Laravel is one of the most demanded and powerful PHP framework in today's date created by Taylor Otwell. It is an open-source framework which can be used to develop any kind of web applications in PHP. Laravel follows the Model-View-Controller(MVC) architectural pattern.
My previous blog PHP Laravel Framework - Intro, Versions and Features was about an introduction of Laravel framework and its incredible features which makes it popular among developers. To explore those marvellous features and to test them practically, Let's start with Laravel Framework.
The first step is How to install Laravel framework in our system?. This article defines the different ways to install and create a new Laravel application using composer. This article also provide a brief description of directory structure of new Laravel application.
System Requirements :
Homestead is a virtual machine which satisfied all the requirements for installing and running Laravel application. If you are not using Homestead, your system has to fulfill the following requirements to install Laravel framework.
Installation :
Laravel uses composer to manage dependencies. So before installing Laravel, make sure that composer is installed in your system.
If the composer is already installed on your system, You can skip Step 1 and start from Step 2 and If composer is not installed follow the steps given below :
Step 1: Installing composer.
The Composer is a dependency management tool in PHP. It will manage the project dependencies (install or update the libraries) required for the project. To install composer, visit the given url and follow the instructions for installation.
https://getcomposer.org/
Step 2: Laravel Installation.
There are two ways to install Laravel using composer :
(i) Using Laravel Installer :
1. Install the Laravel installer in the first step.
composer global require “laravel/installer”
2. After installing, the laravel installer laravel new
command is used to create a fresh Laravel installation in the specified directory with all required files and directories.
laravel new laravel5
The above command will create a new directory with the name laravel5 which consists all the directories and files of Laravel framework and all dependencies.
(ii) Via Composer Create-Project :
The other way to install Laravel is using composer create-project
command. Run the below command to create a new Laravel application.
composer create-project –prefer-dist laravel/laravel laravel5
The above command creates a new application directory (laravel5). The image below displays the installation process of Laravel framework and required dependencies using above command.
Step 3: Running Application
To run the project on a local development server. Open console/terminal, go to the project directory and run the artisan serve
command.
php artisan serve
Note: The above command will start the development server at http://localhost:8000
Step 4: To verify the successful installation of Laravel, copy and paste the above url in the browser and it's open the below screen, which shows the successful installation of Laravel.
Directory Structure :
The default application consists different directories and files. Below is the brief description of directories :
1. app: This directory contains the core code of the application.
2. bootstrap: This directory contains the app.php file which is bootstrapping script of the application.
3. config: This directory contains all configuration files of the application.
4. database: This directory stores database migration and seed files.
5. public: This directory is the entry point of application. It also contains assets of the application like js, css and images etc.
6. resources: This directory contains application's view files as well as raw assets such as LESS & Sass files, localization and language files and templates that are rendered as HTML.
7. storage: The storage directory contains the files generated by framework, logs and cache files.
8. test: This directory contains the test scripts.
9. vendor: This directory contains composer dependencies.
The above image displays the list of all directories and files of the newly installed Laravel application. All of the configuration files are stored in the config directory. The fresh installation of Laravel application comes with .env.example file, if you installed application using composer, composer renamed the file into .env file, otherwise you have to rename it manually. This file is used to set the application configuration for the local system environment. It would be more helpful for the development environment with a team working on the same project having different system environments, It helps developer to set the configuration as per their system environment.
References :
1. https://laravel.com/docs/5.5#installing-laravel
2. https://laravel.com/docs/5.5/structure
0 Comment(s)