/** * Compile views. * * @param array $paths * @param string $storagePath * @return $this */ public function compileViews(array $paths, $storagePath) { $this->makeDestination($storagePath); $compiler = new BladeCompiler($this->files, $storagePath); foreach ($paths as $path) { $files = $this->files->glob(realpath($path) . '/{,**/}*.php', GLOB_BRACE); foreach ($files as $file) { if (!Str::endsWith(strtolower($file), '.blade.php')) { continue; } $compiler->setPath($file); $contents = $this->parseToken($this->files->get($file)); $contents = $compiler->compileString($contents); $compiledPath = $compiler->getCompiledPath($compiler->getPath()); $this->files->put($compiledPath . '.php', $contents); } } return $this; }
public function handle() { $this->info('start view compiler'); $targetDir = storage_path(config('trans.view_store_path')); if (!file_exists($targetDir)) { $this->createDirectory($targetDir); $this->comment('created directory ' . $targetDir); } $path = base_path(config('trans.view_blade_path')); $fs = new Filesystem($path); $files = $fs->allFiles(realpath($path)); $compiler = new BladeCompiler($fs, $targetDir); foreach ($files as $file) { $filePath = $file->getRealPath(); $this->comment('compile view: ' . $filePath); $compiler->setPath($filePath); $contents = $compiler->compileString($fs->get($filePath)); $compiledPath = $compiler->getCompiledPath($compiler->getPath()); $fs->put($compiledPath . '.php', $contents); } }
/** * Get the path currently being compiled. * * @return string * @static */ public static function getPath() { return \Illuminate\View\Compilers\BladeCompiler::getPath(); }