📜  拉拉维尔 |目录结构

📅  最后修改于: 2022-05-13 01:56:40.914000             🧑  作者: Mango

拉拉维尔 |目录结构

当您创建新的 Laravel 应用程序时,它将包含大量文件夹,如下图所示:

这些文件夹中的每一个都完成了框架整体功能的特定任务。下面解释了每个文件夹的用途,但在此之前,让我们看一下它们中的每一个:

目录结构:

  • 应用目录
  • 引导目录
  • 配置目录
  • 数据库目录
  • 公共目录
  • 资源目录
  • 路线目录
  • 存储目录
  • 测试目录
  • 供应商目录

每个目录的用途:

1. app 目录:这个目录是框架的核心,后端开发人员大多在这个目录上工作。它包含我们 Web 应用程序的所有后端代码,例如 Controllers、Broadcasts、Providers、Custom Artisan Commands、Middlewares 等。该目录还包含许多子目录,如下图所示:

应用目录:

DirectoryPurpose
ConsoleThis directory contains all Artisan commands which are created by us. These commands can be generated using the php artisan make:command command.
ExceptionsThis directory contains the application’s exception handling files. Here you can create your own specific exceptions to be thrown by our application.
HttpThis directory contains our controllers, middleware, and form requests. Almost all of the backend to handle requests entering our application will be placed here.
ProvidersThis directory contains all of the service providers for the application. Service providers bootstrap our application by making services available to us by registering them.
BroadcastingThis directory is not there by default but can be created by using the php artisan make:channel command. It contains all of the broadcast channel classes for our application to broadcast your events.
EventsThis directory is not there by default but can be created by using the php artisan make:event command. This directory contains event classes which can be used to give signals to other parts of the application or vice-versa.
JobsThis directory is not there by default but can be created by using the php artisan make:job command. This directory contains lineup jobs for our application.
ListenersThis directory is not there by default but can be created by using the php artisan make:listener command. This directory contains the classes that handle our events.
MailThis directory is not there by default but can be created by using the php artisan make:mail command. This directory contains all of our classes that represent emails sent by application.
NotificationsThis directory is not there by default but can be created by using the php artisan make:notification command. This directory contains all of the “transactional” notifications that are sent by our application.
PoliciesThis directory is not there by default but can be created by using the php artisan make:policy command. This directory contains the authorization policy classes which are used to determine if a user can access or change a specific data or not.
RulesThis directory is not there by default but can be created by using the php artisan make:rule command. This directory contains the self-created validation rule objects which are used to encapsulate complicated validation logic in a simple object.

2. bootstrap目录:该目录包含app. PHP从整个框架引导的地方。该目录还包含缓存目录,用于存储框架生成的文件以进行性能优化。

3. config目录:该目录包含所有与数据库、邮件、会话、服务等相关的配置文件。

4. 数据库目录:该目录包含数据库迁移、模型工厂和种子。

5. public 目录:这个目录包含索引。 PHP文件是入口点,它处理应用程序接收到的所有请求并配置自动加载。除此之外,此目录还包含应用程序中使用的资产,如图像、javaScript 和 CSS。

6. 资源目录:该目录包含应用程序的前端。所有构成应用程序前端的 HTML 代码都以 Blade 模板的形式出现在这里,这是 Laravel 自带的模板引擎。

7. routes 目录:该目录包含应用程序的所有路由定义。

8. storage 目录:该目录包含编译好的 Blade 模板、基于文件的会话、文件缓存以及框架生成的其他文件。

9. 测试目录:该目录包含我们所有的自动化测试,这些测试是确保应用程序是否按预期工作所必需的。

10、vendor目录:这个目录包含了我们框架需要的通过Composer下载的所有依赖。