I am having a deja vu, when encountering the same issue I had some time ago: Composer - installing/updating Laravel classic spark doesn't work
After some research, I need to update my Laravel to match my provider's new PHP instances. I want to run Laravel 9 with Spark 11 and Cashier 12. I didn't want to go with Spark 12, since that seems to require Cashier 13 and there is an extensive upgrade guide linked to that.
I made the modifications in composer.json and do a composer update. This is the composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^8.0.2",
"fruitcake/laravel-cors": "^3.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"laravel/spark-aurelius": "~11.0",
"laravel/tinker": "^2.7",
"laravel/ui": "^4.2",
"laravelcollective/html": "^6.4",
"mpociot/vat-calculator": "^3.4",
"realrashid/sweet-alert": "^7.0"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"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"
]
},
"repositories": [
{
"type": "composer",
"url": "https://spark-satis.laravel.com"
}
],
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
This nicely installs the spark-aurelius folder in vendor/laravel. When I check the version, it seems version 11:
php artisan spark:version
Laravel Spark version 11.0.9
However, I have some modifications I need to make to some Spark code, so I need to move the Spark folder outside the vendor.
I moved the spark-aurelius folder from the vendor folder to the root folder of my project and modified the composer json:
"repositories": [
{
"type": "path",
"url": "./spark-aurelius"
}
],
However, when I run composer update to get the symlink, I get:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires laravel/spark-aurelius ~11.0, found laravel/spark-aurelius[dev-master, 10.x-dev (alias of dev-master)] but these do not match your constraint and are therefore not installable. Make sure you either fix the constraint or avoid updating this package to keep the one present in the lock file (laravel/spark-aurelius[v11.0.9]).
I don't understand this. I copied the folder from the vendor location in a separate location, made the link and suddenly the version is not correct?
Interestingly, when I checked the composer.json for spark-aurelius, I see:
"extra": {
"branch-alias": {
"dev-master": "10.x-dev"
}
},
"minimum-stability": "dev"
so there is a reference to version 10.x-dev in there
When I search for the version that is previously reported, I find:
egrep -r 11.0.9 *
src/Spark.php: public static $version = '11.0.9';
I think I'm almost there! Perhaps there is a better way to extract the source folder from the vendor folder?