$this->app->bind('App\DAO\UserDAO',function(){ return new UserDAOImpl(); }); $this->app->bind('App\DAO\UserDAO','App\DAO\Impl\UserDAOImpl');
$this->app->bind(['dao.user' => 'App\DAO\UserDAO'],'App\DAO\Impl\UserDAOImpl');
$this->app->bind(['dao.user' => 'App\DAO\UserDAO'],'App\DAO\Impl\UserDAOImpl', true);
php artisan make:command FirstCommand
$this->dispatch(new FirstCommand());
protected $listen = [ 'App\Events\FirstEvent' => [ 'App\Handlers\Events\FirstEventHandler', ], ];
<span style="white-space:pre"> </span>\Event::fire(new FirstEvent()); //or use the helper function event(new FirstEvent());
$this->release(30); $this->delete();및 기타 방법을 사용하여 이벤트 처리 중에 작업을 삭제하거나 재설정할 수 있습니다.
class ThirdEventHandler { /** * Create the event handler. * * @return void */ public function __construct() { // } public function doSomething(){ echo " ThirdEventHalder !!!.."; } public function doSomethingToo(){ echo "lalala, ThirdEventHalder again!!!.."; } /** * 注册监听器给订阅者。 * * @param Illuminate\Events\Dispatcher $events * @return array */ public function subscribe($events) { $events->listen('App\Events\FirstEvent', 'App\Handlers\Events\ThirdEventHandler@doSomething'); $events->listen('App\Events\FirstEvent', 'App\Handlers\Events\ThirdEventHandler@doSomethingToo'); } }구독 방법은?
$subscriber = new App\Handlers\Events\ThirdEventHandler(); Event::subscribe($subscriber); // or rely on IoC Event::subscribe('App\Handlers\Events\ThirdEventHandler');완료되었습니다.