diff --git a/src/Illuminate/View/Compilers/Compiler.php b/src/Illuminate/View/Compilers/Compiler.php index 2a943e0f6309..30233884e9eb 100755 --- a/src/Illuminate/View/Compilers/Compiler.php +++ b/src/Illuminate/View/Compilers/Compiler.php @@ -3,34 +3,43 @@ namespace Illuminate\View\Compilers; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Str; use InvalidArgumentException; abstract class Compiler { /** - * The Filesystem instance. + * The filesystem instance. * * @var \Illuminate\Filesystem\Filesystem */ protected $files; /** - * Get the cache path for the compiled views. + * The cache path for the compiled views. * * @var string */ protected $cachePath; + /** + * The base path that should be removed from paths before hashing. + * + * @var string + */ + protected $basePath; + /** * Create a new compiler instance. * * @param \Illuminate\Filesystem\Filesystem $files * @param string $cachePath + * @param string $basePath * @return void * * @throws \InvalidArgumentException */ - public function __construct(Filesystem $files, $cachePath) + public function __construct(Filesystem $files, $cachePath, $basePath = '') { if (! $cachePath) { throw new InvalidArgumentException('Please provide a valid cache path.'); @@ -38,6 +47,7 @@ public function __construct(Filesystem $files, $cachePath) $this->files = $files; $this->cachePath = $cachePath; + $this->basePath = $basePath; } /** @@ -48,7 +58,7 @@ public function __construct(Filesystem $files, $cachePath) */ public function getCompiledPath($path) { - return $this->cachePath.'/'.sha1($path).'.php'; + return $this->cachePath.'/'.sha1(Str::after($path, $this->basePath)).'.php'; } /** diff --git a/src/Illuminate/View/ViewServiceProvider.php b/src/Illuminate/View/ViewServiceProvider.php index 7eb731f53cfb..9baeb2c83777 100755 --- a/src/Illuminate/View/ViewServiceProvider.php +++ b/src/Illuminate/View/ViewServiceProvider.php @@ -85,7 +85,11 @@ public function registerViewFinder() public function registerBladeCompiler() { $this->app->singleton('blade.compiler', function ($app) { - return tap(new BladeCompiler($app['files'], $app['config']['view.compiled']), function ($blade) { + return tap(new BladeCompiler( + $app['files'], + $app['config']['view.compiled'], + $app['config']->get('view.relative_hash', false) ? $app->basePath() : '', + ), function ($blade) { $blade->component('dynamic-component', DynamicComponent::class); }); });