app->singleton('test', function($app){ return new UserService(new Sms($app)); }); //使用bind板顶实际到接口以便依赖注入 $this->app->bind('App\Contracts\UserContract', function($app){ return new UserService(new Sms($app)); }); } }