Sometimes read of documentation is boring and you don’t need to know everything when you’re starting learn something new. Because it, I made a summary about the most important things about Laravel Directory structure.
Folders and main files
I think that before we getting started development is very important knowing the directory structure of your applications, it can show us where put some file or how something works for example. See the default directory structure of Laravel (except the dep folder).
Important! The dep directory isn’t of Laravel fresh installation, i’ve created it to store some files.
Little tip: most important folders
app, config, database, routes.
Well, let’s start.
Files in the main folder
See the complete detailed info about files in root folder of Laravel:
In the default application directory, you see some important files like:
.env, artisan, composer, webpack.mix.js
Little tip: Laravel folders that does not exists by default
There are some folders that not exists by default:
Events, Exceptions, Jobs, Listeners, Mail, Notifications, Policies, Rules
Digging in first important folders
The text about these folders was extracted from documentation.
The app directory contains a variety of additional directories such as Console, Http, and Providers. Think of the Console and Http directories as providing an API into the core of your application. The HTTP protocol and CLI are both mechanisms to interact with your application, but do not actually contain application logic. In other words, they are simply two ways of issuing commands to your application. The Console directory contains all of your Artisan commands, while the Http directory contains your controllers, middleware, and requests.
A variety of other directories will be generated inside the app directory as you use the make Artisan commands to generate classes. So, for example, the app/Jobs directory will not exist until you execute the make:job Artisan command to generate a job class.
Inside the app folder we need to focus first on app/Http/Controllers folder.
The Http Directory
The Http directory contains your controllers, middleware, and form requests. Almost all of the logic to handle requests entering your application will be placed in this directory.
The Config Directory
The config directory, as the name implies, contains all of your application’s configuration files. It’s a great idea to read through all of these files and familiarize yourself with all of the options available to you.
The Database Directory
The database directory contains your database migration and seeds. If you wish, you may also use this directory to hold an SQLite database.
The Routes Directory
The routes directory contains all of the route definitions for your application. By default, several route files are included with Laravel: web.php, api.php, console.php and channels.php.
The web.php file contains routes that the RouteServiceProvider places in the web middleware group, which provides session state, CSRF protection, and cookie encryption. If your application does not offer a stateless, RESTful API, all of your routes will most likely be defined in the web.php file.
Well this is just a summary about how to start studying the Laravel directory structure.
As I told before, you can see everything about Directory structure at https://laravel.com/docs/5.5/structure
See you in next post! 🙂