2016-02-01 07:33
浏览 55


I am facing one problem I do not know what is a reason of this I add class with location in my project src/ApiMaps/ApiMapBundle with this name space

     namespace ApiMaps\ApiMapService;

  class ApiMapService {
  private $transport;
   public function __construct() {
    $this->transport = 'sendmail';
// ...

when i give in


      class:  ApiMaps\ApiMapService\ApiMapService
      arguments: ["@doctrine.orm.entity_manager"]

and when i run it from some other class for example


 class GetApiCommand extends ContainerAwareCommand
   protected function execute(InputInterface $input, OutputInterface $output)
   $number = $this->getContainer()->get('app.test');

it give me error

Fatal error: Class 'ApiMaps\ApiMapService\ApiMapService' not found in D:\xampp\htdocs\ProjectMapApiData\a pp\cache\dev\appDevDebugProjectContainer.php on line 325 [2016-02-01 08:25:20] php.CRITICAL: Fatal Error: Class 'ApiMaps\ApiMapService\ApiMapService' not found {" type":1,"file":"D:\xampp\htdocs\ProjectMapApiData\app\cache\dev\appDevDebugProjectContainer.php"," line":325,"level":-1,"stack":[]}

[Symfony\Component\Debug\Exception\ClassNotFoundException] Attempted to load class "ApiMapService" from namespace "ApiMaps\ApiMapService". Did you forget a "use" statement for another namespace?

Note-- one thing to mention that when i try to make service from the built-in class of symfony2 classes it does not give me such error. I do know where I need to add the namespace of the class which i recently added with my project that it able to know the class...

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douhe4608 2016-02-01 07:39

    You mention that your service in file: src/ApiMaps/ApiMapBundle
    but in config you wrote: ApiMaps\ApiMapService\ApiMapService.

    I think you should house you service in file: src/ApiMaps/ApiMapBundle/ApiMapService/ApiMapService.php,
    take namespace: ApiMaps\ApiMapBundle\ApiMapService
    and write in config: ApiMaps\ApiMapBundle\ApiMapService\ApiMapService.

    Truly believe it'll help you...

    解决 无用
    打赏 举报

相关推荐 更多相似问题