loren.szendre's avatar

Cannot find layout file

Laravel 5.2/PHP7/Windows 10. I am going through the first 7 Laracasts -- and I am trying to use a layout file for the first time. It was easy -- just create my standard web page with 3 @yield directives. I placed this file (called layout.blade.php) in my resources\views directory. Then I created a page about.blade.php which has @extends('layout') plus some small markup for @section('header') and @section('content'). Both of these blade pages are in the root of the views directory. My routes file contains:

Route::get('about', function () { $devs = ['Bob', 'Bobby', 'Bubba']; return view('about', compact('devs')); });

But the problem is that I get this error:

file_get_contents(C:\W\Apache24\htdocs\cloud\public\build/rev-manifest.json): failed to open stream: No such file or directory (View: C:\W\Apache24\htdocs\cloud\resources\views\layout.blade.php) (View: C:\W\Apache24\htdocs\cloud\resources\views\layout.blade.php)

I have meticulously checked the path and the file names. There is no problem there. Laravel simply cannot see or use my layout.blade.php file.

Am I too cutting edge here with the latest Laravel and PHP? Has anyone else seen this?

0 likes
10 replies
RonB1985's avatar

I see no errors in your code whatsoever. Try to clear the cache and run the composer autoload to see if that helps:

composer dump-autoload

php artisan cache:clear

1 like
loren.szendre's avatar

Thanks for the quick response! I did what you said, but unfortunately I still get the same error:

No such file or directory (View: C:\W\Apache24\htdocs\cloud\resources\views\layout.blade.php)

But I know this file exists!

The contents of my layout page are simple: (brackets replaced for display purposes)

^!DOCTYPE html^ ^html lang="en"^ ^head^ ^meta charset="UTF-8"^ ^title>Document</title^

@yield('header') ^/head^ ^body^

@yield('content')

@yield('footer')

^/body^ ^/html^

PS: I dumped the supposed non-existent file (with full path) into Windows Explorer, and it opened right up. So the file really does exist.

RonB1985's avatar

Unfortunately, I haven't had this issue myself before. What I would do, is strip my code down, and make some test pages, like so:

Routes.php:

Route::get('test', function() { return view('test'); });

In my views directory, I would make a new file called "view.blade.php" with the following contents:

@extends('layout')

This is my test.blade.php file

@section('content')

@endsection

And I would make a view called "layout.blade.php" with the following contents:

This is my layout.blade.php file

@yield('content')

And then simply test it and see what happens. Usually it works for me and I know I done something wrong somewhere :P Hopefully someone else recognises the above error you're getting, at least from their own experience. ofcourse I know what the error means, but I have no idea where it is coming from. So a little troubleshooting might give some answers.

d3xt3r's avatar

Its not your view or layout file but you seem to be using elixir() function with out proper version control ??? Show your layout.blade file.

2 likes
loren.szendre's avatar

I did list my layout file above. Thank you for all answers! I removed all references to elixir that I had added while stepping through the tutorials.

I will start a new project, and create the simplest possible route, layout and view -- and I'll report back.

lindstrom's avatar

What @premsaurav said. You have something like <link href="{{ elixir(app.css) }}" and you aren't actually mixing the version in your gulpfile.js (mix.version). The error you are getting isn't referring to layout.blade.php, it's looking for public\build/rev-manifest.json.

See: https://laravel.com/docs/5.2/elixir#versioning-and-cache-busting

The quick fix is to reference your css/js directly. If you want to version it, use the link. Otherwise -- link href="/css/app.css" or for js src="app.js" (obv replace w/ the names of your css/js.

2 likes
loren.szendre's avatar

I had the elixir line commented out, but it was still wreaking havoc)) So I removed it altogether, and it works now. Thank you to all that helped. My knowledge of Laravel has gone up another notch because of this issue)

RonB1985's avatar

Apologies for having wasted your time, also my knowledge has gone up a notch :)

loren.szendre's avatar

You didn't waste my time -- I put your suggestion on a sticky note and I keep it around for future reference, or at least until I have done it enough times that I can throw away the note))

Please or to participate in this conversation.