Laravel is a free and open-source PHP web framework widely used for building modern web applications. It emphasizes simplicity, security, and elegance in the development process, offering several features that streamline and enhance web development:
In this tutorial you through the hassle-free process of installing the latest version of Laravel. Before you begin, make sure you have the following prerequisites in place:
PHP: Laravel requires PHP 7.4 or higher. You can check your PHP version by running the following command in your terminal:
php -v
The Laravel Installer is a command-line tool that simplifies the process of creating and managing Laravel projects. To install it, open your terminal and run the following command:
composer global require laravel/installer
This command installs the Laravel Installer globally on your system.
Once you have the Laravel Installer installed, you can create a new Laravel project with the following command:
laravel new project-name
Replace project-name
with the name you want to give to your Laravel project. This command will download the latest version of Laravel and set up a new project directory with the specified name.
Navigate to your project directory:
cd project-name
Next, copy the .env.example
file to .env
:
cp .env.example .env
Open the .env
file and configure your database connection settings. Update the following lines with your database credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your-database-name
DB_USERNAME=your-database-username
DB_PASSWORD=your-database-password
Laravel uses an application key for security purposes, such as encrypting user sessions and passwords. Generate a new application key by running:
php artisan key:generate
You can use Laravel's built-in development server to serve your application:
php artisan serve
This will start a development server, and you can access your Laravel application at http://localhost:8000
in your web browser.
Installing the latest Laravel version is a straightforward process, thanks to the Laravel Installer and Composer. By following the steps outlined in this article, you can have a fresh Laravel installation up and running in no time.