您好我已经为我正在开发的Laravel项目创建了一个新的包,我对包和laravel本身的概念不熟悉,但这里是我提出的代码,
/workbench/cycs/proofhq/src/Cycs/Proofhq/ProofhqServiceProvider.php
public function boot()
{
$this->package('cycs/proofhq');
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->booting(function()
{
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Cycs', 'Cycs\Proofhq\Facades\Supyo');
});
$this->app['proofhq'] = $this->app->share(function($app)
{
return new Proofhq;
});
}
/workbench/cycs/proofhq/src/Cycs/Proofhq/Proofhq.php
<?php namespace Cycs\Proofhq;
class Proofhq {
public static function greeting() {
return "What's up dawg!";
}
}
/workbench/cycs/proofhq/src/Cycs/Proofhq/Facades/Proofhq.php
<?php namespace Cycs\Proofhq\Facades;
use Illuminate\Support\Facades\Facade;
class Proofhq extends Facade {
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() {
return 'proofhq';
}
}
我已将软件包添加到app / config / app.php和providers数组中,然后尝试通过简单的get访问包函数,
Route::get('/test', function(){
echo proofhq::greeting();
});
但是我收到以下错误,
找不到类'proofhq'
我无法弄清楚为什么,我已经按照这些例子写了这封信,并且该课程存在。
有人可以为我解释这个吗?
答案 0 :(得分:1)
composer dump-autoload
并将路由中的类名首字母改为大写似乎可以解决问题!