1. Go to this page and download the library: Download xiashaung/inject library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xiashaung / inject example snippets
namespace App\Http\Controllers;
use Xiashaung\Inject\Attribute\Inject;
use App\Services\OrderService;
use Illuminate\Http\Request;
class TestController extends Controller
{
#[Inject]
//使用inject标注需要注入服务,OrderService 自动使用服务容器解析实例,如果 OrderService 里有静态方法 make ,自动调用
protected OrderService $orderService;