Installing Laravel involves a few steps, and it assumes that you have PHP and Composer already installed on your system.
You will have to follow the steps given below for installing Laravel onto your system.
-
PHP: Ensure that PHP is installed on your system. Laravel requires PHP 7.3.0 or higher.
-
Composer: Composer is a dependency manager for PHP. Install Composer by following the instructions on the official Composer website.
-
Install Laravel via Composer: Open a terminal or command prompt and run the following command to create a new Laravel project:
composer create-project --prefer-dist laravel/laravel your-project-name
Replace
your-project-name
with the desired name for your Laravel project. This command downloads the Laravel framework and its dependencies. -
Navigate to Your Project Directory: Change into the newly created project directory:
cd your-project-name -
Generate Application Key: Laravel requires an application key for security purposes. Run the following command to generate the key:
php artisan key:generate -
Configure the Database: Open the
.env
file in the root of your project and configure the database settings, including the database name, username, and password.
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
Save the changes.
-
Run Migrations: Run the following command to migrate the database tables:
php artisan migrateThis command creates the necessary tables in your configured database.
-
Serve Your Application: You can use the built-in server to run your Laravel application. Execute the following command:
php artisan serveThis will start a development server, and you can access your Laravel application by visiting
http://127.0.0.1:8000
in your web browser.
Comments