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

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

Related

Laravel: Database connection error when using "config:cache", but working fine without caching

Now this is a really weird one.
My .env file is fine. When I run
php artisan config:clear
everything works. But when I run
php artisan config:cache
my database connection stops working:
SQLSTATE[HY000] [1045] Access denied for user 'foobar'#'xxx.xxx.xxx.xxx'
So again: My settings are correct. But when they are cached, they stop working. How could this possibly be?! Laravel seems to use some kind of old settings when using the cache, but I have no idea where these are coming from?
What I already tried:
php artisan optimize:clear
rm -rf bootstrap/cache/*.php
I ran into this issue while trying to setup a Laravel forge deployment script for zero downtime.
I hard coded the path to the ssl files for my database connection in /config/database.php. Changed that to use the values of .env, now it's working.

Call to undefined method Illuminate\Routing\RouteFileRegistrar::get() - Error after upgrading from Laravel 5.7 to 5.8

I have a running app written on Laravel 5.7. I tried to change the record in composer.json to match "5.8.*" and ran composer update. On my local (win10/WAMP) machine it went fine, but on the staging server (Debian 9/nginx) the update command changed the vendor contents and failed at the end.
Since then anything I do with the app on the server I get this error and I can't find any information anywhere.
Call to undefined method Illuminate\Routing\RouteFileRegistrar::get()
And this is the line that fails:
$this->get('login', 'Auth\LoginController#showLoginForm')->name('login');
Thanks in advance!
remove "$this" from your routes and use "Route::"
It is a problem with the routes. Mainly, you get this problem when you are using routes with resource or resources. Make sure you do not have any problem in routes by using the command:
#php artisan route:list
If you are getting any problem while route listing please fix it.
I solved this problem in Laravel 5.8 by fixing routes.
Hope this will help.

Laravel swagger api-docs json file not found

Hello i am trying to add swagger into my laravel project.
installed
composer require "darkaonline/l5-swagger:5.6.*"
so when i do
http://127.0.0.1:8000/api/documentation
got info
Fetch error Not Found http://127.0.0.1:8000/docs/api-docs.json
already created docs folder with that json file.
Should i adjust route or change swagger base URL somewhere, not sure whats the problem. Tnx for your help.
You should run the command
php artisan l5-swagger:generate
after adding the annotations
And if you are still getting the Not Found http://your-host/docs/api-docs.json error.
Run chown www-data storage -R
if you still get "Not Found" error after running the
command : php artisan l5-swagger:generate
run
php artisan route:cache , worked for me
open in incognito in chrome or as a private tab in firefox
this problem for your internet explorer, chrome, FireFox

laravel artisan app:name resulted in syntax errors

I am using Laravel 5 on a shared host. I have installed it ok. However on running:
/usr/bin/php55-cli artisan app:name 247
the laravel install broke. I tracked it down to app.php and the new name caused syntax errors. I got it working again by using Linux to do a global replace changing it back from 247 to App.
Does anyone know why? And how can I get artisan to work properly?
Thanks
This is not Laravel nor artisan issue, but plain PHP syntax error.
PHP does not allow variable or class name to start with an integer. Same goes to namespaces. So your error comes from you app name being 247. First letter can not be an integer.

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

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.

Categories