Before installing Laravel, ensure your system meets the following requirements:
✅ PHP 8.1 or higher
✅ Composer (PHP dependency manager)
✅ MySQL or SQLite (Database)
✅ Node.js & NPM (For frontend assets, optional)
You can check your PHP version using:
php -v
Laravel requires Composer to manage dependencies.
🔹 Download Composer from getcomposer.org and install it.
🔹 Verify the installation by running:
composer -V
This should display the Composer version, confirming it's installed.
There are two ways to install Laravel:
Run the following command to install Laravel globally:
composer global require laravel/installer
After installation, create a new Laravel project using:
laravel new my_project
If you don’t use the Laravel installer, you can directly create a Laravel project using:
composer create-project --prefer-dist laravel/laravel my_project
Once installed, navigate to your project folder:
cd my_project
Laravel uses an .env file to manage environment settings.
🔹 Open .env
file in the root directory and set database details:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=root
DB_PASSWORD=
Replace these values with your actual database credentials.
Run the following command to start Laravel's built-in development server:
php artisan serve
This will output a local server URL, such as:This will output a local server URL, such as:
Starting Laravel development server: http://127.0.0.1:8000
To ensure Laravel is installed correctly, run:
php artisan --version
This should return the Laravel version installed on your system.
If you're using MySQL, create a database and configure it in the .env
file (as mentioned earlier). Then, run migrations to set up database tables:
php artisan migrate
🎯 You have successfully installed Laravel and set up the development environment! You can now start building applications using Laravel’s powerful features like routing, controllers, models, and authentication.
👉 Learn about Routing in Laravel to define your application URLs.
👉 Explore Eloquent ORM for database interactions.
Would you like a tutorial on any specific part? 🚀