Error Updating Laravel 5.4 to 5.5 - laravel-5

Method Illuminate\Foundation\ComposerScripts::postAutoloadDump is not callable, can not call post-autoload-dump script
#php artisan package:discover
There are no commands defined in the "package" namespace.
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1

This would normally happen if the version of laravel in your composer.json file is under 5.5.
You will want to make sure you have:
"laravel/framework": "5.5.*",
In the require portion of the json. Sometimes, if you update through composer, it will load the package from the cache. You might want to delete your $PROJECT_DIR/vendor/* folder and then run:
composer update --prefer-source
Notice the output to see that laravel/framework is indeed at 5.5.*.

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 clear cache Laravel?

I tried these commands:
php artisan config:cache
php artisan route:cache
php artisan cache:clear
All of them return me error:
Class 'App\Providers\InvitationServiceProvider' not found
But I dont have InvitationServiceProvider anywhere in project.
So, how to rebuild Laravel?
Also I tried composer dump and php artisan serve
Dump is:
PS C:\Projects\secure> composer dump-autoload -o
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
In ProviderRepository.php line 208:
Class 'App\Providers\InvitationServiceProvider' not found
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
The correct name of the command is
composer dump-autoload
Don't know if you tried that one.
And also the service providers are usually registered within the config\app.php providers array, so take a look in that file and remove it from there too.
Or remove manually the bootstrap\cache\packages.php file.
EDIT:
From your dump it is obvious that you have the service provider registered in the config app file, so you tried to cache the config, try to clear the cache if you haven't tried the manual way yet:
php artisan config:clear
I would really appreciate comments after someone downvotes an answer, this way I don't understand what is wrong in the answer.
Try it
Make sure :
You have a file named InvitationServiceProvider inside App\InvitationServiceProvider.
The class InvitationServiceProvider is namespaced correctly.
You didn't change the app namespace.
//after that run the bellow comments
composer dump-autoload or composer update
You have tried registering your provider under 'providers' array of /app/cofig/app.php
and then You have to do this do a
composer dump-autoload -o

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.

Symfony parse error in output.php when creating project in laravel

Installed laravel 5.6
Have PHP 7.0 installed as well.
When I try
laravel new sample-project
it creates the required files and dependencies but bails with an error below:
PHP Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /home/johndoe/laravel/sample-project/vendor/symfony/console/Output/Output.php on line 40
Have a feeling this might be due to issues with the symfony file but not sure how to go about getting the right version or making a change in Output.php
Trying any other command such as
php artisan list
results in the same error
Composer relevant section denoting laravel 5.6 / php 7.1.3
"require": {
"php": "^7.1.3",
"fideloper/proxy": "~4.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "~1.0"
},
Any help would be appreciated.
EDIT
Based on the answer I had to create a project with laravel version 5.5 which means I had to use
composer create-project laravel/laravel sample-project "5.5.*"
That worked.
Laravel 5.6 requires PHP > 7.1.3
you will need to make sure your server meets the following
requirements:
PHP >= 7.1.3
I ended up having to edit the $PATH in my .bashrc file, because it was picking up an old version of php.
> whereis php
> echo $PATH
I found the correct version of php here: /opt/php71/bin
So now my .bashrc file looks like this:
export PATH=/opt/php71/bin:$PATH
This fixed the error I was getting in composer, AND now php artisan also works!
:-D
PS. The version of php that you're using in the shell may be different from the version used to serve your site. That can be fixed in cpanel's php selector.

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.

Resources