Zend\ServiceManager\Exception\ServiceNotCreatedException 在 Zend php

Zend\ServiceManager\Exception\ServiceNotCreatedException in Zend php

我有一个 web 工具,它在服务器上 运行ning,但我遇到了一个错误,所以我试图获取它的本地副本以进行调试。 问题是,当我尝试 运行 在本地使用该工具时,它可以正常工作,但有些功能却不行。

当我点击要在表单上重定向的添加按钮时,这是函数调用

 public function addAction()
{
    $pdpFormId = $this->params()->fromRoute('id', null);
    $category = $this->params()->fromRoute('category', self::CATEGORY70);

    if (empty($pdpFormId)) {
        return $this->redirect()->toRoute('pdp');
    }

    $form = $this->getObjectiveForm();
    $form->get('fsPdpObjective')->get('pdp_form_id')->setValue($pdpFormId);
    $form->get('fsPdpObjective')->get('category')->setValue($category);
    $form->get('cancel')->setAttribute('formaction', $this->url()->fromRoute('pdp'));

    $request = $this->getRequest();
    if ($request->isPost()) {
        $objective = new Objective();
        $form->setData($request->getPost());

        if ($form->isValid()) {
            $data = $form->getData();
            $objective->exchangeArray($data["fsPdpObjective"]);

            $objectiveTable = $this->getObjectiveTable();
            $objectiveTable->saveObjective($objective);

            return $this->redirect()->toRoute('pdp');
        }
    }

当它试图调用这个函数时:

public function getObjectiveForm()
{
    if (!$this->objectiveForm) {
        $this->setObjectiveForm($this->getServiceLocator()->get('PdpObjectiveForm'));
    }
    return $this->objectiveForm;
}

已更新我包括了整个堆栈跟踪和异常 它returns这个错误

#0 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(985): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Object(Closure), 'pdpobjectivefor...', 'PdpObjectiveFor...')
#1 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(598): Zend\ServiceManager\ServiceManager->createFromFactory('pdpobjectivefor...', 'PdpObjectiveFor...')
#2 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(557): Zend\ServiceManager\ServiceManager->doCreate('PdpObjectiveFor...', 'pdpobjectivefor...')
#3 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(481): Zend\ServiceManager\ServiceManager->create(Array)
#4 C:\Xampp\htdocs\atp\module\Pdp\src\Pdp\Controller\PdpController.php(259): Zend\ServiceManager\ServiceManager->get('PdpObjectiveFor...')
#5 C:\Xampp\htdocs\atp\module\Pdp\src\Pdp\Controller\PdpController.php(132): Pdp\Controller\PdpController->getObjectiveForm()
#6 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Mvc\Controller\AbstractActionController.php(83): Pdp\Controller\PdpController->addAction()
#7 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#8 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#9 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#10 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Mvc\Controller\AbstractController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#11 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Mvc\DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#12 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#13 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#14 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#15 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Mvc\Application.php(309): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#16 C:\Xampp\htdocs\atp\public\index.php(15): Zend\Mvc\Application->run()
#17 {main}

之前的异常:

Zend\I18n\Exception\ExtensionNotLoadedException

File:

    C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\I18n\Validator\Float.php:49

Message:

    Zend\I18n\Validator component requires the intl PHP extension

Stack trace:

    #0 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\AbstractPluginManager.php(170): Zend\I18n\Validator\Float->__construct()
    #1 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(602): Zend\ServiceManager\AbstractPluginManager->createFromInvokable('float', 'Float')
    #2 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(557): Zend\ServiceManager\ServiceManager->doCreate('Float', 'float')
    #3 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(481): Zend\ServiceManager\ServiceManager->create(Array)
    #4 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\AbstractPluginManager.php(103): Zend\ServiceManager\ServiceManager->get('Float', true)
    #5 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Validator\ValidatorChain.php(82): Zend\ServiceManager\AbstractPluginManager->get('Float', Array)
    #6 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Validator\ValidatorChain.php(149): Zend\Validator\ValidatorChain->plugin('Float', Array)
    #7 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\InputFilter\Factory.php(374): Zend\Validator\ValidatorChain->attachByName('Float', Array, false)
    #8 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\InputFilter\Factory.php(244): Zend\InputFilter\Factory->populateValidators(Object(Zend\Validator\ValidatorChain), Array)
    #9 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\InputFilter\InputFilter.php(61): Zend\InputFilter\Factory->createInput(Array)
    #10 C:\Xampp\htdocs\atp\module\Pdp\src\Pdp\Form\ObjectiveFilter.php(41): Zend\InputFilter\InputFilter->add(Array)
    #11 C:\Xampp\htdocs\atp\module\Pdp\Module.php(48): Pdp\Form\ObjectiveFilter->__construct()
    #12 [internal function]: Pdp\Module->Pdp\{closure}(Object(Zend\ServiceManager\ServiceManager), 'pdpobjectivefor...', 'PdpObjectiveFor...')
    #13 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(853): call_user_func(Object(Closure), Object(Zend\ServiceManager\ServiceManager), 'pdpobjectivefor...', 'PdpObjectiveFor...')
    #14 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(985): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Object(Closure), 'pdpobjectivefor...', 'PdpObjectiveFor...')
    #15 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(598): Zend\ServiceManager\ServiceManager->createFromFactory('pdpobjectivefor...', 'PdpObjectiveFor...')
    #16 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(557): Zend\ServiceManager\ServiceManager->doCreate('PdpObjectiveFor...', 'pdpobjectivefor...')
    #17 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\ServiceManager\ServiceManager.php(481): Zend\ServiceManager\ServiceManager->create(Array)
    #18 C:\Xampp\htdocs\atp\module\Pdp\src\Pdp\Controller\PdpController.php(259): Zend\ServiceManager\ServiceManager->get('PdpObjectiveFor...')
    #19 C:\Xampp\htdocs\atp\module\Pdp\src\Pdp\Controller\PdpController.php(132): Pdp\Controller\PdpController->getObjectiveForm()
    #20 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Mvc\Controller\AbstractActionController.php(83): Pdp\Controller\PdpController->addAction()
    #21 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
    #22 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
    #23 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
    #24 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Mvc\Controller\AbstractController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
    #25 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Mvc\DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
    #26 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
    #27 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
    #28 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
    #29 C:\Xampp\htdocs\atp\vendor\ZF2\library\Zend\Mvc\Application.php(309): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
    #30 C:\Xampp\htdocs\atp\public\index.php(15): Zend\Mvc\Application->run()
    #31 {main}

这是客观形式

class Objective extends Form
{
    public function __construct()
    {
        parent::__construct('pdpObjective');

        $this->setName('pdpObjectiveForm');
        $this->setAttribute('method', 'post');

        $this->add(array(
            'name' => 'fsPdpObjective',
            'type' => 'Zend\Form\Fieldset',
            'options' => array(
                'legend' => 'PDP Objective Details'
            ),
            'elements' => array(
                // ID
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Hidden',
                        'name' => 'id',
                    ),
                ),
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Hidden',
                        'name' => 'pdp_form_id',
                    ),
                ),
                // Category
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Select',
                        'name' => 'category',
                        'options' => array(
                            'label' => 'Category',
                            'value_options' => array(
                                '1' => '70 - On The Job Training',
                                '2' => '20 - Coaching/Mentoring',
                                '3' => '10 - Formal Training'
                            ),
                        ),
                    ),
                ),
                // Development Activity
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Text',
                        'name' => 'activity',
                        'options' => array(
                            'label' => 'Development Activity'
                        ),
                    ),
                ),
                // Description
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Textarea',
                        'name' => 'description',
                        'options' => array(
                            'label' => 'Description'
                        ),
                    ),
                ),
                // Estimated Cost
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Text',
                        'name' => 'cost',
                        'options' => array(
                            'label' => 'Estimated Cost'
                        ),
                    ),
                ),
                // Start Date
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Text',
                        'name' => 'start',
                        'options' => array(
                            'label' => 'Start Date',
                            'readonly' => true,
                            'hint' => '(yyyy-mm-dd)',
                        ),
                    ),
                ),
                // Due Date
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Text',
                        'name' => 'due',
                        'options' => array(
                            'label' => 'Due Date',
                            'hint' => '(yyyy-mm-dd)',
                        ),
                    ),
                ),
                // Priority
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Select',
                        'name' => 'priority',
                        'options' => array(
                            'label' => 'Priority',
                            'value_options' => array(
                                '1' => 'Critical (in present position)',
                                '2' => 'Important for the Growth (in present position)',
                                '3' => 'Helpful for Career Growth (3-5 years)'),
                        ),
                    ),
                ),
                // Status
                array(
                    'spec' => array(
                        'type' => 'Zend\Form\Element\Select',
                        'name' => 'status',
                        'options' => array(
                            'label' => 'Status',
                            'value_options' => array(
                                '1' => 'Not Started',
                                '2' => 'Ongoing',
                                '3' => 'Completed',
                                '4' => 'No Longer Applicable'
                            ),
                        ),
                    ),
                ),
            ),
        ));

        $this->add(array(
            'type' => 'Zend\Form\Element\Csrf',
            'name' => 'csrf'
        ));

        $this->add(array(
            'type' => 'Zend\Form\Element\Submit',
            'name' => 'submit',
            'attributes' => array(
                'value' => 'Save Changes',
                'class' => 'btn-primary btn-large',
            ),
        ));

        $this->add(array(
            'type' => 'Zend\Form\Element\Submit',
            'name' => 'cancel',
            'attributes' => array(
                'value' => 'Cancel'
            ),
        ));
    }
}

希望有人能帮助我。提前致谢!

已更新

这里是整个module.config的pdp模块

class Module implements AutoloaderProviderInterface, ServiceProviderInterface
{
    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\ClassMapAutoloader' => array(
                __DIR__ . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
            // if we're in a namespace deeper than one level we need to fix the \ in the path
                    __NAMESPACE__ => __DIR__ . '/src/' . str_replace('\', '/' , __NAMESPACE__),
                ),
            ),
        );
    }

    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    /* (non-PHPdoc)
     * @see \Zend\ModuleManager\Feature\ServiceProviderInterface::getServiceConfig()
     */
    public function getServiceConfig()
    {
        return array(
            'factories' => array(
                'PdpObjectiveForm' => function($sm) {
                    $form = new Form\Objective();
                    $form->setInputFilter(new Form\ObjectiveFilter());
                    return $form;
                },

                'Pdp\Model\PdpTable' => function ($sm) {
                    $tableGateway = $sm->get('PdpTableGateway');
                    $table = new \Pdp\Model\PdpTable($tableGateway);
                    return $table;
                },

                'PdpTableGateway' => function($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new \Pdp\Entity\Pdp());
                    return new TableGateway('pdp_form', $dbAdapter, null, $resultSetPrototype);
                },

                'Pdp\Model\ObjectiveTable' => function($sm) {
                    $tableGateway = $sm->get('PdpObjectiveTableGateway');
                    $table = new \Pdp\Model\ObjectiveTable($tableGateway);
                    return $table;
                },

                'PdpObjectiveTableGateway' => function($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new \Pdp\Entity\Objective());
                    return new TableGateway('pdp_form_objective', $dbAdapter, null, $resultSetPrototype);
                },
            ),
        );
    }

}

Zend\I18n\Validator component requires the intl PHP extension

intl php 扩展名丢失。我不确定它在 windows 上的表现如何,但我认为它应该与 php 发行版捆绑在一起。因此,您只需在 php.ini

中启用它