What PHP version is required for Laravel 12
- Required PHP Version for Laravel 12
- How to Check the Required PHP Version for Any Laravel Version
- How to Check Your PHP Version
- How to Upgrade PHP
- Verifying Compatibility Before Installing Laravel 12
- Summary
Required PHP Version for Laravel 12
Laravel 12 requires PHP 8.2 or higher to run. This version requirement aligns with Laravel's commitment to supporting modern PHP features, improved performance, and better type safety.
How to Check the Required PHP Version for Any Laravel Version
To check which PHP version is required for a specific Laravel release, follow these steps:
- Go to the laravel/laravel GitHub repository.
- Switch to the branch corresponding to the version you want to check (for example,
12.x,11.x, etc.). - Open the
composer.jsonfile. - Find the
requiresection and you’ll see the PHP version requirement listed like this:
"require": { "php": "^8.2", ...}
This ensures you always verify against the official and most accurate source.
How to Check Your PHP Version
You can quickly verify your PHP version using the following command:
php -v
Example output:
PHP 8.2.12 (cli) (built: Sep 27 2024 15:00:00) (NTS)
If the version displayed is 8.2.0 or higher, you’re ready to install Laravel 12.
How to Upgrade PHP
If your PHP version is lower than 8.2, upgrade it before creating or running a Laravel 12 project.
On Ubuntu / Debian
sudo add-apt-repository ppa:ondrej/php -ysudo apt updatesudo apt install php8.2 php8.2-cli php8.2-common php8.2-mbstring php8.2-xml php8.2-bcmath php8.2-curl php8.2-zip -y
On macOS (Homebrew)
brew update
On Windows
- Download PHP 8.2 from windows.php.net/download.
- Extract it and update your system PATH variable to include the PHP directory.
Verifying Compatibility Before Installing Laravel 12
If you’re installing Laravel 12 using Composer, you can confirm your PHP version meets the requirement by running:
composer create-project laravel/laravel example-app "^12.0"
If your PHP version is below 8.2, Composer will show an error similar to:
Your PHP version (8.1.12) does not satisfy that requirement.
Upgrade your PHP installation, and rerun the command.
Summary
- Required PHP version: 8.2 or higher
- Reason: Laravel 12 uses new PHP 8.2 language features
-
Check PHP version:
php -v -
Check required PHP for any version: View the
composer.jsonin the respective Laravel branch on GitHub - Upgrade: Use your OS-specific package manager or installer
Always ensure your environment meets Laravel’s minimum requirements to avoid compatibility issues and to take advantage of the framework’s full potential.
Stay Updated.
I'll you email you as soon as new, fresh content is published.