yii2 컨트롤러 작업 주입은 어떻게 작동합니까? (How does the yii2 Controller action injection works)


문제 설명

yii2 컨트롤러 작업 주입은 어떻게 작동합니까? (How does the yii2 Controller action injection works)

저는 yii2의 종속성 주입에 대해 작업 중이며 매우 유용한 주제인 컨트롤러 작업 주입. 시도했지만 작동하지 않습니다. 나는 모든 Google 작업을 수행했고 이벤트는 yii2 프레임워크의 소스 코드를 읽었습니다. 제가 놓치고 있는 것이 있습니까? 내 코드는 다음과 같습니다.

//my action
public function actionIndex(JobService $jobService) {
    //logic code
}

//i register the dependencies in the bootstrap file
// and yes ,i tried \Yii::$container‑>set('JobService', '\hr\services\JobService') too
\Yii::$container‑>set('\hr\services\JobService', '\hr\services\JobService');

아래 오류 메시지가 나타납니다. 여기에 이미지 설명 입력


참조 솔루션

방법 1:

the controller DI just fixed two month ago, and they hadn't release yet, you can fix it manually. check you yii\web\Controller with github‑yii\web\Controller

(by dzthinkcrains)

참조 문서

  1. How does the yii2 Controller action injection works (CC BY‑SA 2.5/3.0/4.0)

#PHP #yii2 #dependency-injection






관련 질문

bash의 rsync가 php 생성 --exclude-from 파일을 구문 분석하지 않음 (rsync in bash not parsing php-generated --exclude-from file)

PHP 배열 값 저장 (PHP Save array value)

검색으로 배열에서 특정 데이터 가져오기 (get specific datas from a array by a search)

창 서비스를 사용하여 PHP 파일 트리거 (Trigger a php file using window service)

yii2 컨트롤러 작업 주입은 어떻게 작동합니까? (How does the yii2 Controller action injection works)

php와 drupal을 사용하여 pdf를 텍스트로 변환 (pdf to text convert using php and drupal)

PHP에서 카테고리 및 하위 카테고리 목록 검색 (Retrieve Category & Subcategory list in PHP)

PDO - COUNT(*) 결과를 얻습니까? (PDO - get the result of a COUNT(*)?)

PHP - MySQL 쿼리 문제 (PHP - Mysql query problem)

제품용 Reviews.io API의 Foreach 루프 (Foreach loop in Reviews.io API for Products)

숫자를 나누고 점 뒤에 하나의 숫자를 유지하십시오. (Split the number and keep one number after the dot)

내 메시지 입력이 데이터베이스에 들어가지 않습니다. (My message input doesn't get into database)







코멘트