How to Install Laravel and Composer on Windows and Get Started


- Step 1: Install PHP and Composer
- Step 2: Install the Laravel Installer
- Step 3: Create a New Laravel Application
- Step 4: Install Node.js and NPM
- Step 5: Set Up Frontend Dependencies
- Step 6: Build Frontend Assets
- Step 7: Start the Development Server
- Step 8: Configure Your Environment
- Step 9: Set Up a Database (Optional)
- You’re All Set!
If you’re new to Laravel and web development, getting started might seem overwhelming. But don’t worry—this guide will walk you through the process of installing Laravel 11 on a Windows system step by step. By the end, you’ll have a fully functional Laravel environment ready to build your next project.
Step 1: Install PHP and Composer
Laravel requires PHP and Composer (a dependency manager for PHP). Thankfully, there’s an easy way to install both:
-
Open Windows PowerShell with administrator privileges.
-
Run the following command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4'))This command installs PHP 8.4 and Composer. Restart your terminal after installation to apply the changes.
Step 2: Install the Laravel Installer
With Composer installed, you can now globally install the Laravel installer. Run the following command in PowerShell:
composer global require laravel/installer
This will make the laravel
command available globally on your system.
Step 3: Create a New Laravel Application
-
Navigate to the folder where you want to create your Laravel project. For example:
cd C:\Projects -
Create a new Laravel application by running:
laravel new example-app -
Follow the prompts to configure your project’s testing framework, database, and starter kit.
Step 4: Install Node.js and NPM
Laravel uses Node.js and NPM to manage frontend assets. Follow these steps:
- Download and install the latest LTS version of Node.js from nodejs.org.
- During installation, ensure that you select the option to include NPM (Node Package Manager).
Step 5: Set Up Frontend Dependencies
-
Navigate to your project directory:
cd example-app -
Install the necessary frontend dependencies:
npm install
This installs the packages listed in your package.json
file.
Step 6: Build Frontend Assets
After installing the dependencies, build the frontend assets by running:
npm run build
This compiles your application’s CSS and JavaScript files.
Step 7: Start the Development Server
To start the Laravel development server, run:
composer run dev
This command starts the local development server, queue worker, and Vite development server. Your application will be accessible at:
http://localhost:8000
Step 8: Configure Your Environment
Laravel uses a .env
file in the project root to manage configuration settings like database credentials and application environment. Open this file and update it with your specific setup.
Step 9: Set Up a Database (Optional)
By default, the .env configuration file specifies that Laravel will interact with an SQLite database. If you’re comfortable using SQLite, Laravel is already set up for you. However, if you’d like to use a different database system, follow these steps:
-
Update the
.env
file with your database settings. For example, to use MySQL:DB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=laravelDB_USERNAME=rootDB_PASSWORD= -
Run migrations to create the necessary database tables:
php artisan migrate
You’re All Set!
Congratulations! You’ve successfully installed Laravel 11 on your Windows system. You’re now ready to start developing your application. If you have any questions or run into issues, Laravel’s official documentation is an excellent resource to consult. For beginners, check out the Laravel Bootcamp for a hands-on tour of the framework while walking you through building your first Laravel application.
Welcome to Laravel!
Stay Updated.
I'll you email you as soon as new, fresh content is published.