本文整理汇总了PHP中Illuminate\View\Compilers\BladeCompiler::compile方法的典型用法代码示例。如果您正苦于以下问题:PHP BladeCompiler::compile方法的具体用法?PHP BladeCompiler::compile怎么用?PHP BladeCompiler::compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\View\Compilers\BladeCompiler
的用法示例。
在下文中一共展示了BladeCompiler::compile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
// Set directories
$inputPath = base_path('resources/views');
$outputPath = storage_path('gettext');
// Create $outputPath or empty it if already exists
if (File::isDirectory($outputPath)) {
File::cleanDirectory($outputPath);
} else {
File::makeDirectory($outputPath);
}
// Configure BladeCompiler to use our own custom storage subfolder
$compiler = new BladeCompiler(new Filesystem(), $outputPath);
$compiled = 0;
// Get all view files
$allFiles = File::allFiles($inputPath);
foreach ($allFiles as $f) {
// Skip not blade templates
$file = $f->getPathName();
if ('.blade.php' !== substr($file, -10)) {
continue;
}
// Compile the view
$compiler->compile($file);
$compiled++;
// Rename to human friendly
$human = str_replace(DIRECTORY_SEPARATOR, '-', ltrim($f->getRelativePathname(), DIRECTORY_SEPARATOR));
File::move($outputPath . DIRECTORY_SEPARATOR . sha1($file) . '.php', $outputPath . DIRECTORY_SEPARATOR . $human);
}
if ($compiled) {
$this->info("{$compiled} files compiled.");
} else {
$this->error('No .blade.php files found in ' . $inputPath);
}
}
示例2: compile
public function compile($path = null)
{
if (str_contains($path, 'vendor/')) {
preg_match('~/vendor/\\w+/([^/]+)~', $path, $matches);
preg_match('~/([^/]+)$~', $path, $matches2);
$name = $matches[1] . '::' . $matches2[1];
} elseif (str_contains($path, 'resources/views/')) {
$name = explode('resources/views/', $path)[1];
} else {
$name = explode('/views/', $path)[1];
}
$record = CoverageRecord::RecordEntry('View', '', $name);
parent::compile($path);
}
示例3: fire
public function fire()
{
$app = app();
$cache = $app['path.storage'] . '/views';
$compiler = new BladeCompiler($app['files'], $cache);
// delete compiled
$files = new \GlobIterator(TEMP_PATH . '/views/*');
foreach ($files as $file) {
if ($file->getExtension() !== '.gitignore') {
unlink($file);
}
}
// generate new ones
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(VIEWS_PATH), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file) {
if ($file->getExtension() === 'blade') {
$compiler->compile($file->getPathname());
}
}
}
示例4: compile
/**
* Compile the view at the given path.
*
* @param string $path
* @return void
* @static
*/
public static function compile($path = null)
{
\Illuminate\View\Compilers\BladeCompiler::compile($path);
}