lotusphp Recommended program Directory _php tutorial

Source: Internet
Author: User
Tags autoloader php class
A good project will be fixed-format directory, lotusphp relatively flexible, can reasonably arrange their own program run directory, here I recommend 2 kinds of directory configuration

The first is the directory structure recommended by lotusphp, first of all to ensure that the server opens the parent directory reference function, or through rewrite boot into the wwwroot/frontend (but this is not recommended, because there may be multiple applications, unless you have an application, Default boot to index.php)

├─framework├─app│  └─frontend                      app name │      ├─action│      ├─conf│      ├─lib│      └─view│          └─layout├─conf│  ├─dev│  └─standard├─lib│  ├─dao│  ├─util│  └─service└─wwwroot    └─frontend

Wwwroot everyone to understand, is the Web root directory, all the program running files, including the framework, programs, class libraries, plug-ins, configuration files, etc. are in the parent directory of wwwroot, even if it is black, only hacked server, simply browse from the Web server, is unable to see any program files and class library , the Wwwroot directory can only access resources such as pictures, scripts, and so on. The safety factor for this configuration is relatively high. The top app folder is the application folder, the following can create a new number of applications, generally like we are often the foreground of an application, the background of an application, 2 applications enough, for complex logic, you can define the number of applications as needed, Wwwroot folder and app corresponding folder name should be consistent, the app stored in the background program files, and wwwroot should be stored in the foreground script, pictures, styles and other files. The application directory also has several folders, the corresponding function is the action corresponding to the application file, is responsible for parsing the background logic part, conf to define the application configuration file, Lib is the definition of plug-ins, a variety of applications used by the Common class Library, DAO data table class, view storage view, It can also be understood as a template that we often say, where the subfolder layout is the one that holds the layout view file.

Conf directory is a configuration file, where the following dev directory is the configuration file applied in development mode, and standard is the production mode of the configuration file, for example, the local and server database configuration is not the same, you can save as a different configuration, enable the development mode locally, To the server to enable production mode, you can calmly handle different operating environments. All configuration files are placed in the Conf directory. The global configuration is a shared configuration for all apps, and each application special configuration is placed into the Conf under the app name directory. The production environment only loads the standard configuration, the development mode loads the standard configuration first, and then loads the development configuration, overwriting the same in the standard configuration.

Lib directory is stored in some basic library, outside the framework of the plug-in can also be stored here, the Lotus is declared, will automatically load this folder, all of the library and functions will be loaded automatically, DAO is stored in the data table declaration of the class, Util store is commonly used functions and class library, Service storage is a program of some complex logic of the class library, such as we often log in, to determine the legitimacy of the user, you can write a class library, action calls the class library of a check method, you can determine whether the user is legitimate.

You can put your own defined PHP class into the Lib and the Action directory, in other places directly new to use, do not need to have a include/require statement. The Autoloader component will automatically load the class used, which is loaded on demand yo.

The directory structure and file name under LIB and action directories are arbitrary, so long as the class name is guaranteed to be unique, the current autoloader does not use the php5.3 name space feature.

Note that the rest of the files in the lotusphp run directory, except for files under the Conf,view folder, must exist in the form of a class or function.

There is also a directory structure for unable to open the parent directory reference, the general virtual host application will be more

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

Cache is cached directory, structure many people want to ask why the first structure above does not set this folder, because the above structure is suitable for their own server, so the cache can be set to their own set of folders, or even set into memory, but the virtual host is not possible to give you this permission, To set up only in their own directory, so add a directory, runtime is the program run file directory, static is stored style sheets, scripts, picture files. The functionality of the other directories is the same as above.

These two recommended directory approaches are basically suited to the needs of most people.

http://www.bkjia.com/PHPjc/440304.html www.bkjia.com true http://www.bkjia.com/PHPjc/440304.html techarticle a good project will be fixed-format directory, lotusphp relatively flexible, you can reasonably arrange their own program run directory, here I recommend 2 kinds of directory of the configuration of the first kind is ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.