Laravel is an open-source PHP web application framework designed for building web applications following the Model-View-Controller (MVC) architectural pattern. It was created in 2011 and become one of the most popular PHP frameworks used for web development.

Laravel provides developers with a number of powerful features and tools, including a simple and expressive syntax, built-in database migration and schema management, automated testing, and a robust ecosystem of third-party packages. Some of the key features of Laravel include its powerful routing engine, which allows developers to easily define application routes using a simple and intuitive syntax, and its comprehensive ORM (Object-Relational Mapping) system, which makes working with databases and models a breeze.

Laravel also includes a templating engine called Blade, which makes it easy to create dynamic, reusable views for your application, and a built-in authentication system for managing user authentication and authorization.


Prerequisites

Laravel utilizes Composer to manage its dependencies. Take a look on how to install Composer 2 on your computer.

Installation

Assuming that Composer is already installed on your computer, you can generate a fresh Laravel project directly using Composer. Upon execution, this command will create a new project within a directory named my_project in the current location and install any necessary dependencies:

composer create-project laravel/laravel my_project

Environment variables

Environment variables are used to store sensitive data such as passwords, credentials and other information that should not be written directly in code. Environment variables must be used to configure variables or configuration details that may differ between environments. Laravel provides an example of how should initial environment file look like in .env document. It should be modified based on your needs and configuration.

Encryption key

When you install Laravel, an application key is automatically generated for your project. This key is a random string that is used to safeguard your user sessions and encrypt data. To generate a new key, you can execute the following command:

Source code ☀ 1 linephp artisan key:generate

The command sets the APP_KEY value in your .env file. It is important to note that if the encryption key needs to be regenerated after an application has been in use, any data that was previously encrypted using the old key cannot be decrypted using the new encryption key.

Using Laravel

Once you have configured the application, you can initiate Laravel's local development server. To do this, navigate to the project directory and use the following artisan command to start up the server:

Source code ☀ 1 linephp artisan serve

We will see that our terminal will be blocked by the process and will show us the URL to access the APP from any browser installed on our computer. Usually it will be something similar to http://127.0.0.1:8000