How to refresh laravel template and disabe caching ?

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

How to refresh laravel template and disabe caching ?

Post by gautamz07 »

Hey guys i am just playing around with laravel and bascally have the following view:

Code: Select all

<!doctype html>
<html class="no-js" lang="">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>Title</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="apple-touch-icon" href="apple-touch-icon.png">
        <!-- Place favicon.ico in the root directory -->
        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/style.css">
        <style>
            h1 {
                color: #727272;
                font: bold 2em/1.4 verdana;
            }
            .nav-items {
                padding: 0;
                margin: 0;
                list-style-type: none;
            }
            
            .nav-items li {
                display: inline-block;
                margin-right: 10px;
                padding: 1em 1.5em;
                border: 1px solid #ccc;
                background-color: #eee;
                -webkit-box-shadow: 0 0 2px rgba(0,0,0,.2);
                box-shadow: 0 0 2px rgba(0,0,0,.2);
                color: #727272;
                text-shadow: 0 0 1px rgba(255,255,255,1);
            }
        </style>
   
    </head>
    <body>
        <!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
       
           
           <ul class="nav-items">
               
               @foreach($categories as $category)

                   <li>
                       Category id is {{ $category-> id }} 
                   </li> 

               @endforeach  

            </ul>
                  
                                       
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.3.min.js"><\/script>')</script>
        
    </body>
</html>
Now suppose i change the below code:

Code: Select all

<ul class="nav-items">
               
               @foreach($categories as $category)

                   <li>
                       Category id is {{ $category-> id }} 
                   </li> 

               @endforeach  

 </ul>

To the following:

Code: Select all

<ul class="nav-items">
               
               @foreach($categories as $category)

                   <li>
                       Product id is {{ $category-> id }} // I have only changed the word "Categories" to "Products"
                   </li> 

               @endforeach  

 </ul>
I have only changed the word Categories to Products , but when my view loads in the browser i still see the word "Category" instead of "Products" .

The only current solution i have is to change the view file name and than change the view name in the controller, which is quite inconvenient ! , Is there another solution to this problem ? Is this something to do with caching ?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to refresh laravel template and disabe caching ?

Post by Celauran »

Refreshing your browser should be enough. I generally develop in a separate browser that always runs in private mode so as not to have to deal with caching, cookies, etc. Finally, you can run "artisan cache:clear"
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: How to refresh laravel template and disabe caching ?

Post by gautamz07 »

Will try that thanks :)
Swhite
Forum Newbie
Posts: 7
Joined: Thu Feb 04, 2016 1:19 am

Re: How to refresh laravel template and disabe caching ?

Post by Swhite »

Hey, try this code to disable caching:

If you run php artisan list then you can find all the commands available for artisan, anyways, there is a command to clear the cache and it's
php artisan cache:clear
Also, you can use
foreach (Cache::getMemory() as $cacheKey => $cacheValue)
{

Cache::forget($cacheKey);
}
Update:
Cache::flush();
Post Reply