php - Why custom directive not reflecting changes in its code immediately -


i writing simple custom directive in laravel. whenever make changes in code of custom directive, not reflected in view until i

  • comment directive in view.
  • reload page
  • uncomment directive
  • reload page changes

custom directive code in global.php

blade::extend(function($value, $compiler) {     $pattern = $compiler->creatematcher('molvi');     return preg_replace($pattern, '$1<?php echo ucwords($2); ?>', $value); }); 

directive call in view

@molvi('haji') //this output 'haji' due ucwords($2)  //the ucwords() replaced strtolower() @molvi('haji') //this still output 'haji' 

i converting words uppercase. when lets want use strtolower() instead of ucwords(), have repeat above steps changes reflected.

update

i have tried clear cache various methods described in this thread still no success.

update

since no 1 answering question on stackoverflow, have posted on laravel github.

note: pasting answer given @lukasgeiter on github thread.

the problem compiled views cached , can't disable that. can clear files. either manually deleting in storage/framework/views or running command php artisan view:clear

not supported in laravel 4 or 5.0

this command not found in laravel 4 or 5.0. new command , introduced in larvel 5.1. here viewclearcommand code 5.1.

manually add support in laravel 4 or 5.0

you can manually add support in laravel 4 or 5.0.

register new command

the way achieve in previous versions register new command. aritsan development section helpful in regard.

final working code 4.2.1

i have tested following code on 4.2.1.

add new command file

app/commands/clearviewcommmand.php

<?php  use illuminate\console\command; use illuminate\filesystem\filesystem; use symfony\component\console\input\inputoption; use symfony\component\console\input\inputargument;  class clearviewcommand extends command { /**  * console command name.  *  * @var string  */ protected $name = 'view:clear';  /**  * console command description.  *  * @var string  */ protected $description = 'clear compiled view files';  protected $files; /**  * create new command instance.  *  * @return void  */ public function __construct(filesystem $files) {     parent::__construct();      $this->files = $files; }  /**  * execute console command.  *  * @return mixed  */ public function fire() {     //this path may different 5.0     $views = $this->files->glob(storage_path().'/views/*');     foreach ($views $view) {         $this->files->delete($view);     }     $this->info('compiled views cleared!'); }  } 

register new command

add following line in app/start/artisan.php

artisan::resolve('clearviewcommand'); 

cli

now can run command. after each update of code in custom directive can run command immediate changes in views.

php artisan view:clear 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -