When installing a specific Laravel version through composer Laravel seems to forcefully install the 9.2 version. This is odd since it doesn't matter which earlier version of Laravel 9.x I install it just forces the 9.2 install onto my machine.
It didn't seem to do this a few weeks ago when setting up a Laravel 9.19.0 version application. Does anyone know what is going on or how to circumvent this?
The issue persists on any version of Laravel 9 that is below 9.2.
I supplied an image regarding the problem below.
This is a fresh Laravel install. Nothing has been changed I only ran the installation command in cmd.
Commands used to attempt to get the version:
This issue has never occured before. Installing specific Laravel distributions always worked until now.
Any help would be appreciated.
composer.json (Please note the version behind the version specified in the install, running composer update/install etc does not do anything to change the version.):
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0.2",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.11",
"laravel/sanctum": "^2.14.1",
"laravel/tinker": "^2.7"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
composer.lock Laravel version:
{
"name": "laravel/framework",
"version": "v9.22.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "b3b3dd43b9899f23df6d1d3e5390bd4662947a46"
},
When you run command composer create-project laravel/laravel
you are creating a project based on the composer package laravel/laravel (source code at GitHub). This project is the Laravel boilerplate code which is typically used as a template for your own project. Using the boilerplate project is optional, you can, in theory, create a new Laravel project completely from scratch, though it's a tedious task. The version you choose when you create the project corresponds to the version of that project for example choosing version 9.1 creates this as a new project locally.
As you can see in all versions 9+ the dependency is laravel/framework: ^9.X
where X is what the latest version the framework happened to be at when they tagged the release (probably). However the key is that ^
means composer is allowed to install the latest version based on semantic versioning. More information on this is here but generally speaking if you specify ^9.X.Y
as a dependency composer is allowed to install the latest package that has a major version of 9 so anything from 9.0.0 to 9.1000.1000 (or more) could be installed.
If you want to install a specific version of the Laravel framework you need to modify your composer.json
file after you have created your boilerplate project and change the version to the exact version you want. For example something like:
"laravel/framework": "9.0",
will force install version 9.0 for the framework. I do not generally recommend doing this because the latest version will have security and bug fixes which you will not be getting.