phplaravellaravel-3

Laravel route throwing: cannot find localhost


I'm trying to understand RESTfull controllers and Laravel 3 routing. I created a restfull controller Articles and now want to create the following methods:

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

POST: create
PUT: update

DELETE: destroy

However before I even started I keep getting redirected when pressing New article link in my view that should redirect to articles/write instead I get redirected to blank page with chrome error: Chrome can't find localhost.

My controller:

<?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';
    }

}

My routes:

?php


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

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

My view:

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

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

Solution

  • Try using

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

    and set up your root URL right in the application/config/app.php to http://localhost or http://127.0.0.1!