Laravel is a free, open-source PHP web framework intended for the development of web applications following the model–view–controller (MVC) architectural pattern that requires at least PHP version 5.6.4.
Laravel utilizes composer to manage its dependencies. So, we need to have composer installed before starting to work on this framework.
Download and run Composer-Setup.exe that will install the latest composer version that you can call composer from any directory in your command line. Hit the command stated below in your terminal to create a fresh copy of Laravel project files with all it's dependencies already installed in the specified directory.
composer create-project --prefer-dist Laravel/Laravel projectName
A random APP_KEY will be set with installation in the .env file of your project that secures the user sessions and other encrypted data. If not, you can generate one using key:generate command in the terminal.
php artisan key:generate
Let's have a look at the directory structure of Laravel and their usage.
This directory contains the core codes of the application. It is namespaced under App and is autoloaded by Composer. It contains various additional directories along with the Eloquent models.
This directory holds all of the custom Artisan commands along with the kernel file where the Artisan commands are registered and scheduled tasks are defined.
This directory contains the application's exception handler that handles all the thrown exceptions.
This directory contains all the controllers, middleware and form requests. Almost all of the logic to handle requests entering your application will be placed here.
This directory contains all of the service providers for the application which is responsible for loading the application by binding services, registering events and performing any other tasks to prepare the application for incoming requests.
This directory contains files that load the framework and configure autoloading. This directory also houses a cache directory responsible for performance optimization.
The Config Directory
All of the configuration files are stored in this directory. Laravel framework needs almost no other configuration. The files it houses contain several options that might require changes at times.
The Database Directory
This directory contains your factories, migrations and seeds sub-directory. The factories directory can be used to define models for testing purpose. The migration files can be used to connect to database and create, update or delete database tables or columns while the seeds directory houses methods for adding dummy data to database.
The Resources Directory
The Routes Directory
The routes directory contains all of the route definitions for the application. By default, three route files are included in Laravel.
The web.php file contains routes that provide session state, CSRF protection and cookie encryption.
The api.php file contains routes that provides rate limiting. Requests entering the application through these routes are intended to be authenticated via tokens and will not have access to session state.
The console.php file does not define HTTP routes but the closure based console commands intended to return the value in the terminal.
The Storage Directory
This directory has three sub-directories. The app directory stores any files generated by the application. The framework directory stores sessions, view files and caches and the logs directory contains application's log files. The storage/app/public directory stores user-generated files that are publicly accessible.
The Tests Directory
This directory contains your automated test methods and caches.
The Vendor Directory
This directory contains the framework's composer dependencies.