0

我试图理解 Laravel 4:

\controllers\catalogs.php

class Catalogs_Controller extends BaseController {
  public function get_index(){
    return View::make('catalogs')->with('title', 'Catalog - Home');
  }
}

路由.php

 Route::get('/', array('as'=>'home', 'uses'=>'catalogs@index'));

\views\layouts\default.blade.php

<!DOCTYPE html>
<html>
<head>
<title>{{ $title }}</title>
.....
</html>

\view\catalogs\index.blade.php

 @extends('layouts.default')
 @section('content')
Home Page
 @endsection

但我有一个错误:“类目录不存在”。问题可能出在哪里?

4

3 回答 3

1

基本上一切都是错误的,包括文件名。以下解决方案

// app/controllers/CatalogsController.php

class CatalogsController extends BaseController {
  public function get_index(){
    return View::make('catalogs/index')->with('title', 'Catalog - Home');
  }
}

// app/routes.php
Route::get('/', array('as'=>'home', 'uses'=>'CatalogsController@get_index'));


// app/views/layouts/default.blade.php

<!DOCTYPE html>
<html>
<head>
<title>{{ $title }}</title>
.....
</html>


// app/view/catalogs/index.blade.php

@extends('layouts.default')

@section('content')
    Home Page
@endsection

现在你必须运行命令composer dump-autoload

看到这个: http: //laravel.com/docs/quick

于 2013-10-12T16:47:44.053 回答
0

我对Laravel不是很熟悉,但我的猜测是类和文件名之间的连接是区分大小写的,所以尝试改变

\controllers\catalogs.php

\controllers\Catalogs.php
于 2013-10-12T14:22:18.950 回答
0

我也不熟悉劳拉,但我认为你的问题在第 3 行return View::make('catalogs')->with('title', 'Catalog - Home');

尝试使用return View::make('Catalogs')->with('title', 'Catalog - Home');

干杯...

于 2013-10-12T14:25:54.260 回答