Kode Blog - Inspiring And Empowering Developers.
In this tutorial, we are going to look at how to install Laravel, configure Laravel and explore the directories of Laravel. We will work with a windows machine in this tutorial but the knowledge can still be applied to other operating systems such as Linux based OS, Mac OS etc.
We will cover the following topics.
Before installing Laravel, ensure that you have the following programs already installed 1. Web server 2. PHP 3. MySQL 4. Composer 5. Integrated Development Environment (IDE)
For this tutorial, we will use XAMPP. XAMPP comes with Apache, MySQL and PHP. The good news is XAMPP is cross platform. If you do not have XAMPP, you can download it from this link. If you prefer working with other types of web servers i.e. IIS, Laravel built in web server, feel free to use them but for these tutorials’ sake, I recommend you work with XAMPP. Installing XAMPP on windows is like installing any windows program. We will not cover how to install it in this tutorial.
Composer is a dependency manager for PHP. You can read more about composer from their official website. You can download composer from this link. We will not cover how to install composer in this tutorial.
This is optional but highly recommended. We will need an IDE to write code. IDE will make you more productive compared to using a plain text editor. I will be using NetBeans IDE for these tutorials. You can download NetBeans IDE from this link.
This section assumes you have already installed composer. In this section, we will;
Step 1: browse to web server root
C:/xampp/htdocsusing windows explorer
C:/xampp/htdocsand select use composer here as shown in the image below
Select use composer here. You will get the following command prompt window
Step 2: Create new Laravel project using composer
composer create-project laravel/laravel larashop
You will get the following output in the command prompt
Wait for the installation to complete
Step 3: Test installation
Browser to the following URL in your web browser.
If you do not get the above welcome page, use the comments section below to share what you get and we will help you out with whatever challenges you will face.
The following table briefly explains the key Laravel directories that you must know about
|1||/app||contains all of your application code|
|2||/app/Console||contains all of your artisan commands|
|3||/app/Events||contains event classes|
|4||/app/Exceptions||contains exception handling classes|
|5||/app/Http||contains controllers, filters, and requests|
|6||/app/Jobs||contains jobs that can be queued|
|7||/app/Listeners||contains handler classes for events|
|8||/bootstrap||contains files required by the bootstrap framework|
|9||/config||contains the application configuration files|
|10||/database||Contains database migrations and seeds. It is also used to store the database for SQLite|
|12||/storage||contains compiled blade templates, filed based sessions, etc.|
|13||/tests||contains automated unit tests|
|14||/vendor||contains composer dependencies|
The application configuration information is located in
/config/app.php. In this section, we are going to;
'debug' => env('APP_DEBUG', false),
Update it to the following code
'debug' => env('APP_DEBUG', true),
'debug' => env('APP_DEBUG', true),sets debug mode to true. This will make Laravel display detailed information when an error occurs. The detailed information is useful for troubleshooting purposes.
Locate the following code
'timezone' => 'UTC',
'timezone' => 'UTC',sets the time zone to UTC. This is the default value If you would like to have a different time zone, you can replace UTC with a value of your preferred time zone.
Locate the following code
'key' => env('APP_KEY', 'SomeRandomString'),
Update it to the following code
'key' => env('APP_KEY', 'inesindinemwanawabambuyabakoiwe'),
'inesindinemwanawabambuyabakoiwe'is a 32 character string that will be used as an encryption key.
You can explore
/config/app.php to see the various settings that are available in it.
The authentication configuration file is located in
/config/auth.php. We will leave the default values as they are. If you want you can change them to meet your requirements.
The database configuration file is located in
/config/database.php. By default, MySQL will be used as the database engine. You can set it to a different database management system if you want but for this tutorial, we will leave the default value.
We will update the following keys;
Locate the following lines
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],
Update the above code to the following
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'larashop'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', 'melody'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],
'database' => env('DB_DATABASE', 'larashop'),sets the database name to larashop. You can go ahead and create an empty database larashop in MySQL.
'username' => env('DB_USERNAME', 'root'),sets root as the database username that will be used for authentication. You should use a valid username for your MySQL instance.
'password' => env('DB_PASSWORD', 'melody'),sets melody as the password that will be used to login. You should use a valid password for your MySQL instance.
In this tutorial, we looked at;
Let’s get our hands dirty by developing a simple hello world application. We will continue building on this project. Use the next tutorial button to navigate to the next tutorial
Tutorial version 1: Date Published 2015-08-25