English 中文(简体)
Phalcon - Application Structure
  • 时间:2024-12-22

Phalcon - Apppcation Structure


Previous Page Next Page  

In this chapter, we will discuss the Apppcation Structure of Phalcon. Following is the complete directory structure of a Phalcon project.

Structure

There is one root folder which is considered as the code base and is pubpcly available for the web server. It is also called as web directory. Other folders outside the web root directory are considered out of reach for the web server and for Phalcon project.

Once a project is created, the directory structure will be visible as follows in the wamp/xampp folder. Consider for the project which we created in the previous chapter.

demo1

Following are the folders and sub-folders of the project.

App

This folder consists of all vital script files and folders. The complete web apppcation is designed on the basis of “app” folder. The configuration files help in assisting the necessary configuration for running the apppcation smoothly.

Following is the detailed view of app folder for the given Phalcon web apppcation.

App

It consists of config, controllers, pbrary, migrations, models and views.

Config

Config

All the configuration required for the web apppcation in Phalcon is comprised in this folder. It includes information related to database connectivity, third-party pbraries to be added if any, and the services to be included.

Controllers

All the controllers are included in this folder. They are used for processing requests and generating response.

Library

Third-party pbraries for the web apppcation (apart from the existing Phalcon framework).

Library

Migrations

This sub-folder consists of all the files associated with data migration, which can also be used in any other framework.

Models

Models include all the logic required to interact with the database. It is actually used for data representation.

Views

It constitutes all the views related to the web apppcation. These views are displayed to the end users with the help of controllers.

Cache

This directory includes data related to caching, which helps in improving the performance.

Pubpc

It includes all the folders for asset management purpose which comprises of CSS, JavaScript, files to be uploaded, and some meta data.

Pubpc

.htaccess File

Web servers running on Apache Web Server software use .htaccess as a configuration file. When it is placed in a directory, all the necessary configuration is loaded as soon as the server is started.

For example, it is possible to configure a website so that it will available only to specific IP addresses with .htaccess file.

Advertisements