for example there is a blade file at “resources/views/home.blade” so we want to compile the file into plain php file at location “root/public”, is there any artisan command or anything to do the task?
Advertisement
Answer
You can use the BladeCompiler directly:
<?php /** @var IlluminateViewCompilersBladeCompiler */ $compiler = app('blade.compiler'); $srcPath = resource_path('views/home.blade.php'); $targetPath = public_path('home.php'); $compiled = $compiler->compileString(file_get_contents($srcPath)); file_put_contents($targetPath, $compiled);