嘗試加載頁面時,出現ReflectionException類/不存在的錯誤(open:/ var/www/laravel_guestbook/vendor/laravel/framework/src /Illuminate/Routing/ControllerInspector.php)可以使用一些有關導致此錯誤的信息。Laravel 4 - ReflectionException類/不存在
此外,我還在我的項目文件夾的根目錄下運行'composer dump-autoload'無濟於事。
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('/');
}
}
?>
是的,謝謝先生! –