我在工作台中设置了一个新软件包,但我一直收到错误:
Class 'company\package\MyPackageFacade' not found
我的班级名称间隔正确。
我已经在包和root中执行了这个:
composer dump-autoload
我也尝试过:
php artisan dump-autoload
我还检查了所有内容的拼写。
我还有什么地方出错?
Package.php
class Package {
public static function test(){
return "it works";
}
}
PackageFacade.php
<?php namespace Company\Package;
use Illuminate\Support\Facades\Facade;
class Package extends Facade {
protected static function getFacadeAccessor() { return 'package'; }
}
PackageServiceProvider.php
<?php namespace Company\Package;
use Illuminate\Support\ServiceProvider;
class MyPackageServiceProvider extends ServiceProvider {
protected $defer = false;
public function boot()
{
$this->package('company\package');
}
public function register()
{
$this->app['privilege'] = $this->app->share(function($app)
{
return new Package;
});
}
public function provides()
{
return array('package');
}
}
在我的应用配置提供商中:
'Company\Package\PackageServiceProvider',
和别名:
'Package' => 'Company\Package\PackageFacade',
答案 0 :(得分:2)
您的门面名称应为
'Package' => 'Company\Package\Package',
如果您想要PackageFacade,则必须将其更改为:
class PackageFacade extends Facade { ... }