I am updating view and refreshing the route which is rendering that particular view. But it loads previous view. After multiple refresh I get the latest updated view. Can you please explain me in detail how my view should not be cached and i should get updated view only.
In Laravel 4.2 you can't run the command php artisan cache:clear to remove the views. That's because they aren't cached, their compiled.
Laravel 5.1 and greater implemented the command php artisan view:clear to clear compiled views, but here is a custom command you can use in Laravel 4.2 to clear them:
https://gist.github.com/cjonstrup/8228165
Otherwise, just delete all the files in app/storage/views and views will be re-compiled.
I'd recommend to set debug to true, open your browser dev tools and check the option to don't cache pages when dev tools are opened and finally, give 777 permissions to you storage folder (I don't remember the name of the folder in Laravel 4.2) where compiled views are stored as sometimes the system can't write on that location.
I think it should be enough for you to get the view updated on refresh.
Related
I'm having a strange problem when updating a Blade view in a Laravel project hosted on a Linux CentOS server. The changes I make (deleting or commenting out a line of html) are not reflected on the webpage. I tried clearing the view cache with php artisan view:clear to no avail. When I go to /var/www/app/storage/framework/views and check the compiled php view the changes are there, but they still don't show up on the webpage. The old version of the view must still be stored somewhere, I just can't figure out where. Any help is much appreciated.
Edit: As an addendum, I also tried php artisan cache:clear as well as clearing the browser cache and neither worked.
Linux CentOS release 7.3.1611;
Apache 2.4.6;
PHP 7.1.7;
MySQL 5.5.52-MariaDB;
Laravel 5.3.31.
Run
php artian view:clear
OR for broad prospective, run
php artian optimize:clear // This is available for post Laravel 6 versions
If you are using chrome open dev tools, then settings and check disable cache
option
It works like a charm for me.
When I develop a Laravel application I used to clear cache after making any changes to routes\web.php or routes\api.php. Recently I was working on a project for a fellow and found out that the project does not need clearing cache every time I make a change in any of the files I have mentioned.
So I want to know what is the problem with the autoloader or what exactly is the general problem?
When you use commands like
php artisan optimize
php artisan route:cache
your route files(under routes/) are being parsed and cached. Now, next requests will be routed from cached routes, not from routes/*.php.
If you have used above commands, after making changes to route php files, you should re-cache them, or use
php artisan route:clear
to remove the cache. Then, next requests will be routed by routes/*php files.
We already have a Laravel web app hosted in the cloud (AWS EC2 instance). Let's say that changes will be required to be made, such as revising the (blade view) layout or adding new reports.
After I make the changes to the local controller, view and route files, do I simply copy them to the cloud host? Laravel keeps a cache of the blade view files. Will they be updated when the blade view files are updated? What other items do I need to do?
The views caches will be automatically regenerated, but you can force delete the cache if you want. php artisan cache:clear.
For routes, it's parsed from the file, so no worry there.
If you change config at some point, make sure to run php artisan config:clear.
If you touch the services and something is still not working, try php artisan clear-compiled. it will force the regen of the bootstrap.
The best way would be to use a source version control software like git and implement a pipeline on a service like GitLab.
I recently implemented one with this tutorial.
It exploits GitLab pipelines and Larvel's Envoy to automatically run tests and deploy your code that passed each stage you defined. It also allows you to rollback to previous versions at any given time.
For deploying PHP applications in any framework, you can use various tools. The most simple is PHP Deployer, and i recommend you to use it if you're not familiar with automatic deployment. You can set a sequence of commands which will be launched during deployment e.g.
git pull origin master
php artisan cache:clear
php artisan migrate
I am not able to edit my views from resources/view but rather i have to edit from storage/framework/views. Why is this happening with my project suddenly. Is there a way i can change this?
Laravel is caching your views try clearing views cache
php artisan view:clear
I have a Laravel 5.3 project which was created 5 months ago, today I made a duplicate from the project and I made some changes into the code.
When I edit the views in a blade.php file my project which I edited showed me the last project view, I made a new route in the new laravel project and in the routes works well, but still shows the last project view.
It's funny because the js files works pretty well, but the view doens't work. for example, I edit the profile.blade.php file and it shows the content from the last project, if I writte something new in the other view from the last project, it shows in the new project.
Any ideas?
Thanks in advance.
Your views/routes are compiled/cached.
The storage directory contains your compiled Blade templates, file
based sessions, file caches, and other files generated by the
framework.
The bootstrap directory contains files that bootstrap the framework
and configure autoloading. This directory also houses a cache
directory which contains framework generated files for performance
optimization such as the route and services cache files.
Run these commands
php artisan view:clear - Clear all compiled view
php artisan optimize --force - Optimize the framework for better performance
php artisan config:cache - Create a cache file for faster configuration loading
php artisan route:cache - Create a route cache file for faster route registration
Disable opcache from php.ini or use:
ini_set('opcache.enable', 0);