Laravel View无法调用子文件夹视图

时间:2014-06-09 00:50:21

标签: view laravel-4 blade

我尝试从子文件夹调用视图时出错。 首先,这件事有效

Route::get('/', function() { return View::make('sample'); });

但是当我尝试在像这样的文件夹中调用它时

Route::get('/', function() { return View::make('pages.sample'); });

它给我一个这样的错误:

[2014-06-08 16:00:43] production.ERROR: exception 'InvalidArgumentException' with message 'View [pages.sample] not found.' in /var/www/bootstrap/compiled.php:9076 Stack trace:
0 /var/www/bootstrap/compiled.php(9049): Illuminate\View\FileViewFinder->findInPaths('pages.sample', Array)
1 /var/www/vendor/laravel/framework/src/Illuminate/View/Factory.php(124): Illuminate\View\FileViewFinder->find('pages.sample')
2 /var/www/bootstrap/compiled.php(3225): Illuminate\View\Factory->make('pages.sample')
3 /var/www/app/routes.php(16): Illuminate\Support\Facades\Facade::__callStatic('make', Array)
4 /var/www/app/routes.php(16): Illuminate\Support\Facades\View::make('pages.sample')
5 [internal function]: {closure}()
6 /var/www/bootstrap/compiled.php(5098): call_user_func_array(Object(Closure), Array)
7 /var/www/bootstrap/compiled.php(4795): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
8 /var/www/bootstrap/compiled.php(4783): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
9 /var/www/bootstrap/compiled.php(706): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
10 /var/www/bootstrap/compiled.php(687): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
11 /var/www/bootstrap/compiled.php(7425): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
12 /var/www/bootstrap/compiled.php(8031): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
13 /var/www/bootstrap/compiled.php(7978): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
14 /var/www/bootstrap/compiled.php(10747): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
15 /var/www/bootstrap/compiled.php(648): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
16 /var/www/public/index.php(49): Illuminate\Foundation\Application->run()
17 {main} [] []

我尝试重新安装所有东西,但似乎它不起作用。我错过了什么吗?谢谢!

1 个答案:

答案 0 :(得分:1)

我终于明白了。文件夹和文件不归“www-data”所有,这会导致此错误。这通常发生在使用LAMP时。我希望这有助于解决这类问题的任何人。任何人都想知道命令是什么:

sudo chgrp -R  www-data /var/www/app/views/*