Laravel路线投掷:找不到localhost

时间:2013-05-28 16:27:26

标签: php laravel laravel-3

我正在尝试了解RESTfull控制器和Laravel 3路由。我创建了一个restfull控制器文章,现在想要创建以下方法:

GET: index 
GET: write // (new but new is reserved)
GET: edit

POST: create
PUT: update

DELETE: destroy

然而,在我开始之前,我一直按照我的视图中的New article链接进行重定向,该链接应重定向到articles/write而不是重定向到空白页面,并显示Chrome错误:Chrome无法找到localhost。

我的控制器:

<?php

class Articles_Controller extends Base_Controller {

  public $restful = true;

    public function get_index()
    {
        return View::make('articles.index', array('articles' => Article::all()));
    }

    public function get_write()
    {
        return View::make('articles.new');
    }

    public function post_create()
    {
        return 'Created';
    }

}

我的路线:

?php


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

// Articles
Route::controller('articles');

我的观点:

<h1>Todays articles:</h1>
<?php

    if(sizeof($articles) == 0)
    {
        echo 'No articles published';
    }
?>
<br /><br />
<?= HTML::Link('articles/write', 'New article') ?>

1 个答案:

答案 0 :(得分:1)

尝试使用

HTML::link_to_action('articles@write', 'New article');

并在application/config/app.phphttp://localhosthttp://127.0.0.1中设置您的根网址!

相关问题