1

When attempting to load the page, I'm getting the error that the ReflectionException Class / does not exist (open: /var/www/laravel_guestbook/vendor/laravel/framework/src/Illuminate/Routing/ControllerInspector.php), could use some insight on what is causing this error.

Furthermore, I've also run 'composer dump-autoload' at the root of my project folder to no avail.

routes.php

Route::controller('EntriesController', '/');

Entry.php

<?php
class Entry extends Eloquent {

   /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'entries';
}
?>

home.blade.php

<html>
<head>
    <title>Laravel 4 Guestbook</title>
</head>
<body>
    @foreach ($entries as $entry)
        <p>{{ $entry->comment }}</p>
        <p>Posted on {{ $entry->created_at->format('M jS, Y') }} by 
           <a href="mailto:{{ $entry->email }}"> {{ $entry->username}}</a>
        </p><hr>
    @endforeach

    <form action="/" method="post">
        <table border="0">
            <tr>
                <td>Name</td>
                <td><input type="text" name="frmName" value="" size="30" maxlength="50"></td>
            </tr>

            <tr>
                <td>Email</td>
                <td><input type="text" name="frmEmail" value="" size="30" maxlength="100"></td>
            </tr>
            <tr>
                <td>Comment</td>
                <td><input textarea name="frmComment" row="5" cols="30"></textarea></td>
            </tr>

            <tr>
                <td></td>
                <td>
                    <input type="submit" name="submit" value="submit"> 
                    <input type="reset" name="reset" value="reset">
                </td>
            </tr>
        </table>
    </form>
</body>

EntriesController.php

<?php

class EntriesController extends BaseController {

    # Handles "GET /" request
    public function getIndex()
    {
        return View::make('home')
                ->with('entries', Entry::all());
    }

    # Handles "POST /"  request
    public function postIndex()
    {
        // get form input data
        $entry = array(
            'username' => Input::get('frmName'),
            'email'    => Input::get('frmEmail'),
            'comment'  => Input::get('frmComment'),
        );

        // save the guestbook entry to the database
        Entry::create($entry);

        return Redirect::to('/');
    }
}
?>

3 Answers 3

6

It's suppose to be:

Route::controller('/', 'EntriesController');
Sign up to request clarification or add additional context in comments.

Comments

4

If your naming is correct but you still get this type of error do a

composer update

This command will refresh your composer autoload files (among others).

1 Comment

composer update will check/download and update all dependencies in project (which may take some time or not necessary), if needed just generate new autoload file just use composer dumpautoload / composer dump-autoload getcomposer.org/doc/03-cli.md#dump-autoload
1

In my case the name of the file was PostController.php, but inside I had

class Post extends \BaseController {

Instead of

class PostController extends \BaseController {

I had to rename the file as "php artisan generate:controller " command requires the word controller to be specified.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.