我正在學習laravel並出現錯誤。你有什麼建議什麼是錯的? 我嘗試過「composer dump-autoload」,但它沒有解決這個問題。類不存在Container.php中的ErrorException 738行:
ErrorException在Container.php行738:類 應用程序\ HTTP \查看\作曲家\ CatFormComposer不存在(查看: /Applications/MAMP/htdocs/lar/furbook.com/resources/views/cats /create.blade.php)
ReflectionException在Container.php行738:類 應用程序\ HTTP \查看\作曲家\ CatFormComposer不存在
這裏是我的代碼: 應用程序\ HTTP \瀏覽\ Composers \ CatFormComposer.php
<?php
namespace Furbook\Http\Views\Composers;
use Furbook\Breed;
use Illuminate\Contracts\View\View;
class CatFormComposer {
protected $breeds;
public function __construct (Breed $breeds) {
$this->breeds = $breeds;
}
public function compose(View $view) {
$view->with('breeds', $this->breeds->lists('name', 'id');
}
}
應用/供應商/ AppServiceProvider.php
<?php
namespace Furbook\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\View\Factory as ViewFactory;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(ViewFactory $view)
{
$view->composer('partials.forms.cat',
'App\Http\Views\Composers\CatFormComposer');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}