Failing to run source code is often not about the code but about an incomplete development environment. The three mandatory components for almost every Laravel app are PHP, Composer, and a database (usually MySQL/MariaDB). Let us set all three up cleanly.
The Fastest Route: All-in-One Bundles
For beginners, installing a ready-made bundle saves far more time than installing each piece separately:
- Windows: Laragon (lightweight, already includes PHP, MySQL, Apache/Nginx, and Composer).
- macOS: Laravel Herd or Homebrew.
- Cross-platform: XAMPP for PHP + MySQL, then install Composer separately.
If you use one of these, you can skip ahead to the verification section.
Installing PHP
Modern Laravel typically needs PHP 8.1 or newer plus a few extensions. Once PHP is installed, verify it:
php -v
php -m
The first command shows the version, the second lists active extensions. Make sure these are present: mbstring, openssl, pdo_mysql, tokenizer, xml, ctype, json, and bcmath. If any is missing, enable it in php.ini by removing the semicolon in front of its line.
Installing Composer
Composer is PHP's package manager. It downloads Laravel and every library into the vendor/ folder. After installing it from getcomposer.org, verify:
composer --version
If the command is not recognised, Composer is not on your system PATH. On Windows the official installer usually handles this; otherwise add the composer.phar location to your PATH variable.
Installing MySQL / MariaDB
The database stores your app's data. MySQL and MariaDB are interchangeable for most cases. Through phpMyAdmin (bundled with Laragon/XAMPP) you can create a new database in a few clicks. To create one from the command line:
mysql -u root -p
CREATE DATABASE my_app CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Use utf8mb4 so emojis and special characters are stored correctly.
Verify Everything Works Together
Quick test: create a throwaway Laravel project.
composer create-project laravel/laravel env-test
cd env-test
php artisan serve
If the Laravel welcome page appears at http://127.0.0.1:8000, PHP and Composer are healthy. Next, fill in the database settings in .env and run php artisan migrate; if tables are created without error, your database connection is ready too.
Supporting Tools Worth Installing
- Node.js + npm to build front-end assets (Vite/Tailwind).
- Git to track code changes.
- VS Code with the PHP Intelephense and Laravel extensions.
Once this environment is set up once, every future Laravel project becomes far easier to run.