How to Install Laravel 10
Laravel is a powerful PHP framework that allows developers to build robust web applications quickly. This guide will walk you through the process of installing Laravel 10 on your local machine.
Prerequisites
Before you begin, make sure you have the following installed:
- PHP: Laravel 10 requires PHP 8.1 or higher.
- Composer: A dependency manager for PHP.
- Database: (Optional) You may need a database server like MySQL or PostgreSQL, depending on your application requirements.
Step 1: Install PHP
If you haven’t installed PHP yet, you can use Homebrew to install it on macOS. Open your terminal and run:
Verify your PHP installation:
Step 2: Install Composer
Composer is essential for managing Laravel dependencies. If you haven't installed Composer, run the following commands:
Check if Composer is installed:
Step 3: Create a New Laravel Project
You can create a new Laravel 10 project using Composer. Navigate to the directory where you want to create your project and run:
Replace my-laravel-app
with your desired project name.
Step 4: Change to Your Project Directory
Once the installation is complete, navigate to your project directory:
Step 5: Configure Your Environment
Laravel uses a .env
file to manage environment configurations. Open the .env
file in your project directory to configure your database and other settings:
Make any necessary changes (such as database configuration) and save the file.
Step 6: Generate Application Key
Laravel requires an application key, which you can generate using the following command:
This command sets the APP_KEY
value in your .env
file.
Step 7: Run Your Application
Laravel includes a built-in development server. Start the server with the following command:
You should see an output indicating that your application is running. By default, it will be accessible at:
Open this URL in your web browser, and you should see the Laravel welcome page!
Conclusion
🎉 Congratulations! You have successfully installed Laravel 10. You can now start building powerful web applications using this amazing framework.
💬 If you have any questions or need further assistance, please ask!