How to recompile Laravel's Controller - php

I have a Laravel app running behind an Apache2/Ubuntu-16.04. I have to change a little code line in my controllers ( .i.e. a typo mistake in
laravel_project/app/Http/Controller/MyController.php). But when I reload the webpage using the browser, it still doesn't update with my fixed version. I tried some cleanup commands:
php artisan config:cache
php artisan route:cache
php artisan list
php artisan clear-compiled
and also restart apache2 but it still doesn't work. Can you please help me. Thanks.

I had the same issue, its was because of routes cache
I resolved it by:
php artisan route:clear

Related

Accidentally ran php artisan clear - compiled services and packages files removed [duplicate]

This question already has answers here:
Laravel - What does php artisan view:clear do?
(1 answer)
In Laravel, what is meant by the term "clear compiled class"
(1 answer)
Difference between "php artisan config:cache" and "php artisan cache:clear" in Laravel
(2 answers)
Closed 12 months ago.
Just as I was getting ready to run:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
...for debugging purposes, I ended up running php artisan clear instead. I got back the following output:
Compiled services and packages files removed!
What have I just done and how do I undo it? My application still seems to work fine, but if things are broken I'd rather roll things back now rather than get further down the line before I eventually realise that they are. If things aren't broken, I'd still like to know what I just did.
A preliminary answer before someone who can do more than read through the help commands comes along:
Although:
php artisan clear
...isn't listed in artisan's documentation at all (or at least not in php artisan list), based on its output it seems to be an alias of:
php artisan clear-compiled
This seems to be confirmed by php artisan help clear-compiled:
Description:
Remove the compiled class file
Usage:
clear-compiled
Although that help command doesn't really clear up much, like what exactly compiled class files are or what relation they have to any of the other clear commands, I'm guessing the command does something similar to:
php artisan view:clear
...which does the following according to its own help command:
Description:
Clear all compiled view files
Usage:
view:clear
Based on the above, I can only guess that running php artisan clear is about as harmless as running php artisan view:clear, in that both are designed to clear away compiled files that, when cleared, are simply recompiled again on the next build.
How exactly php artisan clear differs from php artisan view:clear and why it needs its own separate command and a much more memorable alias than any of the other clear commands is still... unclear.
BONUS
To anyone else that arrived here because they find themselves constantly running some variation of the above commands for debugging and troubleshooting, I just learnt about the php artisan optimize:clear command, which runs all of these commands at once:
php artisan view:clear
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan clear
and returns the following output:
Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!

Laravel Error: Erroneous data format for unserializing 'Symfony\Component\Routing\CompiledRoute'

I ran these commands: php artisan route:clear and php artisan cache:clear. Then I got this error on whatever I want to do: running artisan command, running composer command, rendering any view that worked just fine. Can not do anything at all.
I searched for the problem and seems that this has happened because of changing the php version from 7.4 to 7.3. Yes, I have done this about 10 days ago, now I am not able to resolve it and make it work again. I use Nginx and tried anything suggested on the web, but can not solve the problem. I had apache and could not solve it, I removed apache completely and installed nginx. Now any other project works fine with nginx, but only this project which I ran php artisan route:clear and php artisan cache:clear commands, has problem and displays this error on every action I want to do: Erroneous data format for unserializing 'Symfony\Component\Routing\CompiledRoute'.
How can I solve this problem?
I got this same error when I was experimenting with Laravel Envoy. I think I pulled the 7.0 version of Envoy onto of my Laravel 5.8 version app. The way to solve it for me was to clear out the bootstrap/cache directory of the app with the command rm -fr bootstrap/cache/* from the root Laravel directory. Once I did that I was able to use my application normally and all the artisan commands began working.

Laravel view [auth.login] not found on server

I have a problem with my project laravel 5.7. I have developed it locally and all is well but once sent to my server online I have this error: view [auth.login] not found.
Ran into the same problem. I noticed three things;
A message while booting homestead about virtualbox guest-tools being out of sync between host and guest. There could be a problem with paths. I fixed that issue with the help of this here
The Laravel view [auth.login] not found on server page displayed the path of the host machine and not of the vagrant-guest.
bootstrap/cache/config.php also displayed paths from the host and not the guest.
Renaming/deleting (or artisan cache:clear) the config.php only gave errors (Laravel Error “Unable to load the ”app“ configuration file”).
I fixed the issue by correcting the paths in config.php manually to the correct path in vagrant.
Run following commands on your server.
it might solve your problem.
php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan route:cache
php artisan optimize
or
composer dump-autoload -o
if you are in develop mode you can run:
php artisan config:clear
or if you are in product mode you can run:
php artisan config:cache
notice: when you use second, config clear and cache again and you force to repeat command for other changes.

php artisan serve get cached or does not react while updating code in Laravel 5.5. After a restart, it works again each time

My IDE is phpstorm and running on WAMP Server. While coding, it does not show the expected response, always returns the previously requested response (In postman). Each time, I need to close 'php artisan serve' with CTRL+C and then run again to get the expected response.
I tried changing IDE, changing port but it does not work. Of course, I tired to save manually ( CTRL+S) but the problem persists.
I also tried the following commands:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
composer dump
But the problem still persists.
The issue might be the composer command. Please, have a look on my setup in the Makefile:
run:
php artisan config:cache
php artisan config:clear
php artisan cache:clear
composer.phar dump-autoload -o
php artisan serve
And it's ready to go with a Laravel's "clean build".
Can you try with a diferent request tool, like doing a GET on your browser?
Or just create a new endpoint to test that. This way you make sure that changes are being saved.
I recommend you make tests to see if:
the problem is on your postman (a cache maybe?);
the problem is that your code isn't being saved;
the problem is on your local server (a persistent cache?);
My tip is: Try to eliminate the possible causes and you should achieve an answer.
Let´s try to make sure about above items and if them are ok, we check possible another ones.

Cannot delete Laravel Application cache from deployment script

I am trying to setup a deployment script for my Laravel 5 app to use with CodeShip but I am having issues with clearing the application cache during the deployment.
By running
php artisan cache:clear
it does not give any errors and says the cache has been cleared but it hasnt, then when I ssh into the box and try to delete the cache manually it says permission is denied, so I need to use sudo which is not ideal as Id like to have this all to run without my intervention. I know this is a permissions issue but I cannot work out a way around it.
Is there a way I can do this or maybe a slightly different method?
You shouldn't delete cache manually. Try to run these commands:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan config:clear
composer dump-autoload
Try php artisan config:cache
This will do it all for you.
Hope this helps!

Categories