webman依赖注入报错must not be accessed before initialization

xtn

依赖注入报错


控制器依赖注入service提示Typed property app\admin\controller\LoginController::$service must not be accessed before initialization,请问要如何处理?

"php-di/php-di": "^7.0"
"workerman/webman-framework": "^1.5.0"
1186 1 0
1个回答

Tinywan

你这注解配置都没安装

composer require psr/container ^1.1.1 php-di/php-di ^6 doctrine/annotations ^1.14
  • xtn 2023-10-05

    安装了得 "workerman/webman-framework": "^1.5.0",
    "monolog/monolog": "^2.0",
    "psr/container": "^1.1",
    "webman/blade": "^1.5",
    "illuminate/database": "^10.24",
    "illuminate/pagination": "^10.24",
    "illuminate/events": "^10.24",
    "symfony/var-dumper": "^6.3",
    "illuminate/redis": "^10.24",
    "symfony/cache": "^6.3",
    "topthink/think-validate": "^2.0",
    "intervention/image": "^2.7",
    "webman/captcha": "^1.0",
    "vlucas/phpdotenv": "^5.5",
    "webman/event": "^1.0",
    "php-di/php-di": "^7.0",
    "doctrine/annotations": "^2.0",
    "phpoffice/phpspreadsheet": "^1.29",
    "firebase/php-jwt": "^6.8",
    "webman/console": "^1.2",
    "webman/action-hook": "^1.0",
    "symfony/translation": "^6.3",
    "topthink/think-helper": "^3.1"

  • xtn 2023-10-05

    可以了container.php配置得问题
    //return new Webman\Container;
    $builder = new \DI\ContainerBuilder();
    $builder->addDefinitions(config('dependence', []));
    $builder->useAutowiring(true);
    $builder->useAttributes(true);
    return $builder->build();
    感谢

年代过于久远,无法发表回答
×
🔝