2013-10-12 28 views
0

我想了解Laravel 4:

\控制器\ catalogs.php

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

routes.php文件

Route::get('/', array('as'=>'home', 'uses'=>'[email protected]')); 

\意见\布局\默认.blade.php

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

\ view \ catalogs \ index.blade.ph p

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

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

回答

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'=>'[email protected]_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

+0

谢谢,我明白了,现在它的工作。 –

+0

如果问题得到解决,请按我的答案接受(箭头绿色在左边) –

0

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

\controllers\catalogs.php 

\controllers\Catalogs.php 
0

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

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

干杯...