Root directory

contentsSecondary directoryIntroductioneffect
/app Application Directory The core code of the application
/bootstrap Startup directory
app.php Frame startup and auto-loading configuration
./cacheRouting and service cachingFiles generated by the framework to improve performance
/config Configuration directory
/database database directory Database migration files and filling files
/public Public Directory Application entry files and front-end resource files
index.phpApplication entry file
/resources Resource catalogApplication view files and uncompiled native front-end resource files
/routes routing directory
web.phpweb middleware groupSupport Session, CSRF protection and Cookie encryption function
api.phpapi middleware groupSupport frequency limit function
console.phpConsole commandUsed to define all closure-based console commands
channels.php Used to register all event broadcast channels supported by the application
/storage File storage directory Blade, Session, file cache, files generated by the framework
./app Application-generated files
./publicUsed to store user-generated files
./framework Files and caches generated by the framework
./logs Application log file
/tests test catalog You can run the test phpunit
/vendor dependent directory Contains all dependencies of Composer

Remark

1. Console routing/routes/console.php

Artisan::command('inspire', function () {
    $this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');

php artisan inspire

Application directory/app

contentsIntroductioneffect
/BroadcastingBroadcast channelEvent broadcast. make:channel
/ConsoleTask scriptRegister Artisan commands to define scheduling tasks. make:command
/EventseventStore the event class. event:generate and make:event
/ExceptionsException handlingContains application exception handler
/HttpWeb applicationContains controllers, middleware, and form requests, etc.
/JobsQueue taskStore queue tasks. make:job
/ListenersEvent monitoringEvent listener. event:generate and make:listener
/MailmailMail related classes. make:mail
/ModelsEloquent modelEloquent model class. make:model
/NotificationsnotifySend notification. make:notification
/PoliciesAuthorizationAuthorization strategy. make:policy
/Providersservice providerBind services to containers, register events, and perform other tasks during application startup.
/RulesValidation rulesEncapsulate complex verification logic in a single object. make:rule

Remark

PSR-4 automatic loading standard https://learnku.com/docs/psr/psr-4-autoloader/1608
1. "Class" here refers to all classes, interfaces, traits, reusable code blocks, and other similar structures.
2. A complete class name must have the following structure:
 \<命名空间>(\<子命名空间>)*\<类名>
  1. The complete class name must have a top-level namespace, called "vendor namespace";
  2. The complete class name can have one or more sub-namespaces;
  3. The complete class name must have a final class name;
  4. The underline in any part of the complete class name has no special meaning;
  5. The complete class name can consist of any uppercase and lowercase letters;
  6. All class names must be case sensitive.
  7. When loading the corresponding file according to the complete class name...
  8. In the complete class name, the first namespace separator is removed, and one or more consecutive namespaces and sub-namespaces in front are used as "namespace prefixes", which must correspond to at least one "root directory";
  9. immediately after the namespace prefix must with the corresponding "file base directory", and the namespace separator will be used as the directory separator
  10. The class name at the end must be the same as the corresponding file with the suffix .php.
  11. The implementation of the autoloader must not throw exceptions, must not trigger any level of error message, and should not have a return value.
3. Examples

| Full class name | Namespace prefix | File base directory | File path |
| :--------------------------- | :-------------- | :--------------------- | :---------------------------------------- |
| \Acme\Log\Writer\File_Writer | Acme\Log\Writer | ./acme-log-writer/lib/ | ./acme-log-writer/lib/File_Writer.php |
| \Aura\Web\Response\Status | Aura\Web | /path/to/aura-web/src/ | /path/to/aura-web/src/Response/Status.php |
| \Symfony\Core\Request | Symfony\Core | ./vendor/Symfony/Core/ | ./vendor/Symfony/Core/Request.php |
| \Zend\Acl | Zend | /usr/includes/Zend/ | /usr/includes/Zend/Acl.php |


IT小马
1.2k 声望166 粉丝

Php - Go - Vue - 云原生