Service 未在工厂找到Laminas(ex Zend Framework 3)类

Service 未在工厂找到Laminas(ex Zend Framework 3)类,service,factory,zend-framework3,Service,Factory,Zend Framework3,我被这个问题迷住了 我的最后一堂课“Enterprise”有一个带工厂的模块表 所以在module/Tables/config/module.config.php <?php namespace \Tables\Service\Factory; use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Factory\FactoryInterface; use Tables\S

我被这个问题迷住了

我的最后一堂课“Enterprise”有一个带工厂的模块表
所以在
module/Tables/config/module.config.php

<?php
    namespace \Tables\Service\Factory;

    use Interop\Container\ContainerInterface;
    use Laminas\ServiceManager\Factory\FactoryInterface;
    use Tables\Service\Entreprise;


    class EntrepriseFactory  implements  FactoryInterface 
    {    
             public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
             {
                DIE('FACTORY ENTREPRISE NOT REACHED ... :-( ');
                $entreprise = new Entreprise(); 
                return $enteprise;
             }
}
模块/Tables/src/Tables/Service/Factory.php

<?php
namespace \Tables\Service\Factory;

use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Tables\Service\Entreprise;


class EntrepriseFactory  implements  FactoryInterface
{
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
     {
        DIE('FACTORY ENTREPRISE NOT REACHED !!!');
        $entreprise = new Entreprise(); 
        return $entreprise;
     }
 }
SERVER/config/modules.config.php中的根配置中

<?php
 return array(
   'service_manager' => [
        // the resolution works...
        // but the final class is not found...
        'invokables' => [
           Service\Entreprise::class =>  \Tables\Service\Factory\EntrepriseFactory::class,
        ]

   ]
);
...
return [
    'Laminas\Db',
    'Laminas\Di',
    'Laminas\Mvc\Plugin\FilePrg',
    'Laminas\Mvc\Plugin\FlashMessenger',
    'Laminas\Mvc\Plugin\Identity',
    'Laminas\Mvc\Plugin\Prg',
    'Laminas\Session',
    'Laminas\Mvc\I18n',
    'Laminas\Mvc\Console',
    'Laminas\Form',
    'Laminas\Hydrator',
    'Laminas\InputFilter',
    'Laminas\Filter',
    'Laminas\I18n',
    'Laminas\Cache',
    'Laminas\Router',
    'Laminas\Validator',
    'Application',
    'Tables',
    'Tfirst',
......
以及错误转储

  Error
    File:
    /home/vagrant/Code/yeting/SERVER/vendor/laminas/laminas-servicemanager/src/Factory/InvokableFactory.php:31
    Message:
    Class 'Tables\Service\Factory\EntrepriseFactory' not found
    Stack trace:
    #0 /home/vagrant/Code/yeting/SERVER/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(765): Laminas\ServiceManager\Factory\InvokableFactory->__invoke()
    #1 /home/vagrant/Code/yeting/SERVER/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(201): Laminas\ServiceManager\ServiceManager->doCreate()
    #2 /home/vagrant/Code/yeting/SERVER/module/Tables/src/Module.php(246): Laminas\ServiceManager\ServiceManager->get()

。。。有什么建议吗?

好的。。。我发现了我的错误

实际上,我将旧式的zend 2目录结构与新的zend 3教程(现在是Laminas)混合在一起,所以名称空间是错误的

更正前:我的结构目录是:
(即适用于型号:)
模块/表格/src/Tables/model

新结构是
(即适用于型号:)
模块/表格/src/model
工厂等的idem

总有错误,但那是另一个问题

我结束这个问题

...
return [
    'Laminas\Db',
    'Laminas\Di',
    'Laminas\Mvc\Plugin\FilePrg',
    'Laminas\Mvc\Plugin\FlashMessenger',
    'Laminas\Mvc\Plugin\Identity',
    'Laminas\Mvc\Plugin\Prg',
    'Laminas\Session',
    'Laminas\Mvc\I18n',
    'Laminas\Mvc\Console',
    'Laminas\Form',
    'Laminas\Hydrator',
    'Laminas\InputFilter',
    'Laminas\Filter',
    'Laminas\I18n',
    'Laminas\Cache',
    'Laminas\Router',
    'Laminas\Validator',
    'Application',
    'Tables',
    'Tfirst',
......
  Error
    File:
    /home/vagrant/Code/yeting/SERVER/vendor/laminas/laminas-servicemanager/src/Factory/InvokableFactory.php:31
    Message:
    Class 'Tables\Service\Factory\EntrepriseFactory' not found
    Stack trace:
    #0 /home/vagrant/Code/yeting/SERVER/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(765): Laminas\ServiceManager\Factory\InvokableFactory->__invoke()
    #1 /home/vagrant/Code/yeting/SERVER/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(201): Laminas\ServiceManager\ServiceManager->doCreate()
    #2 /home/vagrant/Code/yeting/SERVER/module/Tables/src/Module.php(246): Laminas\ServiceManager\ServiceManager->get()