비슷한 질문이 제기되었지만이를 파악할 수 없습니다. 실행되는 ConsoleCommand가 있고 파일의 네임 스페이스를 원했습니다. 구조는 다음과 같습니다.
/protected/commands/Ingestion/
(root, IngestionCommand.php 포함). /protected/commands/Ingestion/ingestionServices/
(이 명령이 사용하는 서비스 포함).
이상한 부분은 IngestionCommand의 상단에 'Ingestion namespace Ingestion'을 넣지 않았지만 다른 모든 네임 스페이스를 그대로두면 모두 잘 돌아갑니다. 난 그냥 네임 스페이스 섭취에이 클래스를 넣어 싶어하지만, PHP는이 오류가 발생합니다 :
PHP Fatal error: Cannot redeclare class Ingestion\IngestionCommand in /mnt/hgfs/linkFolder/devro/CFXJobTrack/monoMassPrintTemplate/protected/commands/Ingestion/IngestionCommand.php on line 166
PHP Error[2]: include(/mnt/hgfs/linkFolder/devro/CFXJobTrack/monoMassPrintTemplate/protected/config/../commands/Ingestion/Iterator.php): failed to open stream: No such file or directory...
나는 또한 Iterator.php 오류가 내가 사용 한 모든 ... 중 하나에 관한 파일 모르는를 NetBeans 및 Finder (Mac의 경우)를 사용하여이 클래스의 다른 인스턴스를 검색 할 수 있습니다. 여기 내의 .conf의 일부는 다음과 같습니다
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR . '..',
'name'=>'Cron',
'preload'=>array('log'),
'aliases'=> array(
'Ingestion' => dirname(__FILE__) . '/../commands/Ingestion/',
),
//autoload class for use in yii.
'import'=>array(
'application.components.*',
'application.models.*',
'application.extensions.sftp.*',
'application.components.container.*',
'application.commands.*',
'Ingestion.*',
'Ingestion.ingestionServices.*',
),
'commandMap'=> array(
'ingestion' =>array(
'class' =>'Ingestion.IngestionCommand',
),
I 라인 주석 때 :
'Ingestion' => dirname(__FILE__) . '/../commands/Ingestion/',
PHP는 다음과 같이 불평 :
PHP Error[2]: include(IngestionCommand.php): failed to open stream: No such file or directory
in file /mnt/hgfs/linkFolder/devro/CFXJobTrack/yii/framework/YiiBase.php at line 421...
내게 '유일한 장소를 알려줍니다 이 클래스를로드하려고 시도하면됩니다.하지만 잘못되었습니다. 아무도 내가 누락되었거나 잘못하고 있음을 안다?
왜이 클래스의 네임 스페이스를 사용할 수 없는지 이해하지 못하고 있지만 하위 디렉터리 클래스의 네임 스페이스를 지정할 수 있습니다.
중요한 정보를 생략했는지 알려주세요. 단지, 다음과 같이 실행중인 init 파일이 있습니다.
// change the following paths if necessary
$yii=dirname(__FILE__).'/../../../yii/framework/yii.php';
$config=dirname(__FILE__).'/../config/cron.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
require_once(dirname(__FILE__).'/../components/ConsoleApplication.php');
Yii::createApplication('ConsoleApplication',$config)->run();
모든 파일은 클래스와 동일한 명명 규칙을 따릅니다.
나는이뿐만 아니라 SO 질문과 YII 파일을 다른 같은 겪었 : Yii Framework Namespace Docs
감사합니다.