[Laravel 5.2 Document] schema--Application directory structure

Source: Internet
Author: User
Tags sqlite database

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:

The app directory contains the core code of the app;

The bootstrap 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;

The Config directory contains all the configuration files for the application;

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

The public directory contains front-end controllers and resource files (images, JavaScript, CSS, etc.);

The resources directory contains view files and native resource files (less, SASS, Coffeescript), as well as localized files;

The storage directory contains compiled blade templates, file-based sessions, file caches, and other framework-generated files that are subdivided into apps, frameworks, and logs subdirectories, and the app directory is used to store the files that the app uses. The framework directory is used to hold the files and caches generated by the frame, and finally, the logs directory contains the application log files;

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

The vendor directory contains composer dependencies;

3. App Directory

The app's core code is located in the app directory, which, by default, is located under the Namespace app and automatically loaded by Composer via PSR-4 Auto-load standard. You can modify this namespace by Artisan command App:name.

The app directory contains multiple subdirectories, such as Console, Http, providers, and so on. The console and HTTP directories provide the API,HTTP protocol to the application core and the CLI as 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, and the HTTP directory contains the controller, middleware, and requests.

The jobs directory is where queue tasks are placed, the tasks in the application can be queued, or they can be executed synchronously during the current request life cycle.

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

The listeners 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.

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

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

  • 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.