Zf2 still supports getDependencies ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Zf2 still supports getDependencies ?

Katalin
There is no "getDependencies" call: https://github.com/search?q=getDependencies+%40zendframework%2Fzf2&type=Code

So, before that I tried to find some code for adding dependencies to modules, and I found this: http://stackoverflow.com/questions/10796180/advises-needed-on-zend-framework-2-modules-and-models-architecture . Added some dependencies, disabled some modules and the project didnt work. But it didn't didn't work for "Cant load module X" but "Can't find class X".
So, I understand most of the people work with composer, but on large projects it would be GREAT and maybe a requirement this thingy. Why was it removed?
Thank you
Reply | Threaded
Open this post in threaded view
|

Re: Zf2 still supports getDependencies ?

Marco Pivetta
You can use the DependencyIndicatorInterface https://github.com/zendframework/zf2/blob/master/library/Zend/ModuleManager/Feature/DependencyIndicatorInterface.php. It does not load stuff automagically, but at least it stops you from building applications that don't have all required modules or module dependencies loaded.

Also, don't re-invent the wheel: composer has been built to solve this specific problem, so if you need to compute dependencies yourself, you can use composer's kernel classes.



On 28 April 2013 00:33, Katalin [via Zend Framework Community] <[hidden email]> wrote:
There is no "getDependencies" call: https://github.com/search?q=getDependencies+%40zendframework%2Fzf2&type=Code

So, before that I tried to find some code for adding dependencies to modules, and I found this: http://stackoverflow.com/questions/10796180/advises-needed-on-zend-framework-2-modules-and-models-architecture . Added some dependencies, disabled some modules and the project didnt work. But it didn't didn't work for "Cant load module X" but "Can't find class X".
So, I understand most of the people work with composer, but on large projects it would be GREAT and maybe a requirement this thingy. Why was it removed?
Thank you


If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/Zf2-still-supports-getDependencies-tp4659852.html
To start a new topic under Zend Framework, email [hidden email]
To unsubscribe from Zend Framework Community, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Zf2 still supports getDependencies ?

Katalin
I see. The function changed to "getModuleDependencies" from "getDependencies". It seems reduntant the keywords "Module", but for anyone trying to put dependencies, here is a sample code:

<?php
namespace Blog;

use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
/**
 * The Blog module of the FZ Application
 */
class Module
{
    public function onBootstrap(MvcEvent $e)
    {
        $e->getApplication()->getServiceManager()->get('translator');
        $eventManager        = $e->getApplication()->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);
    }

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

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }
        /**
        * Get dependencies
        *
        * @return array
        */
        public function getModuleDependencies() // @TODO: is it working?
        {
           return array(
                   'Application',
                   'ZfcUserDoctrineORM'
           );
        }
}

Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: Zf2 still supports getDependencies ?

Bas Kamer
In reply to this post by Marco Pivetta

On 28 apr. 2013, at 00:39, Marco Pivetta <[hidden email]> wrote:

> It does not load stuff automagically, but at least it stops you from
> building applications that don't have all required modules or module
> dependencies loaded.
>
> Also, don't re-invent the wheel: composer has been built to solve this
> specific problem, so if you need to compute dependencies yourself, you can
> use composer's kernel classes.

It *can* help to force the order in which modules are loaded - which sometimes can be useful


--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]