Call to undefined function Symfony\Component\Console\Input\escapeshellarg() - laravel

When running composer install in production I get a new error message today:
$ composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
Error
Call to undefined function Symfony\Component\Console\Input\escapeshellarg()
at vendor/symfony/console/Input/Input.php:195
191▕ * #return string
192▕ */
193▕ public function escapeToken(string $token)
194▕ {
➜ 195▕ return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
196▕ }
197▕
198▕ /**
199▕ * {#inheritdoc}
+1 vendor frames
2 [internal]:0
Symfony\Component\Console\Input\ArgvInput::Symfony\Component\Console\Input\{closure}("package:discover")
+8 vendor frames
11 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
I can't figure out what is wrong. I'm wondering if the dependencies have got into a funny state and I need to do a fresh install of the vendor directory?

Turns out the function escapeshellarg() was disabled by the hosting provider. Thank you Nico for your help!

Related

"Class 'Symfony\Component\Translation\Loader\ArrayLoader' not found"

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

Laravel ER diagram generator getAllModelsFromEachDirectory()

When I try to follow the instruction here (https://github.com/beyondcode/laravel-er-diagram-generator) I get the following error.
Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to BeyondCode\ErdGenerator\GenerateDiagramCommand::getAllModelsFromEachDirectory() must be of the type array, null given, called in vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php on line 96
at vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:101
97|
98| return $modelsFromDirectories;
99| }
100|
101| protected function getAllModelsFromEachDirectory(array $directories): Collection
102| {
103| return collect($directories)
104| ->map(function ($directory) {
105| return $this->modelFinder->getModelsInDirectory($directory)->all();
Exception trace:
1 BeyondCode\ErdGenerator\GenerateDiagramCommand::getAllModelsFromEachDirectory()
vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:96
2 BeyondCode\ErdGenerator\GenerateDiagramCommand::getModelsThatShouldBeInspected()
vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:57
Please use the argument -v to see more details.
I've already opened an issue in the repository.
Screen capture of the error:
Posting for others that may encounter same issue.
Confirm you are using the latest version 1.4.0 of the library
Also if you're using php artisan serve try to stop the server. Run php artisan config:cache, and restart the artisan sever.
Note that the reason why you might need to run php artisan config:cache is because Laravel does cache the app's configurations. if you changed or added new configurations you might explicitly need to clear the configuration cache so that Laravel can cache the new configurations.
If no solution yet. Try this
php artisan vendor:publish --provider=BeyondCode\\ErdGenerator\\ErdGeneratorServiceProvider.
Then repeat step 2.

Laravel Queue Cache not updating

I have used Laravel queues in my application and when i try to run
php artisan queue:restart
it gives me following exception:
ErrorException : file_put_contents(/storage/framework/cache/data/ee/2f/ee2f842aa7bb1f53edf3a2ed2c09a1807ffa6c90): failed to open stream: No such file or directory
at /var/www/html/asd/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
118| * #return int
119| */
120| public function put($path, $contents, $lock = false)
121| {
> 122| return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
123| }
124|
125| /**
126| * Prepend to a file.
Exception trace:
1 file_put_contents("/var/www/html/asd/storage/framework/cache/data/ee/2f/ee2f842aa7bb1f53edf3a2ed2c09a1807ffa6c90", "9999999999i:1558912298;")
/var/www/html/asd/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
2 Illuminate\Filesystem\Filesystem::put("/var/www/html/asd/storage/framework/cache/data/ee/2f/ee2f842aa7bb1f53edf3a2ed2c09a1807ffa6c90", "9999999999i:1558912298;")
/var/www/html/asd/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php:65
Please use the argument -v to see more details.
I have tried running following commands but to no avail:
composer dump-autoload
php artisan optimize
php artisan clear-compiled
php artisan cache:clear
php artisan view:clear
php artisan route:cache
I am not able to reflect changes made to my application logic that is in queue handlers, any help in this regard is much appreciated.
You forgot to run php artisan config:cache with the other commands
I read somewhere else that you could try
chmod 775 -R storage

Laravel: Class App\Console\Commands\BlockModelsDidNotShowUp does not exist

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.

Laravel 5.4: What is the best way to create routes based on user logged in or logged out

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.

Resources