ZF2 Modulés name convention

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

ZF2 Modulés name convention

diego
Hi everyone!

i have a module called "Stock". The directory that contains the
directories Controller, Model and Form which, in turn, is under the
directory scr ... Should have the same name as the module?

When I name it "stock" works, if appointed otherwise, does not work (can
not find the controller class).

Working Example

module
   ->Stock
     ->config
     ->src
      ->Stock
          ->Controller
             ->MarcaController
          ->Form
          ->Model
     ->view


Not Working example
   ->Stock
     ->config
     ->src
      ->Marca
          ->Controller
             ->MarcaController
          ->Form
          ->Model
     ->view


i change settings in module.config.php but i´m getting:

Fatal error: Class 'Album\Controller\AlbumController' not found in
C:\xampp\htdocs\zf2tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\AbstractPluginManager.php
on line 170

thanx!


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


Reply | Threaded
Open this post in threaded view
|

Re: ZF2 Modulés name convention

Norbert Máté
Hi Diego,
   the recomended module structure says that under src you should have a
folder with the module name but this can be configured within the modules
Module.php.
You have probably not setup or setup wrong the autoloader for the module.
For the recommended structure the autoloader looks like this:

public function getAutoloaderConfig()
{
return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__
                ),
            ),
        );
}

To make your not working example work I think you just have to remove the
". __NAMESPACE__" part and it should work.

Regards,
Norbert.


On 5 November 2013 18:19, Diego Garcia <[hidden email]> wrote:

> Hi everyone!
>
> i have a module called "Stock". The directory that contains the
> directories Controller, Model and Form which, in turn, is under the
> directory scr ... Should have the same name as the module?
>
> When I name it "stock" works, if appointed otherwise, does not work (can
> not find the controller class).
>
> Working Example
>
> module
>   ->Stock
>     ->config
>     ->src
>         ->Stock
>           ->Controller
>              ->MarcaController
>           ->Form
>           ->Model
>     ->view
>
>
> Not Working example
>   ->Stock
>     ->config
>     ->src
>         ->Marca
>           ->Controller
>              ->MarcaController
>           ->Form
>           ->Model
>     ->view
>
>
> i change settings in module.config.php but i´m getting:
>
> Fatal error: Class 'Album\Controller\AlbumController' not found in
> C:\xampp\htdocs\zf2tutorial\vendor\zendframework\
> zendframework\library\Zend\ServiceManager\AbstractPluginManager.php on
> line 170
>
> thanx!
>
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ZF2 Modulés name convention

diego
Thanks for the answer Norbert, i´ll try that and tell how it works

Thank you


El 07/11/2013 06:14 p.m., Norbert Máté escribió:

> Hi Diego,
>     the recomended module structure says that under src you should have a
> folder with the module name but this can be configured within the modules
> Module.php.
> You have probably not setup or setup wrong the autoloader for the module.
> For the recommended structure the autoloader looks like this:
>
> public function getAutoloaderConfig()
> {
> return array(
>              'Zend\Loader\StandardAutoloader' => array(
>                  'namespaces' => array(
>                      __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__
>                  ),
>              ),
>          );
> }
>
> To make your not working example work I think you just have to remove the
> ". __NAMESPACE__" part and it should work.
>
> Regards,
> Norbert.
>
>
> On 5 November 2013 18:19, Diego Garcia <[hidden email]> wrote:
>
>> Hi everyone!
>>
>> i have a module called "Stock". The directory that contains the
>> directories Controller, Model and Form which, in turn, is under the
>> directory scr ... Should have the same name as the module?
>>
>> When I name it "stock" works, if appointed otherwise, does not work (can
>> not find the controller class).
>>
>> Working Example
>>
>> module
>>    ->Stock
>>      ->config
>>      ->src
>>          ->Stock
>>            ->Controller
>>               ->MarcaController
>>            ->Form
>>            ->Model
>>      ->view
>>
>>
>> Not Working example
>>    ->Stock
>>      ->config
>>      ->src
>>          ->Marca
>>            ->Controller
>>               ->MarcaController
>>            ->Form
>>            ->Model
>>      ->view
>>
>>
>> i change settings in module.config.php but i´m getting:
>>
>> Fatal error: Class 'Album\Controller\AlbumController' not found in
>> C:\xampp\htdocs\zf2tutorial\vendor\zendframework\
>> zendframework\library\Zend\ServiceManager\AbstractPluginManager.php on
>> line 170
>>
>> thanx!
>>
>>
>> --
>> List: [hidden email]
>> Info: http://framework.zend.com/archives
>> Unsubscribe: [hidden email]
>>
>>
>>
>



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