laravel 服务容器的用法
建立一个服务
<?php namespace App\Services; class FooService { public function __construct(){ } public function doSomething(){ echo "some"; } }
绑定服务
$this->app->bind('\App\Services\FooService');
在控制器里调用
$fooService = app()->make('\App\Services\FooService');
$fooService->doSomething();