I have Laravel 5.0.34 project that works perfectly fine, but recently I had to install another plugin and realized that as soon as I try to run
composer update
in my root directory, it gives the error
Script php artisan optimize handling the post-update-cmd event returned with an error
I have tried removing the post-update-cmd section of my composer.json, but all that does is removes the error from popping up on the command-line. It still gives an error when I try to display the project though.
I have also tried deleting storage/framework/compiled, but found that I don't have that file/directory
This person seemed to have the same issue, but none of their fixes worked for me
http://laravel.io/forum/03-25-2015-composer-update-throwing-error-script-php-artisan-optimize-handling-the-post-update-cmd-event-returned-with-an-error
Any help would be greatly appreciated!
Related
I am trying to create a simple symfony project.
I run this on console:
composer create-project symfony/skeleton myProjectName
php -S 127.0.0.1:8000 -t myProjectName/public
Project succesfully run at localhost:8000. However, when I begin to inspect the code, I realized VS Code editor is indicating "Undefined type" error in projectDirectory/src/Kernel.php file. Do you have any ideas why this happens and any suggestions towards solution?
I use PHP v7.4.32 and Symfony 5.4 for development. My helper extentions are PHP Intelephense v1.8.2 and PHP IntelliSense v1.0.11.
projectDirectory/src/Kernel.php
The Error
Since it runs succesfully on browser, I dubted that the classes exist somewhere but the VSCode could not solve the relative paths. Then, I tried a couple of extensions. Installation of PHP v1.22.11089 created by DEVSENSE and PHP Namespace Resolver v1.1.9 created by Mehedi Hassan has solved the problem.
I'm trying to open tinker in a Laravel project, but when I run php artisan tinker I get this error:
ErrorException
file_exists(): Unable to find the wrapper "hoa" - did you forget to enable it when you configured PHP?
I can't find everything similar error online, I found only similar errors but with 'wrapper http' .
Does anyone have any suggestions? Thanks
Could this be due to custom code or a library you've imported?
I often find that if I add things to the ServiceProvider or Kernel, they run before many of the artisan commands, and if I've failed to perform the proper "if" checks first, it fails.
I suppose the question I would have in return would be; Is this a fresh Laravel install or have you got custom code and libraries running? I would check there, try removing libraries you've added, HOA from my searching doesn't appear to default to Laravel.
— Happy to revise my answer should more detail be provided
Solved with this command founded on github:
composer require psy/psysh:0.11.2 --dev
I had to clear config and cache, I ran into the following exception :
PHP Fatal error: Uncaught ReflectionException: Class log does not exist in /html/project/bootstrap/cache/compiled.php:1355
I removed bootstrap/compiled.php and ran php artisan clear-compiled, Then the exception got changed a little bit.
Class log does not exist in /html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php:734
Steps i took to solve it :
Checked env for spaces and syntax errors, Which had a blank space and i removed it, but still my php artisan commands are not working.
Ran composer update | Still not working
Some people associate the error with mbstring and php-mysql extensions which i both have.
Tried composer dumpautoload
What am i missing, How should be done ?
I think somewhere in your code there is a typo like this (note lowercase 'l'):
\log::info('test');
And that code is executed when artisan is executed, so, probably this is somewhere in your console commands, or maybe in some services used by console commands, or maybe some global configuration.
Anyhow, search for '\log::' or 'log::' (in top-level file without namespaces this would result in same error message), and you'll find it.
I just moved my app from a AWS EC2 server to another.
I deploy with GitHub, so, everything should be smooth.
a
But I got a lot of issues:
When I try to login with user / Pass, I get:
TokenMismatchException in VerifyCsrfToken.php line 68:
When I try to login with socialite ( Google / FB ) I get:
Socialite: InvalidStateException in AbstractProvider.php Line 200
I manage a plugin https://github.com/proengsoft/laravel-jsvalidation, that I also give error
Off course, in local, everything works fine ( I use Laravel valet )
I can't figure out what is the common point between all those elements.
What I did :
composer install
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artian vendor:publish
composer clear-compiled
php artisan migrate -seed
gulp
copied my old .env to the new server ( it's not automatically deployed )
I also checked my storage/framework/sessions folder had write permission.
EDIT: My guess is there is a problem with sessions, but don't really know what... CRSF Field works with session. Also AbstractProvider issue appears to be a session problem. I tried to change session from file to DB, but with no result.
Any idea why is there so many errors?
I read a lot of cases, but none got my solution.
I solved it changing
APP_ENV=testing
to
APP_ENV=test
in my .env file
One more solution to this problem, hope it helps!
Stupid, but very time consuming!!!
I just pushed my L5.2 app to production server. I have made a few changes, but suddenly I get the following error:
PHP Fatal error: Declaration of Illuminate\Auth\SessionGuard::basic($field = 'email')
must be compatible with
Illuminate\Contracts\Auth\SupportsBasicAuth::basic($field = 'email', $extraConditions
= Array) in /home/forge/domain.com/bootstrap/cache/compiled.php on line 461
The app works fine locally and on the staging server.
just remove the bootstrap/cache/compiled.php file
rm bootstrap/cache/compiled.php
then run
composer dump-autoload
and
php artisan clear-compiled
it should work
I solved it.
I had to do:
rm bootstrap/compiled.php
I suppose that you have run composer update on production. You should copy composer.lock to production server (if you haven't done it yet) and run composer install to install exact same version you have on your localhost
You should also run php artisan clear-compiled because it might be also the problem.
Yes as other said, removing that file solves the error.
But in my case that file gets generated again and again automatically after 1 mins. (So to keep site running I need to manually delete that file over and over :) )
So here is what I did:
Opened that bootstrap/compiled.php, removed all the content and revoke write permission for that file.
And that worked very well for me.
I know its worst/temporary solution, but unless we know the exact cause of that issue and better solution, we can use this solution.
However I don't recommend anyone to use this solution for production sites, but you can use it for just a demo site like my case.