L5.2 PHP Fatal error: Declaration of Illuminate\Auth\SessionGuard::basic - php

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.

Related

VS Code can not reach Symfony\Component and Symfony\Bundle

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.

Laravel 5.2: Class log does not exist in /vendor/laravel/framework/src/Illuminate/Container/Container.php:734

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.

Symfony messenger can't consume messages

Few weeks ago I set up a Message system with Symfony Messenger and it worked great.
Today I wanted to create new object through message, so I went to my server and type the command to consume message
First I had this result
$ bin/console messenger:consume-messages amqp_notifications
/usr/bin/env: ‘php\r’: No such file or directory
It never happened before with my files, and I never changed the line ending or encoding of my file sin PHPstorm.
I tried to use $ php bin/console messenger:consume-messages amqp_notifications
but then I had this error.
Attempted to load class "AMQPConnection" from the global namespace.
Did you forget a "use" statement?
Pretty weird, because I have have the php-amqp ext installed as you can see on the screenshot of my phpinfo
I didn't change anything in my Message class or Handler.
Also, I tried to call new AMQPConnection() on a random action, just to try, and I didn't get the error.
I'm completely lost with this error this time, as everything is installed.
I use PHP 7.3.1 and symfony Messenger 4.2.2
It seems your second issue was already solved by ccKep on his comment.
The first one is that the specific shebang line #!/usr/bin/env php executes the first php found in the $PATH. So if you already have uninstalled it, which seems the case, or it has a symbolic link to another php version, you can get a wrong result.
Tries to check what is inside the $PATH and replace the PHP path for the correct one. You might get the place running which php.

Moved my laravel 5.3 project from a server to other and I got a lot of issues

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!!!

Laravel 5.0 breaks as soon as I try to composer update

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!

Categories