In this recipe, we will take a brief look at the commonly used directory structure of a single module application. A structure of this type is aimed at providing a great starting point for different applications.
We don't need any special means to implement this recipe. We will create the project structure on site, at the development stage. Important points of this recipe are the names of directories and their location.
Follow these steps to complete this recipe:
Create a root directory for your project, where
myprojectname
is the name of your project:/var/www/myprojectname
Create three second-level directories in the root directory:
/var/www/myprojectname/app /var/www/myprojectname/public /var/www/myprojectname/.phalcon
Create the following subdirectories in the
public
directory:/var/www/myprojectname/public/css /var/www/myprojectname/public/img /var/www/myprojectname/public/js
Create the following subdirectories in the
app
directory:/var/www/myprojectname/app/cache /var/www/myprojectname/app/config /var/www/myprojectname/app/controllers /var/www/myprojectname/app/library /var/www/myprojectname/app/logs /var/www/myprojectname/app/models /var/www/myprojectname/app/tasks /var/www/myprojectname/app/views
Create the following subdirectories in the
cache
directory:/var/www/myprojectname/app/cache/annotations /var/www/myprojectname/app/cache/data /var/www/myprojectname/app/cache/metadata /var/www/myprojectname/app/cache/volt
Make sure that the just created structure eventually appears as follows:
myprojectname ├── app │ │── cache │ │ ├── annotations │ │ ├── data │ │ ├── metadata │ │ └── volt │ ├── config │ ├── controllers │ ├── library │ ├── logs │ ├── models │ ├── tasks │ └── views ├── .phalcon └── public ├── css ├── img └── js
The project root directory contains the following directories: app
, public
, and .phalcon
(note that the last one has a point at the beginning of its name).
In the app
directory, there will be, as you would expect, the main application code. We will describe this folder in detail shortly.
The public
directory will contain the entry point of your application and directories for various static assets (JavaScript files, images, and CSS files).
The .phalcon
directory will be used by the Phalcon developer tools for internal purposes (migration creation, code generation, and so on). This is the Phalcon system directory. There is no need to create something in it.
The app
directory contains a subdirectory for controllers as well as their views and models. Additionally, there is the tasks
directory, which is intended for cli tasks, the library
directory for the general application components (plug-ins, helpers, and other custom classes), the logs
directory, where we will store our log
files, and the cache
directory for storing cached data of different application components.
In the cache
directory, there are the following directories: annotations
to store the file cache of model annotations, data to store common file cache, metadata to store the model structure cache, and volt to store the view cache.
Note that we have created different directories to store screenshots. These directories are utilized when we are using the File Cache. If you will be using a cache adapter other than the File one, you don't need to create the directory structure here.