[Laravel 5.1 Document] schema--Application directory structure

Source: Internet
Author: User

1. Introduction

Laravel applying the default directory structure attempts to provide a good starting point for both large and small applications, and of course, you can reorganize the application directory structure yourself as you like, laravel there are no restrictions on where classes are loaded-as long as composer can load them automatically.

2. root directory

The newly installed Laravel app contains many folders:

appThe directory contains the core code of the application;

bootstrapThe directory contains a few files for the framework's startup and automatic loading configuration, and a cache folder to contain the boot files generated by the framework to improve performance;

configThe directory contains all the configuration files for the application;

databaseThe directory contains data migration and fill files, if you like it can also be used as a SQLite database storage directory;

publicThe directory contains the front-end controller and resource files (Pictures, JS, CSS, etc.);

resourcesThe directory contains view files and native resource files (less, SASS, Coffeescript), and localized files;

storageThe directory contains the compiled blade template, the file-based session, the file cache, and other framework-generated files, which are quarantined into app , framework and logs directories, app directories used to store the files that framework the application will use. The directory is used to hold the files and caches generated by the framework, and finally, the logs directory contains the application log files;

testsThe catalog contains automated tests, which already provide an out-of-the-box PHPUnit example;

vendorThe directory contains composer dependencies;

3. App Directory

The core code of the app is located in the app directory, which, by default, is located under the Namespace app and is automatically loaded by composer via PSR-4 auto load standard. You can app:name modify the namespace with the artisan command.

appThe directory contains multiple subdirectories, such as Console ,, Http , and Providers so on. Consoleand Http directories provide access to the application core of the Api,http protocol and the CLI are two mechanisms for interacting with the application, but do not actually contain the application logic. In other words, they are just two ways to publish commands to an app. The Console directory contains all the artisan commands, including Http controllers, filters, requests, and so on.

JobsA directory is where a queue task is placed, the tasks in the app can be queued, or they can be executed synchronously during the current request life cycle.

EventsThe directory is where the event classes are placed, and events can be used to inform the application that other parts of the given action have occurred and provide flexible decoupling processing.

ListenersThe directory contains the processor class for the event, the processor receives an event and provides the response logic after the event, for example, the UserRegistered event can be handled by the SendWelcomeEmail listener.

ExceptionsThe directory contains the exception handler for the application, and it is a good place to handle any exceptions thrown by the app.

Note: app Many of the classes in the directory can be generated through the artisan command, and to see all valid commands, you can run the commands in the terminal php artisan list make .

4. Set the application's command space

As discussed above, applying the default namespace is, App of course, you can modify the namespace to match the name of the app, and modifying the namespace can be done by app:name command. For example, if your app is named "Socialnet", you can run the following command:

php artisan app:name SocialNet

Of course, you can also continue to use App namespaces without modification.

[Laravel 5.1 Document] schema--Application directory structure

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.