Quantcast

ZF2 module namespaces

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

ZF2 module namespaces

demiankatz
Hello,

I'm brainstorming how to adapt my application to ZF2.  The software is a web app with a handful of CLI tools.  I would like to share as much code between these two areas as possible.  I'm thinking of using a primary module to handle the web app, with a secondary module loaded in CLI mode to override routing behavior while recycling other configuration and code.

I'm struggling with the naming in this hypothetical situation.  If the top-level namespace is supposed to be a vendor, then the logical namespacing would be something like:

\MyApp\Module

and

\MyApp\CLI\Module

However, it appears that ZF2 modules have to live in the top of a namespace, so I would end up with something like:

\MyApp\Module

and

\MyAppCLI\Module

...which just doesn't quite feel right.

Am I misunderstanding something, or is this a limitation I should just live with?  If I have to live with it, are there any conventions I should keep in mind?  I'm also interested in comments on my proposed CLI solution, though that is not my primary concern right now.

thanks,
Demian
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ZF2 module namespaces

Marco Pivetta
Hey Demian,

Modules don't need to live at the top of the namespace. You can use as many
sub-namespaces as you want!

Enjoy ;)

Marco Pivetta

http://twitter.com/Ocramius

http://marco-pivetta.com



On 19 June 2012 15:49, Demian Katz <[hidden email]> wrote:

> Hello,
>
> I'm brainstorming how to adapt my application to ZF2.  The software is a
> web app with a handful of CLI tools.  I would like to share as much code
> between these two areas as possible.  I'm thinking of using a primary
> module to handle the web app, with a secondary module loaded in CLI mode to
> override routing behavior while recycling other configuration and code.
>
> I'm struggling with the naming in this hypothetical situation.  If the
> top-level namespace is supposed to be a vendor, then the logical
> namespacing would be something like:
>
> \MyApp\Module
>
> and
>
> \MyApp\CLI\Module
>
> However, it appears that ZF2 modules have to live in the top of a
> namespace, so I would end up with something like:
>
> \MyApp\Module
>
> and
>
> \MyAppCLI\Module
>
> ...which just doesn't quite feel right.
>
> Am I misunderstanding something, or is this a limitation I should just
> live with?  If I have to live with it, are there any conventions I should
> keep in mind?  I'm also interested in comments on my proposed CLI solution,
> though that is not my primary concern right now.
>
> thanks,
> Demian
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: ZF2 module namespaces

demiankatz
Wonderful!  I guess I just saw things like ZendSkeletonApplication and made an incorrect assumption.  Thanks!

From: Marco Pivetta [mailto:[hidden email]]
Sent: Tuesday, June 19, 2012 9:52 AM
To: Demian Katz
Cc: [hidden email]
Subject: Re: [fw-general] ZF2 module namespaces

Hey Demian,

Modules don't need to live at the top of the namespace. You can use as many sub-namespaces as you want!

Enjoy ;)

Marco Pivetta

http://twitter.com/Ocramius

http://marco-pivetta.com


On 19 June 2012 15:49, Demian Katz <[hidden email]<mailto:[hidden email]>> wrote:
Hello,

I'm brainstorming how to adapt my application to ZF2.  The software is a web app with a handful of CLI tools.  I would like to share as much code between these two areas as possible.  I'm thinking of using a primary module to handle the web app, with a secondary module loaded in CLI mode to override routing behavior while recycling other configuration and code.

I'm struggling with the naming in this hypothetical situation.  If the top-level namespace is supposed to be a vendor, then the logical namespacing would be something like:

\MyApp\Module

and

\MyApp\CLI\Module

However, it appears that ZF2 modules have to live in the top of a namespace, so I would end up with something like:

\MyApp\Module

and

\MyAppCLI\Module

...which just doesn't quite feel right.

Am I misunderstanding something, or is this a limitation I should just live with?  If I have to live with it, are there any conventions I should keep in mind?  I'm also interested in comments on my proposed CLI solution, though that is not my primary concern right now.

thanks,
Demian

Loading...