Fatal error - Can't locate blade templates

This is possibly a Windows compatibility issue. This occurs on activating the theme (no changes made).
It says it can’t locate the template page.blade.php, but the file is there.

<b>Fatal error</b>: Uncaught exception 'InvalidArgumentException' with message 'View [C:.wamp.www.project.web.app.themes.project.templates.page] not found.' in C:\wamp\www\project\web\app\themes\project\vendor\illuminate\view\FileViewFinder.php:137 Stack trace: \#0 C:\wamp\www\project\web\app\themes\project\vendor\illuminate\view\FileViewFinder.php(79): Illuminate\View\FileViewFinder-&gt;findInPaths('C:.wamp.www.pro...', Array) \#1 C:\wamp\www\project\web\app\themes\project\vendor\illuminate\view\Factory.php(174): Illuminate\View\FileViewFinder-&gt;find('C:.wamp.www.pro...') \#2 C:\wamp\www\project\web\app\themes\project\src\lib\Sage\Template\BladeProvider.php(39): Illuminate\View\Factory-&gt;make('C:.wamp.www.pro...', Array, Array) \#3 C:\wamp\www\project\web\app\themes\project\src\lib\Sage\Template\BladeProvider.php(50): Roots\Sage\Template\BladeProvider-&gt;make('C:\\wamp\\www\\inc...', Array, Array) \#4 C:\wamp\www\project\web\app\themes\i in <b>C:\wamp\www\project\web\app\themes\project\vendor\illuminate\view\FileViewFinder.php</b> on line <b>137</b><br />

Any ideas how I can fix this?

1 Like

I just pushed some updates to the master branch that might resolve this issue. Can you test it and let us know if it works?

Same error unfortunately. The line numbers have changed though

<br /> <b>Fatal error</b>: Uncaught exception 'InvalidArgumentException' with message 'View [C:.wamp.www.project.web.app.themes.theme..page] not found.' in C:\wamp\www\project\web\app\themes\theme\vendor\illuminate\view\FileViewFinder.php:137 Stack trace: \#0 C:\wamp\www\project\web\app\themes\theme\vendor\illuminate\view\FileViewFinder.php(79): Illuminate\View\FileViewFinder-&gt;findInPaths('C:.wamp.www.the...', Array) \#1 C:\wamp\www\project\web\app\themes\theme\vendor\illuminate\view\Factory.php(174): Illuminate\View\FileViewFinder-&gt;find('C:.wamp.www.the...') \#2 C:\wamp\www\project\web\app\themes\theme\src\lib\Sage\Template\BladeProvider.php(38): Illuminate\View\Factory-&gt;make('C:.wamp.www.the...', Array, Array) \#3 C:\wamp\www\project\web\app\themes\theme\src\lib\Sage\Template\BladeProvider.php(49): Roots\Sage\Template\BladeProvider-&gt;make('C:\\wamp\\www\\inc...', Array, Array) \#4 C:\wamp\www\project\web\app\themes\theme\src\helpers.php(28): Roots\Sage\Template\BladeProvider-&gt;r in <b>C:\wamp\www\project\web\app\themes\theme\vendor\illuminate\view\FileViewFinder.php</b> on line <b>137</b><br />

I’m also running into this error under slightly different circumstances (macOS, loading a vanilla PHP template from within the Give plugin):

Fatal error: Uncaught InvalidArgumentException: View [Users.ned.Sites.sagetest.wp-content.plugins.give...single-give-form] not found. in /Users/ned/Sites/sagetest/wp-content/themes/sage/vendor/illuminate/view/FileViewFinder.php:137
Stack trace: #0 /Users/ned/Sites/sagetest/wp-content/themes/sage/vendor/illuminate/view/FileViewFinder.php(79): Illuminate\View\FileViewFinder->findInPaths('Users.ned.Sites...', Array)
#1 /Users/ned/Sites/sagetest/wp-content/themes/sage/vendor/illuminate/view/Factory.php(174): Illuminate\View\FileViewFinder->find('Users.ned.Sites...')
#2 /Users/ned/Sites/sagetest/wp-content/themes/sage/src/lib/Sage/Template/BladeProvider.php(38): Illuminate\View\Factory->make('Users.ned.Sites...', Array, Array)
#3 /Users/ned/Sites/sagetest/wp-content/themes/sage/src/lib/Sage/Template/BladeProvider.php(49): Roots\Sage\Template\BladeProvider->make('/Users/ned/Site...', Array, Array)
#4 /Users/ned/Sites/sagetest/wp-content/themes/sage/src/helpers.php(28): Roots\Sage\Template\BladeProvider->render('/Users/ned/Site...', Array)
#5 in /Users/ned/Sites/sagetest/wp-content/themes/sage/vendor/illuminate/view/FileViewFinder.php on line 137

FWIW, I used composer create-project with Sage dev-master a couple hours ago so what I’m working with includes the most recent commits.

@ned Confirmed this is a bug with our Blade implementation which is causing incompatibility with the Give plugin - hope to have this fixed soon. Thanks for reporting

@simmbiote9999 Still trying to reproduce this. What version of PHP are you on?

1 Like

I’m on 5.6.2

I’m not certain, but I think the problem is maybe the findInPath function. I added var_dump to see where it’s looking - it doesn’t reach the /templates/ folder.

protected function findInPaths($name, $paths) { foreach ((array) $paths as $path) { foreach ($this->getPossibleViewFiles($name) as $file) { $file = str_replace('//','/',$file); var_dump($file); if ($this->files->exists($viewPath = $path.'/'. $file)) { return $viewPath; } } } throw new InvalidArgumentException("View [$name] not found."); }

Here is the var_dump output

string(64) "C:/wamp/www/project-name/web/app/themes/theme/page.blade.php" string(58) "C:/wamp/www/project-name/web/app/themes/theme/page.php" string(31) "C:/wamp/www/project.blade.php" string(25) "C:/wamp/www/project.php"

I have the same issue and I think I have managed to localize the problem a bit.

In the file: src/helpers.php:26 there is a function named “template($file, $data = [])”.
When I logged out the value of the variable $file it contained the whole path:
“C:\Users\daniel.hansson\Development\My-project-folder/wp-content/themes/sample-theme/templates/index.blade.php”

So I tried to override it like this and it works better:

function template($file, $data = [])
{
    $file = "templates/index.blade.php";
    return sage('blade')->render($file, $data);
}

I haven’t yet localized where the whole path is set or how that part works, but I thought I post this here to point you guys in the right direction maybe.

1 Like

Just confirming that I’ve run into this issue on certain server envs but not all. @danielhansson’s solution fixed the issue on all.

Jumped the gun. while @danielhansson’s snippet does fix the fatal error, it (obviously) causes every page to use the index.blade.php template

This has been fixed in https://github.com/roots/sage/commit/50a6f8ea6006f9b29f84ef11c0e68e9f38e09db7

My issue resulted from using WP 4.6. The dev branch of Sage uses some functions introduced in 4.7 for the blade template routing.