In order to run Laravel on your local machine, you’ll need to have a local development environment like XAMPP installed. If you’re using Windows, you can easily install XAMPP from the official website here. XAMPP will set up Apache, MySQL, and PHP for you, providing the perfect environment for running Laravel.
Setting up a Laravel project on XAMPP is a straightforward process, but it may involve a few steps. Laravel is a powerful PHP framework, and XAMPP is a great tool for setting up a local development environment. Follow these instructions to create a new Laravel project and get it up and running on your local machine.
Step 1: Navigate to the XAMPP Directory
- To begin, you need to open a command prompt or terminal window.
- Change the directory to the location where XAMPP is installed for PHP projects. In my case, xampp is installed on C:\ drive.
cd C:\xampp\htdocs\php-projects
Step 2: Create a Laravel Project
- Laravel makes use of Composer, a PHP dependency management tool, to create and manage Laravel projects. To create a new Laravel project, use the
create-project
command with Composer in your selected directory.
composer create-project laravel/laravel laravel-app
laravel-app"
. Composer will download the necessary files and set up a fresh Laravel installation.Step 3: Resolve Zip Extension Error
- If you encounter a zip extension error during installation, open the php.ini file from the XAMPP Control Panel.
- Remove the semicolon from the line ;extension=zip.
- Save the changes and restart XAMPP.
Step 4: Open Project in VS Code
- Change the directory to the newly created Laravel project in the cmd. cd laravel-app
- Open the project in the visual studio code. code .
- In ths VS code, it can be observed that laravel required files and folders have been created.
Step 5: Run Laravel Server
- Execute the command php artisan serve in the terminal.
Screenshot 3 - This will start the Laravel development server, and you will see the server information in the command line interface.
Step 6: Access Laravel Application
- Copy the localhost URL provided in the command line.
- Paste the URL into your web browser’s address bar and press Enter.
- You should see the Laravel application up and running, displaying the default Laravel welcome page.
Conclusion: By following these steps, you can easily set up a Laravel project on your XAMPP server and start building your web applications with Laravel.