folder structure
- Why is there no model directory?
- Config Directory
- Database Directory
- Public Directory
- Resources Directory
- Routes Directory
- Storage Directory
- Tests Directory
- Vendor Directory
- App Directory
- Broadcasting Directory
- Console Directory
- Events Directory
- Exceptions Directory
- Http Directory
- Jobs Directory
- Listeners Directory
- Mail Directory
- Notifications Directory
- Policies Directory
- Providers Directory
- Rules Directory
Laravel’s folder structure
- Introduction
- Root directory
- App Directory
- broadcasting
Directory
- console
Directory
- events
Catalog
- exceptions
Catalog
- ## http Directory
- jobs Directory
- listeners Directory
- mail Directory
- notifications Directory
- Catalog
- Catalog
- Catalog
- broadcasting
models
directory. However, the lack of such a directory is intentional. We find "model" ambiguous because different people have different understandings of "model". Some developers refer to an application's "model" as the totality of all its business logic, while others refer to the "model" as the classes that interact with a relational database.
directory by default and allow developers to place them elsewhere.For this reason, we place Eloquent models in the
appRoot Directory
App Directory
app
Directory contains the core of the application code. Almost all classes in your application should go here. We'll look into the details of this directory in more depth later.Bootstrap Directory
bootstrap
Directory containsapp.php for Bootstrap Framework
document. This directory also contains acache
directory. Thecache
directory stores files generated by the framework to improve performance, such as routing and service cache files.Config directory
config
Directory, as the name suggests, contains all configuration files of the application . We encourage you to read through these documents to help familiarize you with all available options.Database directory
database
Directory contains data population and migration files and model factory classes . You can also use it as a SQLite database storage directory.Public directory
public
The directory contains the entry fileindex.php
, which is the entry point for all requests entering the application. This directory also contains some of your resource files (such as images, JavaScript, and CSS).Resources directory
resources
The directory contains views and uncompiled resource files ( such as LESS, SASS or JavaScript). This directory also contains all your language files.Routes directory
routes
The directory contains all route definitions of the application. Laravel includes several routing files by default:web.php
,api .php
,console.php
andchannels.php
. Theweb.php
file containsRouteServiceProvider
routes placed in theweb
middleware group, which provides session state, CSRF protection, and cookie encryption . If your application does not provide a stateless, RESTful API, all routes should be defined in theweb.php
file. The .api.php
file contains theRouteServiceProvider
route placed in theapi
middleware group, which provides frequency limiting. These routes are stateless, so requests coming into the application through these routes are intended to be authenticated via the token and do not have access to session state.console.php
The file is where all console command-based closure functions are defined. Each closure function is bound to a command instance and allows simple interaction with command line IO methods. Although these files do not define HTTP routes, it also defines console-based entry points (routes) into the application.channels.php
A place to register all event broadcast channels supported by your application.Storage directory
storage
The directory contains the compiled Blade template and session session generation files, cache files, and other files generated by the framework. This directory is subdivided into three subdirectories:app
,framework
, andlogs
. Theapp
directory can be used to store any files generated by the application.framework
The directory is used to store files and cache generated by the framework. Finally, thelogs
directory contains the application’s log files.storage/app/public
Can be used to store user-generated files, such as user avatars that need to be publicly accessible. You should create apublic/storage
soft link pointing to this directory. You can create this link directly through thephp artisan storage:link
command.Tests directory
tests
The directory contains automated test files. There are ready-made examples in PHPUnit for your reference. Each test class should be suffixed withTest
. You can use thephpunit
orphp vendor/bin/phpunit
command to run the tests.Vendor Directory
vendor
The directory contains all your Composer dependency packages.App Directory
Most of your applications are located in the
app
directory. By default, this directory is namespaceApp
and is automatically loaded by Composer using the PSR-4 autoloading standard. Theapp
directory contains additional various directories, such as:Console
,Http
andProviders
. Think of theConsole
andHttp
directories as providing APIs to the core of your application. Both the HTTP protocol and the CLI are mechanisms for interacting with applications, but do not actually contain application logic. In other words, they are two ways of issuing commands to your application. TheConsole
directory contains all Artisan commands, while theHttp
directory contains your controllers, middleware, and requests.When you use the
make
Artisan command to generate a class, various other directories will be generated under theapp
directory. So, for example, theapp/Jobs
directory will not exist until you execute themake:job
Artisan command to generate a job class{tip} Many Classes are generated in the
app
directory through Artisan commands. To see the available commands, run thephp artisan list make
command in your terminal.Broadcasting Directory
Broadcasting
Directory contains all broadcast channels for the application kind. These classes are generated using themake:channel
command. This directory does not exist by default, but it will be created when you create the first channel. To learn more about channels, check out the documentation on event broadcasting.Console Directory
##Events directory This directory does not exist by default, but you can passConsole
directory contains all custom Artisan commands for the application. These commands can be generated using themake:command
command. This directory also houses the console kernel, where you can register custom Artisan commands and define scheduled tasks.event :generate
and
make:eventArtisan commands to create.
EventsDirectory placement event class. Events can be used to alert other parts of the application that a given action has occurred, providing great flexibility and decoupling.
##Exceptions DirectoryExceptionsThe directory contains the application's exception handling and is also a A good place to put any exceptions thrown by your application. If you want to customize how exceptions are logged and rendered, you should modify the
Handler
class in this directory.Http Directory
##Jobs DirectoryThis directory does not exist by default, but if you executeHttp
Directory contains your controllers, middleware and form requests. Almost all the logic for handling requests coming into the application is placed in this directory.make :job
Listeners DirectoryThis directory does not exist by default, but if you executeArtisan command, it will be created.
JobsDirectory houses the application's queueable jobs. Jobs can be scheduled by the application or run synchronously during the lifetime of the current request. Jobs that run synchronously during the current request are sometimes called "commands" because they are an implementation of the command pattern.
It will be created when event:generate
or
make:listenerArtisan command is executed.
ListenersThe directory contains event handling classes. An event listener receives an event instance and executes logic in response to the event being triggered. For example, a
UserRegisteredevent might be handled by a
SendWelcomeEmaillistener.
##Mail directoryThis directory does not exist by default, but if you execute
make :mailArtisan command and it will be created.
Mail
The directory contains all the classes used by the application to send mail. The mail object allows you to build a mail class that encapsulates all logic. In this simple class, you can use theMail::send
method to send emails.Notifications DirectoryThis directory does not exist by default, but if you execute
make :notificationArtisan command that will be created.
##Policies DirectoryThis directory does not exist by default, but if you executeNotifications
The directory contains all "transactional" notifications sent by the application, such as simple notifications about events that occur in the application. Laravel's notification functionality abstracts sending notifications through various drivers (such as email, Slack, SMS or stored in a database).make :policy
Artisan command that will be created.Policies
The directory contains the application's authorization policy classes. Policies are used to determine whether a user can perform a given operation on a resource. For more information, view the licensing documentation.
Providers Directory
Providers
The directory contains all service providers for the application. A service provider bootstraps an application by binding services in a service container, registering for events, or preparing to perform any other task for the application's incoming requests.In a new Laravel application, this directory already contains some providers. Feel free to add your own providers to this directory as needed.
##Rules DirectoryThis directory does not exist by default, but if you executemake :rule
This article was first published on theArtisan command that will be created. The
Rulesdirectory contains the application's custom validation rule objects. Rules are used to encapsulate complex validation logic in a simple object. For more information, view the validation documentation.
LearnKu.com website.
- Root Directory