Laravel Route:list not working throwing run time exception - laravel

when i tried to display all routes
by using php artisan route:list
it showing some runtime exception like this
[RuntimeException]
Session store not set on request.
how can i get my list of routes

Related

Laravel new routes return 404, when deploying to Forge

I have deployed new code to my Forge server. This code includes new routes (web, api, with and without auth).I have run php artisan optimize, but all the new routes return a 404.
The php artisan route:list command display the new routes. I am getting crazy...
Help!?
thanks
OK, someone gave me the solution on Laravel's Slack. I had to relaunch PHP fpm on my Forge server, in order to reset the OPCache.

301 Moved Permanently on post ajax requests in laravel

I upload a laravel project on server;
When I run all the ajax post request request run like this:
Request URL: http://example.com/user/register/
Request Method: POST
Status Code: 301 Moved Permanently
Then this run:
Request URL: http://example.com/user/register
Request Method: GET
Status Code: 500 Internal Server Error (from disk cache)
Post method change to get method and return error;
How can I solve this?!
I try php artisan cache:clear php artisan config:clear php artisan view:clear
But also return error
I found the answer. put here to help the others.
It take so time of me. The problem was so simple.
I just remove the backslash from end of url of each post actions.
For example /user/register/ must change to /user/register :|
And cache of the browser must be clear for each page.
In my case for uploading file, my route was same as public directory -> Route::POST('upload/data', [UploadDataController::class, 'upload'])->name('uploadData');
On my public folder:
public/upload/data
So I changed the route as upload/uploadData and its perfectly fine!

Laravel custom artisan command cannot access model

I'm trying to create a artisan command to dump data from database table in my existing Laravel 6 project.
I'm following the web to create the command, it works and prints out.
https://codeinphp.github.io/post/creating-your-own-artisan-in-php/
However I could not access the model in the existing project.
I've tried using
MyModel::all()
but it returns error about connection
PHP Fatal error: Uncaught Error: Call to a member function
connection() on null
I also tried do the data dump using existing getCsv() from controller, like
app('App\Http\Controllers\MyController')->getCsv();
Then it complains
Class request does not exist
I also tired doing
$table = DB::table('my_table');
But error returns as
A facade root has not been set

Laravel 7.x View-related exception after config:cache

I am a junior php developer and very new to laravel. I have the following problem. I cached my config with php artisan config:cache, the programm broke with error 500 and in the log i saw the exception shown bellow :
local.ERROR: Method Illuminate\View\View::__toString() must not throw an exception, caught Facade\Ignition\Exceptions\ViewException: Route [homepage.get] not defined.
(View: /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/resources/views/static/includes/header.blade.php) {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Method Illuminate\View\View::__toString() must not throw an exception, caught Facade\Ignition\Exceptions\ViewException: Route [homepage.get] not defined.
(View: /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/resources/views/static/includes/header.blade.php) at /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/vendor/symfony/http-foundation/Response.php:0).
I cleared everything in cache and it worked. Can anyone please help me ? Any steps?? Files to look for ? Anything

Laravel 5.8 419 error / Auth user not available after login

Problem description: after login I receive a 419 page, also session token keeps changing which causes Auth::check() to fail. Database token stays the same but on Laravel side session token keeps changing.
Locally it works this only occurs on live server that this happens.
What I have tried:
php artisan cache:clear
php artisan route:cache
php artisan config:clear
php artisan view:clear
composer update
composer dump-autoload
create fresh installation copy fresh one into old version and dont overwrite
changed cache from file to database
confirmed `/public/index.php` is correct
SESSION_LIFETIME = 120
SESSION_DOMAIN set to domain
generated new app key
checked file permissions
Session token changes:
As the snippets show my session token keeps changing but does not update in the database.
Update
Before the Laravel redirects the auth check passes but is not yet saved, after redirect session token changes and auth check fails. So from what I can tell something is causing my session token to continuously change after redirects.
My problem was fixed by assigning false value to: SESSION_SECURE_COOKIE in config/session.php:
'secure' => env('SESSION_SECURE_COOKIE', false),

Resources