On a local symfony project I removed an unused dependency with composer remove logger, which worked without any problem. When I tried to remove it from production I mess up my project and get the following error:
Package "symfony/monolog-bundle" listed for update is not installed. Ignoring. Loading composer repositories with
package information Updating dependencies (including require-dev)
Nothing to install or update Package symfony/lts is abandoned, you
should avoid using it. Use symfony/flex instead. Generating autoload
files ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class Executing
script cache:clear [KO] [KO] Script cache:clear returned with error
code 255 !! !! [WARNING] Some commands could not be registered:
!! !! In srcProdProjectContainer.php line 938: !!
!! Class 'Symfony\Bridge\Monolog\Logger' not found !!
!! !! !! [WARNING] Some commands could not be registered:
!! !! In srcProdProjectContainer.php line 938: !!
!! Class 'Symfony\Bridge\Monolog\Logger' not found !!
!! !! !! In srcProdProjectContainer.php line 922: !!
!! Attempted to load class "Logger" from namespace
"Symfony\Bridge\Monolog". !! Did you forget a "use" statement
for e.g. "Symfony\Component\HttpKernel\Log !! \Logger" or
"Symfony\Component\HttpKernel\Tests\Logger"? !!
!! !! cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help]
[-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi]
[-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] !!
!!
Removal failed, reverting ./composer.json to its original content.
So it seems it is not even installed? I run composer require logger and it installs, after I again run composer remove logger and I get another error about the lock file being not in sync. I removed the lock file and run composer install, which works. I then try composer remove logger once more and get the error:
Loading composer repositories with package information Updating
dependencies (including require-dev) Package operations: 0 installs, 0
updates, 3 removals
- Removing symfony/monolog-bundle (v3.3.1)
- Removing symfony/monolog-bridge (v4.1.7)
- Removing monolog/monolog (1.24.0) Package symfony/lts is abandoned, you should avoid using it. Use symfony/flex instead.
Writing lock file Generating autoload files ocramius/package-versions:
Generating version class... ocramius/package-versions: ...done
generating version class Symfony operations: 1 recipe
(b1d72bd33ffcb308097230cfdbc2a279)
- Unconfiguring symfony/monolog-bundle (>=3.1): From github.com/symfony/recipes:master Executing script cache:clear [KO]
[KO] Script cache:clear returned with error code 255 !! !!
[WARNING] Some commands could not be registered:
!! !! In srcProdProjectContainer.php line 939: !!
!! Class 'Symfony\Bridge\Monolog\Logger' not found !!
!! !! !! [WARNING] Some commands could not be registered:
!! !! In srcProdProjectContainer.php line 939: !!
!! Class 'Symfony\Bridge\Monolog\Logger' not found !!
!! !! !! In srcProdProjectContainer.php line 923: !!
!! Attempted to load class "Logger" from namespace
"Symfony\Bridge\Monolog". !! Did you forget a "use" statement
for e.g. "Symfony\Component\HttpKernel\Log !! \Logger" or
"Symfony\Component\HttpKernel\Tests\Logger"? !!
!! !! cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help]
[-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi]
[-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] !!
!!
Removal failed, reverting ./composer.json to its original content.
I don't understand why this just won't work and it is really confusing. Does anyone understand what I do wrong or what is wrong?
It turned out to be a cache problem. Although I had tried to clear the cache before with php bin/console cache:clear this was not enough.
In the folder /var/cache/prod there is a file srcProdProjectContainer.php which I had to delete. After deleting this file I managed to remove the dependency.
Related
I tried creating new laravel project using composer but am getting the above error. Any help?
This is the command I used:
"composer create-project --prefer-dist laravel/laravel project-name"
Some Output errors:
Class Symfony\Component\Translation\Tests\DependencyInjection\TranslatorPassTest located in ./vendor/symfony/translation/TranslatorPassTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Symfony\Component\Translation\Loader\ArrayLoader located in ./vendor/symfony/translation/ArrayLoader.php does not comply with psr-4 autoloading standard. Skipping.
Class Symfony\Component\Translation\Tests\Provider\NullProviderFactoryTest located in ./vendor/symfony/translation/Provider/NullProviderFactoryTest.php does not comply with psr-4 autoloading standard. Skipping.
Until the namespace change is accounted for you can temporarily set
"symfony/translation": "v5.3.7"
Update it with composer update and it should work again.
The package has been updated to:
"symfony/translation": "v5.3.9"
and it is working well.
https://github.com/symfony/translation/releases/tag/v5.3.9
I have reverted my composer.lock and then just composer install. It seams that the translator new update is not properly set. For new installations the solution should be what the user3672987 gave as temp solution.
Temporary solution :
You can quick fix it by adding temporarily this line to your composer.json
"symfony/translation": "v5.3.7",
Initial answer :
Same for me, got this error when I'm trying to install a new project or using composer install or composer update on any project :
> #php artisan package:discover --ansi
Error
Class "Symfony\Component\Translation\Loader\ArrayLoader" not found
at vendor/nesbot/carbon/src/Carbon/Translator.php:80
76▕ public function __construct($locale, Translation\Formatter\MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false)
77▕ {
78▕ $this->initializing = true;
79▕ $this->directories = [__DIR__.'/Lang'];
➜ 80▕ $this->addLoader('array', new Translation\Loader\ArrayLoader());
81▕ parent::__construct($locale, $formatter, $cacheDir, $debug);
82▕ $this->initializing = false;
83▕ }
84▕
+13 vendor frames
14 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Carbon\Laravel\ServiceProvider))
+5 vendor frames
20 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Edit :
Apparently, the package symfony/translation had a minor release that changed the namespace of ArrayLoader :
https://github.com/symfony/translation/releases/tag/v5.3.8
https://github.com/briannesbitt/Carbon/issues/2466
When I ran composer update OR bin/console cache:clear it had issue bellow:
Executing script cache:clear [KO]
Script cache:clear returned with error code 1
In ArrayNode.php line 331:
Unrecognized options "dir_name, namespace" under
"doctrine_migrations". Ava !! ilable options are
"all_or_nothing", "check_database_platform", "connection !! ",
"custom_template", "em", "factories", "migrations",
"migrations_paths", !! "organize_migrations", "services",
"storage".
Script #auto-scripts was called via post-update-cmd
I resolved this problem by changing:
I edited doctrine-migrations.yaml:
Befor:
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/Migrations'
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
namespace: DoctrineMigrations
After:
doctrine_migrations:
migrations_paths:
'DoctrineMigrations': '%kernel.project_dir%/src/Migrations'
reference:
https://github.com/doctrine/DoctrineMigrationsBundle/blob/3.1.x/UPGRADE.md
I'm trying to run composer update on my project on a production server and I keep getting this error:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
[ReflectionException]
Class App\Console\Commands\BlockModelsDidNotShowUp does not exist
Script php artisan optimize handling the post-update-cmd event returned with error code 1
Before this I had a permission denied error because of /storage/logs/laravel.log file - I've updated permissions on that file and I keep getting an error from above.
I've tried this, but I don't have bootstrap/cache/compiled.php file.
If you deleted this class, just clear the cache with:
php artisan clear-compiled
Or delete bootstrap/cache/services.php file manually.
So, I have an API endpoint /api/v1/xxx that calls a single controller and method.
In the routes/api.php I have added the following logic
if (Auth::guard('api')->guest()) {
Route::post('xxx', 'API\v1\XXController#xx');
} else {
Route::post('xxx', 'API\v1\XXController#xx')->middleware('auth:api');
}
Everything works except when I run composer install, I get the following error:
a#b /var/www/html/test/app13 $ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
[LogicException]
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
Script php artisan optimize handling the post-install-cmd event returned with error code 1
Removing the lines in routes/api.php does not output that ^ error when I run composer install.
What am I doing wrong?
Thanks for any help.
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
This above lines says everything, you have laravel/passport installed and enabled but you forget to generate the key,
run command
php artisan passport:install
and it will work just fine.
This is basically a problem of moving a laravel package from workbench to vendor, but the solutions in other threads have not worked in this case:
I have a package iateadonut/signup.
I created a fresh laravel installation (laravel_test), and, just for testing sake, I put iateadonut/signup in laravel_test/workbench/.
I put Iateadonut\Signup\SignupServiceProvider, in the 'providers' array in app.php.
I then run:
/laravel_test> php artisan dump-autoload
and get:
Generating optimized class loader
Running for workbench [iateadonut/signup]...
My package is successfully installed.
On a fresh installation of laravel (laravel_test), I then put iateadonut/signup in larael_test/vendor.
I put Iateadonut\Signup\SignupServiceProvider, in the 'providers' array in app.php.
I then run:
/laravel_test> php artisan dump-autoload
and get:
PHP Fatal error: Class 'Iateadonut\Signup\SignupServiceProvider' not found in /var/www/html/laravel_test/bootstrap/compiled.php on line 4214
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Iateadonut\Signup\SignupServiceProvider' not found","file":"/var/www/html/laravel_test/bootstrap/compiled.php","line":4214}}
Any idea what could be wrong?
Here is a more google friendly version in case someone else is looking for this:
PHP Fatal error: Class 'Vendor\Package\PackageServiceProvider' not found in /var/www/html/laravel/bootstrap/compiled.php on line 4214
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Vender\Package\PackageServiceProvider' not found","file":"/var/www/html/laravel/bootstrap/compiled.php","line":4214}}
Try to remove the the bootstrap/compiled.php file and try your composer dumpautoload again