Script php artisan optimize handling the post-install-cmd event returned with error code 255 - laravel-5

After clone the git repo, install composer and Laravel , this error will come out. Anyone can solve this error?
When I run laravel new, I get this error:
Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> php -r "file_exists('.env') || copy('.env.example', '.env');"
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
Script php artisan optimize handling the post-install-cmd event returned with error code 255
Application ready! Build something amazing.

Which repo you cloned? if you want create a new laravel project, just try run laravel new projectName,
check the doc here

Related

Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255

I am developing this package: https://github.com/craftisan/laravel-seo as an extension for laravel-admin and while requiring it via composer into a laravel project, I am getting this error (see github issue here):
% composer require craftisan/laravel-seo --ignore-platform-reqs
Using version dev-master for craftisan/laravel-seo
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing craftisan/laravel-seo (dev-master 96e32bc): Cloning 96e32bc192 from cache
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.
Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
Installation failed, reverting ./composer.json to its original content.
I tried debugging a lot, checked config file syntax, even dumped output all the way from package:discover command in artisan, didn't find anything.
storage/ & bootstrap/cache is writeable
rm -rf bootstrap/cache done
Any ideas why this could be happening?
Fixed
Installed the same package in a fresh laravel application. Apparently the relative link to config file was broken but composer install wasn't giving error trace. Missed preceding / after __DIR__:
// Publish configuration
$this->publishes([
__DIR__ . '../config/seo.php' => config_path('seo.php'),
// fix: __DIR__ . '/../config/seo.php' => config_path('seo.php'),
], 'seo');

How to remove ckeditor package (error: Class 'Ckeditor\CkeditorServiceProvider' not found)?

I followed the steps mentioned here:
How to remove a package from Laravel using composer?
including the step: Remove Service Provider from "app/config/app.php" (reference in "providers" array)
However, since I got an error:
In ProviderRepository.php line 208:
Class 'Ckeditor\CkeditorServiceProvider' not found
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1
The app is down and I cannot do any operation in terminal. How to get rid of the reference to this class?
Then run these commands.
php artisan cache:clear
composer dump-autoload -o
If an error occurs while clearing cache, then delete cache files under bootstrap/cache manually.

Class 'Mpociot\ApiDoc\ApiDocGeneratorServiceProvider' not found

I am currently working on L5.5 and there for generating api docs I have installed this package, now I don't need that package I decided to uninstall it but while doing uninstalling I got this error.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Mpociot\ApiDoc\ApiDocGeneratorServiceProvider' not found
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1
I checked on repo's issue and on net but haven't got satisfying answer.
I uninstalled this repo by doing following this
remove repo from composer.json and then I ran the command composer update.
Any idea why it is appearing and how to fix this error??
Thank you for your efforts :)
I have removed the mentioned file still I am getting this error
Go to config/app.php and make sure you removed
Mpociot\ApiDoc\ApiDocGeneratorServiceProvider::class
from this. Now run:
php artisan clear-compiled
and
php artisan config:clear
to make sure you are not using any cache. After that there shouldn't be any problems
NOTE
if you are getting this issue even after this then go to bootstrap/cache/config.php as mentioned by Marcin NabiaƂek down there in comments and in that delete Mpociot\ApiDoc\ApiDocGeneratorServiceProvider::class from the array of providers after that rerun the above three commands.

Upgrading my Laravel Yajra Table

I'm currently in 7.5.0 and I want to upgrade to 8.0.3, I followed the steps in https://yajrabox.com/docs/laravel-datatables/master/upgrade but I encountered this error
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating yajra/laravel-datatables-oracle (v7.5.0 => v8.0.3): Downloading (conneDownloading (100%)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Yajra\Datatables\DatatablesServiceProvider' not found
Script php artisan optimize handling the post-update-cmd event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
In the Yajra DataTables V8 the Namespace and Facade was updated.
https://yajrabox.com/docs/laravel-datatables/master/upgrade#namespace
https://yajrabox.com/docs/laravel-datatables/master/upgrade#facade
In folder config/app.php, temporarily comment out
Yajra\Datatables\DatatablesServiceProvider.
Run command composer update.
Uncomment the provider Yajra\Datatables\DatatablesServiceProvider.
Done.
To make sure it works, can run again command composer update.
Reference from: https://yajrabox.com/docs/laravel-datatables/master/upgrade#v5-to-v6

Fresh CentOS 7, first Laravel Installation.Composer install breaks

I am fallowing this tutorial:
http://linoxide.com/linux-how-to/install-laravel-php-centos-7-ubuntu-15-04/
And on step 5) when running composer install in the project directory it starts to do staff, as expected, until this happened:
Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
PHP Fatal error: Undefined constant 'Illuminate\Session\TokenMismatchException' in /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 779
PHP Fatal error: Undefined constant 'Illuminate\Session\TokenMismatchException' in /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 779
Script php artisan optimize handling the post-install-cmd event returned with error code 255
What is the problem?
Thanks, Aleks
start creating a project (after updating composer) instead of downloading the referenced file do the following
from your terminal type in cd /var/www/
then type composer create-project laravel/laravel laravel-develop
your composer should download the latest version of Laravel
try it this way feel free to ask any questions.
Good Luck

Resources