Always need to optmize when i changed somthing in web.php laravel8 - laravel

Every time when I changed something in web.php file in the laravel 8 project I need to run
PHP artisan optimize
can anyone tell me what is the solution by default? I don't need to optimize every time or every time I open that project.

I found a solution. If you don't need to optimize every time in your development environment just write this command
PHP artisan route:clear
then you don't face that issues.
If you want to go back to your previous state like you should need to optimize or just upload your app in live then just command this.
PHP artisan route:cache
I hope this will help you 💻👨‍💻

Related

Laravel View Cache keeps interrupting

I'm doing my thing in my normal view blade file, but when i edit my code and save it, it doesn't update. I found out that the view cache stored in /storage/framework/views keeps interrupting. Whatever i change in my normal blade file doesn't change the output. It only reacts to my cache, which doesn't update. I've already cleared my cache, but it doesn't work, it keeps coming back. Is there any way i can ignore or delete the view cache?
php artisan clear
php artisan route:clear
php artisan cache:clear
Run the above codes in your terminal it should do the trick, if it persists try reloading your editor.
Thanks for trying to help! The issue is gone now. Somehow i had 2 of the same blade files and i edited the wrong one, which is really weird. I don't know how i had 2 of the same blade files. I deleted one and now it works fine. Really weird though.
php artisan cache:clear
Try this.

Laravel 5.1 - Some pages are not found on production serveur - "Page you are looking for could not be found"

I have a problem with some "routes" in my old Laravel 5.1.46 project.
When I try to access to some routes, like admin/exercices/creer or admin/exercices/1928, I have this: "Sorry, the page you are looking for could not be found.".
I can access to thoses pages when I work on the test or local serveur. But not on the production serveur.
Other routes like admin/missions/creer are working properly.
I tried php artisan route:list to compare the routes on each serveur: it's the same everywhere.
I also tried php artisan route:cache and php artisan route:clear. Nothing changed.
I can remember we changed the routes path (for example: "admin/modules/creer" became "admin/exercices/creer"). I think we did it manually, directly in the routes.php file. But it waas a long time ago and since then, it already worked properly. So I don't think it comes from that, but Idk.
I'm also not good at sysadmin, so maybe it's more about the config of the server than code and laravel... In this case, any idea here does it come from? I have no clue, and I might need help.
Thanks a lot for reading! And let me know if you have even a tiny idea!

How tu run laravel php artisan serve with fresh cache

I am using php artisan serve to start my mini app on my remote server.
Once I update code, I am using ftp to upload new code.
After upload I am stop and restart (php artisan serve), but view are still "old", there is something like cache, how can I clear it?
try php artisan optimize:clear
If You want to clear file cache then you can use clearstatcache().If you are checking a file several times in a script, to avoid caching & to get correct results, use the clearstatcache() function. see more here
But if you want clear browser cache then you can delete it using headers.
see more here

How to solve Page Expired Due to Inactivity in Laravel

I am a PHP developer using Laravel framework and currently i have an application which is in production. The users are being forced to log in every time even if they just logged in in less than 2 mins and get the message The Page expired due to inactivity. This is causing me headache as the application is doing just fine in the development environment in my my local machine.
I have search for solutions but non is working for me including generating keys using php artisan command, clear cache,config,route and view, i have also tried to increase the number of minuted for the session to expire to up to 8 hours but the same issue still occurring.
I am actually stranded and don't know what to do else,please i need a help to get out of this.
Thanks in advance
Option 1:
Set session lifetime in .env file to SESSION_LIFETIME=120 (2 hours)
Option 2:
Try all of them.
composer dump-autoload
php artisan optimize
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
Option 3: if these have no effect add remember me checkbox on login form who save session token for long time

Blade view not reflecting changes

I am developing a Laravel(5.2.29) project in Windows environment and testing it on Chrome browser.
I have made some changes on a Blade file using atom text editor and then refreshed my page and noticed that suddenly it has stopped reflecting the changes (it's loading the old Blade file).
I've tried the following:
Restarted the browser
Clearing browser cache
Running php artisan cache:clear
Running composer dumpautoload
Deleting the Blade file (and got a view not found error). Then created a new Blade file with the same name, with no content and refreshed the page.
No matter what, the code displayed on the browser is always the same (old) version and not the content of the Blade file.
How can I solve this issue?
In order to avoid the parsing of Blade files on each reload, Laravel caches the views after Blade is processed. I've experienced some situations where the source (view file) is updated but the cache file is not "reloaded". In these cases, all you need to do is to delete the cached views and reload the page.
The cached view files are stored in storage/framework/views.
Run this command from terminal
php artisan view:clear
If you use PhpStorm, uncheck Preserve files timestamps deployment option:
https://stackoverflow.com/a/42534996/2453148
php artisan cache:clear
php artisan route:cache
php artisan config:clear
php artisan view:clear
rm -rf bootstrap/cache/*/*
Delete Cache/OPcache from PHP (fpm) of your Nginx/Apache server.
Clear the cache and clear the cached blade files:
php artisan cache:clear
php artisan config:clear
php artisan view:clear
You can also check if opcache enabled, in that case you need to clear your opcache cache.
Like Can Gelis mentionned in a comment. For me the solution was to reload PHP FPM
service php7.2-fpm reload
Alternatively if other suggested methods did not work, you can rename your files to different names. Refresh their corresponding web pages to start using new file name reference. Then you can rename the files back to your preferred names after the new pages to reflect their changes.
I have cleared all cashs and uploaded folders but didnt see changes.
Thus, if you have placed the project on a public hosting and don't have access to console then try to set deployment via your IDE (mine is phpstorm, e.g.)and set it to autoload mode. Then you'll get it working by changing something in the problem blade and by pressing cntrl+s(save) shortcut.
clear cache didn't work for me, but I just edited the file and saved it again, and it works!
None of these solutions have resolved this issue for me. Tried all php artisan options and the php code is not updating.
Only solution i've found is restarting the docker container that the code is running inside.
In case you try everything and nothing works. I recommend that you simply create a view under another name and the problem will be fixed
Example:
welcome.blade.php
change to
newview.blade.php
copy and paste code to new view
In controller just point to new view:
return view('newview');

Resources