Laravel 5.x.x Installation and Configuration

Laravel 5

Laravel is a great PHP framework. Currently, it is the most PHP framework which a lot of companies and people all over the world use it to build amazing applications. In this tutorial, I’ll show you how easy it is to build a web application with Laravel and add authentication to it.

Laravel is a free, open-source PHP framework designed for building web applications with an expressive and elegant syntax. Laravel saves your time and effort because it come with a lot of features.

Well, in this article We are going to take a look on installing, configuration Laravel and explore the Laravel directories structures. And pretty sure We will work with a Ubuntu (Linux) machine.

Pre-requisites for Installing Laravel
Before installing Laravel, ensure that you have installed: Web Server, PHP, MySQL, Composer.

Web Server, PHP & MySQL
For this article, We will use Laravel built-in web server. or if you prefer other kind of web server i.e. XAMPP comes with Apache, MySQL and PHP. The good news is XAMPP come cross platform. If you do not have XAMPP, you can download it from this link.

Composer
Composer is a dependency manager for PHP. You can read more about composer from their official website. We will not cover how to install composer in this article.

Create a New Laravel Project Using Composer
Laravel use Composer to manage its dependencies. So, before using Laravel, ensure you have Composer installed on your machine.

We can install Laravel by issuing the Composer create-project command in the terminal like so:

1
composer create-project --prefer-dist laravel/laravel blog

Wait for the installation to complete then cd into the project and run the command below for running the Laravel built-in web server:

1
php artisan serve

Browser to the following URL http://localhost:300 in your web browser.

Explore Directory Structure
Laravel follow the Model-View-Controller design pattern.

MVC

- Models: query the database and returns the data.
- Views: displays the model data, and sends user actions (e.g. button clicks) to the controller.
- Controllers: handle user requests from the view, retrieve data from the Models and pass them back into the views.

The following table briefly explains the key Laravel directories that you must know about:

Directories Descriptioin
app contains all of your application code.
app/Console contains all of your artisan commands.
app/Events contains event classes.
app/Exceptions contains exception handling classes.
app/Http contains controllers, filters, and requests.
app/Jobs contains jobs that can be queued.
app/Listeners contains handler classes for events.
bootstrap contains files required by the bootstrap framework.
config contains the application configuration files.
database contains database migrations and seeds. It is also used to store the database for SQLite.
public contains the front controllers and assets such as images, CSS, JavaScript etc.
storage contains compiled blade templates, filed based sessions, etc.
tests contains automated unit tests.
vendor contains composer dependencies.


Application Configuration
The application configuration information is located in config/app.php. In this section, we are going to:

1. Set the debugging mode – the debugging mode is used to determine how much information should be displayed when an error occurs.

Open the file config/app.php and upate the following code:

1
'debug' => env('APP_DEBUG', false),

To:

1
'debug' => env('APP_DEBUG', true),

2. Set the time zone – this setting is used for PHP date and date-time functions.

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:

1
'timezone' => 'UTC',

3. Application key – this value is used for encryption purposes.

Update following code:

1
'key' => env('APP_KEY', 'SomeRandomString'),

To:

1
'key' => env('APP_KEY', 'inesindinemwanawabambuyabakoiwe'),

Authentication Configuration
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.

Database Configuration
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.

So far so good, That’s it!!! See ya!!! :)