'Class'App \ Http \ Controllers \ Url'not found' - Laravel 5

时间:2015-06-04 10:57:32

标签: php laravel-5 laravel-routing

我已经开始学习Laravel 5.关注this tutorial。我收到了这个错误。 (Class 'App\Http\Controllers\Url' not found)。
我在这里附上了我的代码图像。

code-laravel



Whoops, looks like something went wrong.

1/1
FatalErrorException in UrlController.php line 22:
Class 'App\Http\Controllers\Url' not found
in UrlController.php line 22
at FatalErrorException->__construct() in compiled.php line 1838
at HandleExceptions->fatalExceptionFromError() in compiled.php line 1833
at HandleExceptions->handleShutdown() in compiled.php line 0
at UrlController->store() in compiled.php line 8504
at call_user_func_array:{C:\wamp\www\readit-later\vendor\compiled.php:8504}() in compiled.php line 8504
at Controller->callAction() in compiled.php line 8572
at ControllerDispatcher->call() in compiled.php line 8551
at ControllerDispatcher->Illuminate\Routing\{closure}() in compiled.php line 9190



帮助我。

2 个答案:

答案 0 :(得分:1)

你应该创建一个名为Url的模型或者你的app文件夹中最适合的模型,你也可以通过artisan命令生成一个url模型

php artisan make:model Url

或者您可以手动创建一个

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Builder;

protected $table = 'table_name' // in case your table name is different than plural of model name

class Url extends Model
{

}

然后在您的控制器中使用此Url模型,例如

use App\Url;

然后你就可以使用

$url = new Url;
$url->url = Request::get('url'); //make sure you have used use Illuminate\Http\Request; in starting of your controller 

答案 1 :(得分:1)

在控制器中添加

_start