- 1 year ago
How to autostart XAMPP and Laravel project in Windows
To auto-start XAMPP and a Laravel project on Windows, you can create a batch script that starts both XAMPP's Apache and MySQL servers, and then launches your Laravel project using the built-in PHP development server. By creating a batch script, you can easily start everything with a single click or at system startup.
Here's a step-by-step guide to auto-start XAMPP and your Laravel project on Windows:
Start XAMPP Automatically:
- Open the XAMPP Control Panel.
- Click on the "Service" button for both Apache and MySQL to install them as Windows services. This will ensure they start automatically on system boot.
Create a Batch Script to Start Laravel Project:
Open a text editor (e.g., Notepad) and create a new file named
start_laravel.bat
.Add the following lines to the batch script:
batch@echo off
REM Change the directory to your Laravel project root folder
cd "C:\path\to\your\laravel\project"
REM Start Laravel using PHP's built-in development server
php artisan serve
Replace
"C:\path\to\your\laravel\project"
with the actual path to your Laravel project's root folder.
Create a Shortcut for the Batch Script:
Right-click on the
start_laravel.bat
file and select "Create Shortcut."Move the shortcut to a convenient location, e.g., the desktop or a specific folder for easy access.
Auto-Start the Batch Script on System Startup:
Press
Win + R
to open the "Run" dialog.Type
shell:startup
and click "OK." This will open the "Startup" folder for your user.Move the shortcut for
start_laravel.bat
into the "Startup" folder. This will cause the script to run automatically on system startup.
Now, whenever you start your computer, XAMPP's Apache and MySQL servers will automatically start as services, and your Laravel project will be launched using the PHP development server.
Please note that using the PHP development server (php artisan serve
) is suitable for development purposes, but it is not recommended for production use. For production deployment, you should use a proper web server like Apache or Nginx to serve your Laravel application.
Additionally, if your Laravel project requires a database, make sure to configure the database connection in the Laravel project's .env
file to match the credentials of your XAMPP's MySQL server.