I am working on a legacy Laravel 6 app which is isolated from the rest of the system without inte.net connection, and when I try to run composer dump-autoload
I get:
In ProviderRepository.php line 208: Class 'Facade\Ignition\IgnitionServiceProvider' not found
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
So I can't do what's described in this post: Laravel with App Engine Standard Class 'Facade\Ignition\IgnitionServiceProvider' not found
Update #1: I added the missing class to the dont-discover
array in composer.json
, then it showed another class missing, so I started adding them one-by-one. Apparently the following 3 packages are "missing" (even though their files are there):
"facade/ignition"
, "laravel/ui"
, "nunomaduro/collision"
.
When added all these 3 to the dont-discover
array, I was successfully able to run composer dump-autoload
:
"extra": {
"laravel": {
"dont-discover": ["facade/ignition", "laravel/ui", "nunomaduro/collision"]
}
}
But still, I want to know if I can fix the issue with these 3 packages
Can I fix it without inte.net connection? Anything I can try to do manually?
Update #2:
I saw a comment on another post here suggesting moving the packages from require-dev
to require
. I did it, and it worked!
https://stackoverflow.com/a/59369455/18178584
In the same post, someone suggested it might be related to a bug when updating from composer 1.x to 2.x:
https://stackoverflow.com/a/67847239/18178584
But since I don't know exactly what happened here, which one of the above can be the cause? And, since the first solution solved it for me, is it safe to leave these 3 packages in require
instead of require-dev
?
Try to refresh your Laravel project, like:
composer run refresh
But for that to work, you first need to implement refresh
script in composer.json
file, like:
{
// ...
"scripts": {
"refresh": [
"@composer dump-autoload --no-scripts",
"@php artisan config:clear",
"@composer run post-autoload-dump --verbose",
"@php artisan cache:clear",
"@php artisan clear-compiled",
"@php artisan view:clear",
"@php artisan route:clear"
],
// ...
}
}
Also, as mentioned in comments, ensure important packages are in require
section of composer.json
(instead of require-dev
).
Only unit-test and/or lint purpose packages should be in
require-dev
.
Normally composer dump-autoload
is enough, but sometimes post-autoload-dump
uses cached class, hence php artisan config:clear
needs to run first, but " config:clear
" may crash if dump-autoload
is not done yet.
Solution? Like above, use --no-scripts
and trigger post-autoload-dump
later manually;-)
(Well not "manually", I do it all automatically, but you get the idea.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.