にサービス プロバイダを登録しましたconfig/app.php
。ロードして実行しています。
サービス プロバイダーの register() メソッドで:
\App::bind("timer", function() {
return new Foo\Utils\Timer();
});
次に、このようなファサードを作成しました
<?php namespace Foo\Facades;
use Illuminate\Support\Facades\Facade;
class Timer extends Facade {
protected static function getFacadeAccessor() { return 'timer'; }
}
次に、ファサードの実装を追加しました
<?php namespace Foo\Utils;
use Illuminate\Support\Facades\Log;
class Timer {
function test() {}
}
最後に、エイリアスを追加しましたconfig/app.php
'Timer' => 'Foo\Facades\Timer'
私がする時
\Timer::test();
私は次のことを得る
exception 'ReflectionException' with message 'Class timer does not exist'
どうしたの?
編集
Foo\Facades\Timer
正常に読み込まれています。
また、Foo\Utils\Timer
私はできるので解決されています
$timer = new Foo\Utils\Timer();
$timer->test();
エラーなし。