Here is my @rinclude statement, use it to include view files under the directory of current compiled view file or sub directories of it , work fine with Laravel 4.2
Blade::extend(function($view, $compiler)
{
$viewBasePath = Config::get('view.paths')[0];
$curCompiledFilePath = $compiler->getPath();
$paths = explode('/', substr($curCompiledFilePath, strlen($viewBasePath)), -1);
$basePath = '';
foreach($paths as $path) {
$basePath .= $path . '.';
}
$basePath = trim($basePath, '.');
$basePath = "'$basePath.'.";
$pattern = $compiler->createMatcher('rinclude');
return preg_replace($pattern, "<?php echo \$__env->make($basePath$2, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>", $view);
});
With this directory structure, inside index.blade.php, we can use @rinclude('foo') or @rinclude('dir1.foo1')
-/app/views/my-base-view
└── index.blade.php
└── foo.blade.php
└── /dir1
└── foo1.blade.php