请有人告诉我为什么我的第一个自制门面不起作用。我在这上面花了几个小时,我可能会发疯。
composer.js 包含
"classmap": [
"app/commands",
"app/controllers",
"app/facades",
"app/libraries",
....
/app/config/app.php 包含
'providers' => array(
....
'CloudsServiceProvider',
/libraries/Clouds.php
class Clouds {
protected $_current = null;
public function current()
{
if($this->_current)
return $this->_current;
$this->_current = Cloud::find(1); // Cloud in a Model
return $this->_current;
}
}
/libraries/CloudsServiceProvider.php
use Illuminate\Support\ServiceProvider;
class CloudsServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind('Clouds', function()
{
return new Clouds();
});
}
}
/facades/CloudsFacade.php
use Illuminate\Support\Facades\Facade;
class Clouds extends Facade
{
protected static function getFacadeAccessor()
{
return 'Clouds';
}
}
在终端我做:
composer dump
当我调用 $cloud = Clouds::current(); 我得到:
Non-static method Clouds::current() should not be called statically, assuming $this from incompatible context
App::make('云')->current(); 似乎工作。
我已经遵循了一些教程,但我只是不断地回到这个问题。