【问题标题】:blade template loading in public directory在公共目录中加载刀片模板
【发布时间】:2014-02-02 14:10:50
【问题描述】:

我对 laravel 完全陌生,刚刚用它开始了一个新的应用程序。我正在尝试做一个简单的 hello world 项目,然后我用 .blade.php 扩展创建了一个模板,我得到了以下错误

[Tue Jan 14 14:22:50 2014] PHP Fatal error:  require_once(): Failed opening required '/home/ramza/apps/php/testsite/bootstrap/../public/index.blade.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ramza/apps/php/testsite/server.php on line 19

我的控制器代码如下

class GamesController extends BaseController {

    public function index()
    {
            // Show a listing of games.
            return View::make('games.index');
    }
}

我的 index.blade.php 文件是空的,里面只有 hello world,看起来它正试图将它加载到公共目录中。

我试图把这个文件放在公共目录中,它工作得很好

但在 app/views/games/index.blade.php 内部发生了错误。任何帮助。谢谢。

更新

app/config/view.php

<?php

return array(

    /*
    |--------------------------------------------------------------------------
    | View Storage Paths
    |--------------------------------------------------------------------------
    |
    | Most templating systems load templates from disk. Here you may specify
    | an array of paths that should be checked for your views. Of course
    | the usual Laravel view path has already been registered for you.
    |
    */

    'paths' => array(__DIR__.'/../views'),

    /*
    |--------------------------------------------------------------------------
    | Pagination View
    |--------------------------------------------------------------------------
    |
    | This view will be used to render the pagination link output, and can
    | be easily customized here to show any view you like. A clean view
    | compatible with Twitter's Bootstrap is given to you by default.
    |
    */

    'pagination' => 'pagination::slider-3',

);

我的路线文件

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::get('/', 'GamesController@index');

【问题讨论】:

  • 这确实很奇怪。可以分享app/config/view.php的内容吗?该文件准确显示了 View 引擎应该在哪些文件夹中查找模板。
  • 更新了它。我想知道我做错了什么
  • 它在我的游戏文件夹中的视图文件夹中并且它是空的
  • 你用的是什么网址? /公共/游戏?
  • @MrShibby 更新我的路线文件

标签: php laravel laravel-4 blade


【解决方案1】:

您确定您的网络服务器将 /public 目录作为 webroot 指向吗?

【讨论】:

  • 我认为问题出在字符编码上。切换到 utf-8,效果很好。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-11
  • 2020-08-22
  • 2019-04-03
  • 2021-01-23
  • 2019-09-23
  • 2021-11-27
  • 2016-10-02
相关资源
最近更新 更多