Home > Backend Development > PHP Tutorial > LotusPhp recommended program directory_PHP tutorial

LotusPhp recommended program directory_PHP tutorial

WBOY
Release: 2016-07-20 11:14:18
Original
853 people have browsed it

A good project will have a fixed format directory. Lotusphp is relatively more flexible and you can reasonably arrange your own program running directory. Here I recommend two directory setting structures

The first is the directory structure recommended by Lotusphp. First, make sure that the server has enabled the parent directory reference function, or guide it to wwwroot/frontend through rewrite (but this is not recommended because there may be multiple applications, unless you just An application, directed to index.php by default)

├─framework
├─app
│  └─frontend                      应用名称
│      ├─action
│      ├─conf
│      ├─lib
│      └─view
│          └─layout
├─conf
│  ├─dev
│  └─standard
├─lib
│  ├─Dao
│  ├─Util
│  └─Service
└─wwwroot
    └─frontend
Copy after login

Everyone can understand at a glance that wwwroot is the web root directory. All program running files, including frameworks, programs, class libraries, plug-ins, configuration files, etc. are in the parent directory of wwwroot. Even if it is hacked, it will only be hacked. If the server is disconnected and you simply browse from the web server, you cannot see any program files and class libraries. Only pictures, scripts and other resources can be accessed in the wwwroot directory. The safety factor of such a configuration is relatively high. The top app folder is the application folder. Multiple applications can be created below. Generally, we often have one application in the foreground and one application in the background. Two applications are enough. For complex logic, the number of applications can be defined as needed. , the names of the corresponding folders in wwwroot and the folders corresponding to the app should be the same. The background program files stored in the app, while the files stored in wwwroot should be foreground scripts, pictures, styles and other files. There are several folders under the application directory. The corresponding function distribution is action, which corresponds to the application file, which is responsible for parsing the background logic part. conf has defined the configuration file of the application, lib is the definition plug-in, and various common functions used by the application. Class library, Dao data table class, view stores views, which can also be understood as what we often call templates. The subfolder layout is where layout view files are stored

The conf directory stores configuration files. The dev directory below is the configuration file used in development mode, while standard is the configuration file stored in production mode. For a simple example, the database configurations on the local and server are different. If the configuration is the same, you can save it as different configurations, enable development mode locally, and transfer it to the server to enable production mode, so you can easily cope with different operating environments. All configuration files are placed in the conf directory. Global configuration is a configuration shared by all applications. Each application's special configuration is placed in conf in the application name directory. In the production environment, only the standard configuration is loaded. In the development mode, the standard configuration is loaded first, and then the development configuration is loaded, overwriting the same ones in the standard configuration.

The lib directory stores some basic class libraries. Plug-ins outside the framework can also be stored here. After lotus is declared, this folder will be automatically loaded, and all class libraries and functions in it will be automatically loaded. , Dao stores the classes declared in the data table, Util stores commonly used functions and class libraries, and Service stores some complex logic class libraries of the program. For example, we often log in in the background and need to judge the legitimacy of the user. Written as a class library, a check method of the class library is called in the action to determine whether the user is legal.

You can put your own defined PHP classes in the lib and action directories and use them directly in other places without include/require statements. The autoloader component will automatically load the classes used, which is loading on demand.

The directory structure and file names in the lib and action directories are arbitrary, as long as the class names are unique, the current autoloader does not use the name space feature of php5.3.

Please note that in the lotusphp running directory, except for the files in the conf and view folders, other files must exist in the form of classes or functions.

There is also a directory structure for those who cannot open parent directory references. Generally, there are many applications in virtual hosts

wwwroot
├─cache
├─framework
├─runtime
│  ├─app
│  │  └─frontend
│  │      ├─action
│  │      ├─conf
│  │      ├─lib
│  │      └─view
│  │          └─layout
│  ├─conf
│  │  ├─dev
│  │  └─standard
│  └─lib
└─static
Copy after login

cache is the cache directory. Many people ask why the first structure above does not set this folder. Because the above structure is suitable for your own server, the cache can be set to the folder you set. You can even set it into the memory, but it is impossible for the virtual host to give you this permission. You can only set it in your own directory, so I added a directory like this. Runtime is the directory where the program runs files, and static is where style sheets and scripts are stored. , picture file. The functions of other directories are the same as above.

These two recommended directory methods are basically suitable for most people’s needs.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440304.htmlTechArticleA good project will have a fixed format directory. Lotusphp is relatively more flexible and can reasonably arrange the running directory of your own program. , here I recommend two directory setting structures. The first one is...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template