在laravel 4中使用Route::resource或Route::controller

在laravel 4中使用Route::resource或Route::controller,laravel,laravel-4,controller,routing,laravel-routing,Laravel,Laravel 4,Controller,Routing,Laravel Routing,我试着用 Route::resource('Feed', 'FeedController');<br/> 两者都不起作用 这是我的路线代码 route.php Route::get('/', function() { return View::make('pages.home'); }); Route::get('about', function() { return View::make('pages.about'); }); Route::resource(

我试着用

Route::resource('Feed', 'FeedController');<br/>
两者都不起作用
这是我的路线代码
route.php

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

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

Route::resource('Feed', 'FeedController');
Feed.php

<?php
 class Feed 
   extends Eloquent
 {
protected $fillable = array('feed', 'title', 'active', 'category');
protected $feeds;

public static $form_rules = array(
    'category' => 'required|in:Annoucements,Sports,Events',
    'title'    => 'required',
    'feed'     => 'required',
    'active'   => 'required|between:0,1'
);

public function getParsedFeed($limit = 4)
{
    if (is_null($this->feeds)) {
        $this->feeds = simplexml_load_file($this->feed);
    }

    if (!count($this->feed)) {
        return array();
    }

    $output = array();
    $content = $this->feeds->channel->item;

    foreach (range(0, $limit - 1) as $i) {
        $output[] = $content[$i];
    }

    return $output;
}

有什么问题吗?我不认为这里有任何问题,“两者都不起作用”有点含糊不清。如果你向人们描述你期望快乐的事情,与实际发生的事情(包括错误消息和输出)相比,他们会更好地帮助你。检查以确保你启用了modrewrite。如果test.com/index.php/Feed起作用,但test.com/Feed不起作用,则可以进行快速测试。另一个原因是某些环境区分大小写。您需要将web配置更改为不区分大小写。
<?php
 class Feed 
   extends Eloquent
 {
protected $fillable = array('feed', 'title', 'active', 'category');
protected $feeds;

public static $form_rules = array(
    'category' => 'required|in:Annoucements,Sports,Events',
    'title'    => 'required',
    'feed'     => 'required',
    'active'   => 'required|between:0,1'
);

public function getParsedFeed($limit = 4)
{
    if (is_null($this->feeds)) {
        $this->feeds = simplexml_load_file($this->feed);
    }

    if (!count($this->feed)) {
        return array();
    }

    $output = array();
    $content = $this->feeds->channel->item;

    foreach (range(0, $limit - 1) as $i) {
        $output[] = $content[$i];
    }

    return $output;
}
<?php

class FeedController extends \BaseController {
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */

    //The method to show the form to add a new feed
    public function create() {
        //We load a view directly and return it to be served
        return View::make('pages.news');
    }

    //Processing the form
    public function store(){
        //Let's first run the validation with all provided input
        $validation = Validator::make(Input::all(),Feeds::$form_rules);
            //If the validation passes, we add the values to the database and
            return to the form
        if($validation->passes()) {
            //We try to insert a new row with Eloquent
            $create = Feeds::create(array('feed'=> Input::get('feed'),
                'title' => Input::get('title'),
                'active' => Input::get('active'),
                'category' => Input::get('category')
            ));

            //We return to the form with success or error message due to state of the

            if($create) {
                return Redirect::to('feeds/create')
                ->with('message','The feed added to the databasesuccessfully!');
            } 
            else {
                return Redirect::to('feeds/create')
                ->withInput()
                ->with('message','The feed could not be added, please try again later!');
            }
        } 
        else {
        //If the validation does not pass, we return to the form with First error message as flash data
            return Redirect::to('feeds/create')
            ->withInput()
            ->with('message',$validation->errors()->first());
        }
    }

}