Installing Laravel via Composer (Step by Step)
In this article, we'll walk through the exact steps to install Laravel using Composer, create a new project, and run it for the first time using Laravel's built-in development server. By the end, you'll have a real, working Laravel app open in your browser.
Introduction
Now that PHP, Composer, and Node.js are installed and verified on your machine, you're ready for the exciting part: creating your first Laravel project. This step is where all that environment setup finally pays off, as Composer handles the heavy lifting of downloading Laravel and all its dependencies for you.
The good news is that installing Laravel today is much simpler than it used to be. Composer takes care of resolving versions, downloading packages, and setting up a working project structure in just one command. Within a few minutes, you'll have a fully functional Laravel application running locally on your computer.
In this article, we'll walk through the exact steps to install Laravel using Composer, create a new project, and run it for the first time using Laravel's built-in development server. By the end, you'll have a real, working Laravel app open in your browser.
Installing Laravel via Composer
There are two common ways to create a new Laravel project: using the Laravel installer, or using composer create-project directly. Both achieve the same result, so pick whichever feels more comfortable.
Method 1: Using the Laravel Installer (Recommended)
The Laravel installer is a small command-line tool that makes creating new projects faster and gives you extra options during setup (like choosing a starter kit or database).
Step 1: Install the Laravel installer globally
composer global require laravel/installerStep 2: Make sure Composer's global bin directory is in your PATH This is usually located at:
~/.config/composer/vendor/bin(Linux/macOS)%APPDATA%\Composer\vendor\bin(Windows)
If the laravel command isn't recognized after installation, this is almost always the cause — add that folder to your PATH and restart your terminal.
Step 3: Create a new Laravel project
laravel new my-projectYou'll be prompted to choose options like a starter kit (React, Vue, Livewire, or none), a testing framework, and a database. For beginners, choosing the defaults or "None" for the starter kit is perfectly fine — you can always add these later.
Method 2: Using Composer Directly
If you prefer not to install a global tool, you can create a project directly with Composer:
composer create-project laravel/laravel my-projectThis downloads the latest stable Laravel release and sets up the project folder for you, without any interactive prompts.
Running Your Laravel Project for the First Time
Once the installation finishes, navigate into your new project folder:
cd my-projectThen start Laravel's built-in local development server:
php artisan serveYou should see output similar to:
Server running on [http://127.0.0.1:8000]Open that address in your browser, and you'll see the default Laravel welcome page — confirmation that everything is working correctly.
Step-by-Step Installation Checklist
Confirm PHP and Composer are installed by running
php -vandcomposer -v.Install the Laravel installer globally with
composer global require laravel/installer(optional but recommended).Check your PATH includes Composer's global bin directory, if using the installer.
Create a new project using either
laravel new my-projectorcomposer create-project laravel/laravel my-project.Navigate into the project folder using
cd my-project.Start the local server with
php artisan serve.Open your browser and visit
http://127.0.0.1:8000to see the welcome page.Stop the server anytime with
Ctrl + Cin the terminal when you're done working.
FAQ About Installing Laravel
1. What's the difference between using the Laravel installer and composer create-project? The Laravel installer offers an interactive setup experience with extra options like choosing a starter kit, while composer create-project simply downloads the base Laravel skeleton without prompts. Both result in a working Laravel project.
2. Do I need an internet connection to install Laravel? Yes, both methods download files from Packagist (Composer's package repository) and GitHub, so an active internet connection is required during installation.
3. Why does laravel new say the command is not found? This usually means Composer's global bin directory isn't in your system's PATH. Locate that folder and add it manually, then restart your terminal.
4. Can I install a specific version of Laravel instead of the latest one? Yes. With Composer, you can specify a version like this: composer create-project laravel/laravel my-project "10.*" to install Laravel 10 instead of the latest release.
5. Is php artisan serve suitable for production use? No. It's meant only for local development. For production, you should use a proper web server like Nginx or Apache with PHP-FPM.
6. What should I do if I get a "class not found" or dependency error after installation? Try running composer install inside the project folder to make sure all dependencies were downloaded correctly, and confirm your PHP version meets Laravel's minimum requirement.
7. Can I rename my project folder after creating it? Yes, renaming the folder is safe and won't break anything, since Laravel doesn't hard-code the folder name anywhere in its core configuration.
Conclusion
With Laravel successfully installed and running on your machine, you've officially crossed the biggest hurdle in getting started. The Composer-based installation process is designed to be quick and painless, so you can spend more time building and less time configuring.
In the next article, we'll explore the Laravel folder structure in detail, so you understand exactly what all those generated files and folders are for before you start writing your own code.
Found this helpful? Share it!