Re: [fw-general] How to share modules between svn projects

2013-10-15 Thread Michael Gooden
Hi Antonio,

Your question appears to be related to Zend Studio, this mailing list is
for Zend Framework general queries.

Cheers,

Michael Gooden


On 15 October 2013 17:28, Antonio Caccese  wrote:

> Hi,
> i have two or more svn projects in zend studio. Every project is locally
> stored in the apache htdocs folder in order to run it on web browsers.
>
> One project is the main CMS and the others projects are extensions of it
> for different customers.
>
> I would to share main modules, like core, users of the CMS with the others
> projects via SVN so that if i make a change to the core module of the CMS,
> this modification is replicated automatically to the others projects. Also,
> i would that the projects are still runnable with this external inclusion.
>
> I tried with the svn:externals but i lose miserably.
> Anyone can help me?
>
> Hello from Italy.
> Antonio
>


Re: [fw-general] problem in Uploading file

2013-09-10 Thread Michael Gooden
Hi Waqas,

Please restate your question using proper grammar and punctuation.

Additionally:
Be precise

There is nothing worse than "*My printer doesn't work.*" or "*My mail
server doesn't work.*". How are others supposed to help you when you don't
give them any information? Make sure you include at least this information:

   - What did you try to accomplish? (I wanted to fetch my mails via POP3.)
   - What has happened (wrongly) instead? (But my inbox remains empty.)
   - What environment are you using? (I am using kmail 1.8 in KDE 3.4.)
   - What did you try to find the cause? (I already checked my POP3 account
   setup.)
   - Are there error message or log files? (The error message reads: "SSL
   negotiation failed.")
   - Has it ever worked? What did you change? (I switched accounts to a new
   provider. It worked before with another provider.)

If all this information is included then you will have a high chance of
getting a useful reply.
Tell what you are doing

Others only know what you tell them. If you change things silently then
nobody will know about it. The worst thing you can do is say: "*I changed
something. Now I have another problem.*" This will get you ignored in no
time. If you expect help you need to work with the supporters.


On 10 September 2013 14:37, wiki  wrote:

> i am trying to upload file in zend framework 2 , the file is uploaded to
> the
> directory but it gives a routing error page not found pl help me
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/problem-in-Uploading-file-tp4660947.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] zf2 - zend acl dynamic assertions; when/how to load the resource?

2013-09-09 Thread Michael Gooden
Well there are two ways you can do this, (well three, but we will get to
that).

You can do checks based on the requested route or controller and action,
and do generic checks like, can a user of type 'guest' access the 'edit'
action of my 'postcontroller', or if user of type 'guest' can access route
'my/controller/edit'.

This is nice for just overall access control, keeping all your guests out
of user areas etc. You can use a library like BjyAuthorize to do this
automagically.

The second case, which I presume is your case, is to check whether user
1234 can edit post 567. This you use assertions for. I usually do that
check after I have done the 'does this resource even exist' check. If the
assertion fails, I either 403 them or redirect to a known accessible page.

You could do the resource exists and is allowed checks in an early dispatch
listener and then pass the resource as a parameter to the MvcEvent being
passed around. This option might be more attractive if you are worried
about coupling your authorization to your controllers directly.

Hopefully this is of some help :)

Cheers,

Michael Gooden


On 9 September 2013 10:17, Martijn Korse  wrote:

> i'm creating a zend framework 2 application and i'm sort of trying to
> implement what is explained here:
>
> http://ralphschindler.com/2009/08/13/dynamic-assertions-for-zend_acl-in-zf
>
> The demonstration that the code works is really nice, but it doesn't really
> apply to how a framework (utilizing mvc) works. Or maybe i'm just on the
> wrong track...
>
> i've created a RouteListener like this :
>
>
> the method checkAcl then checks if you're allowed to do what you want to
> do.
>
> The resource and action are determined like this:
>
>
> And the role is determined by the identity stored in the session (which
> implements Zend\Permissions\Acl\Role\RoleInterface)
>
> Following the example: how do i determine if a user is allowed to edit a
> certain blog-post? By the time acl is doing it's checking, the controller
> hasn't loaded the blogpost yet, so i'm not sure how to approach this.
> Unless
> i duplicate the retrieval of the blogpost in the assertion, but i'm hoping
> that there is a better way.
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/zf2-zend-acl-dynamic-assertions-when-how-to-load-the-resource-tp4660933.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] DI and Controllers in ZF2

2013-08-24 Thread Michael Gooden
Hi Phillip G,

The easiest way to get the behaviour your co-worker desires is to use
service manager factories. You can create a factory for your controller,
and inject the service there. Then you will be able to do
$this->getPlatformObject() as expected.

Kind Regards,

Michael Gooden


On 24 August 2013 00:21, Philip G  wrote:

> On Fri, Aug 23, 2013 at 3:05 PM, Matthew Weier O'Phinney
> wrote:
>
> > Just for argument's sake, why are you using Zend\Di instead of
> > Zend\ServiceManager? Is there a compelling reason?
> >
> >
> Purely for the sake of a co-worker's request and desire. He didn't like
> hard coding of a ServiceManager alias name, even if it was an alias. He
> comes from a Java background and rather see DI than SM aliases.
>
> However, if there is a compelling reason to use SM over DI with ZFW, I
> could easily convince him otherwise.
>
> In my example, I originally use $sm->get('Firmware\PlatformObject'); and it
> does work perfectly. And he just rather see: $this->getPlatformObject()
> where platformObject is injected into our controller by the framework. I
> wanted to compare the two different approaches, and select the best option.
>
> ---
> Philip
> g...@gpcentre.net
> http://www.gpcentre.net/
>


Re: [fw-general] zend framework 2.2.3 : non required form fields not working anymore?

2013-08-24 Thread Michael Gooden
Hi Matthew,

Even though the 2.2.3 release fixed the previously undiscovered bug, it has
as you noted broken the behaviour that has been standard so far.

I recommend towards setting the flag to true by default, and either an
immediate 2.2.4 release, or a notification of some type as to the usage of
the setPreferFormInputFilter method. I strongly recommend an immediate
release of 2.2.4, as I upgraded to 2.2.3 via composer, which means I did
not immediately see the changelog, just a broken application.

Regards,

Michael Gooden


On 23 August 2013 19:52, Matthew Weier O'Phinney  wrote:

> On Fri, Aug 23, 2013 at 3:27 AM, Wim Kumpen 
> wrote:
> > Just checking if someone has the same problem after upgrading from 2.2.2
> to
> > 2.2.3.
> > I have a form with validation. After upgrading, the not required fields,
> are
> > suddenly required.
>
> After some discussion with Michael Gallego and tracking down what is
> happening under the hood, this is what I discovered:
>
> - Prior to 2.2.3, the `setPreferFormInputFilter()` flag didn't really
> do anything, though it was supposed to. The reason it didn't really do
> anything is because the order of operations in
> `attachInputFilterDefaults()` was incorrect, and was merging inputs
> too soon. This had necessitated a strange situation in
> `Zend\InputFilter\BaseInputFilter::add()` wherein the old input was
> being merged to the new one, and then the new one placed in the input
> filter...
>
> - Which was clearly wrong, because it meant that flags and settings in
> the new input were getting overwritten by the old ones. For this
> reason, issue #4996 was created.
>
> - In fixing #4996, I corrected the behavior in
> `attachInputFilterDefaults()`, which now means that you need to call
> `setPreferFormInputFilter()` and pass it a boolean `true` if you are
> defining forms via configuration and/or using fieldsets or elements
> that implement `InputFilterProviderInterface` and/or
> `InputProviderInterface`.
>
> So, the way you can get the pre-2.2.3 behavior is to simply do this:
>
> $form->setPreferFormInputFilter(true);
>
> The question I have to everyone is: should that flag be set to true by
> default? And, if so, should this be done for an immediate 2.2.4
> release, should it wait for the regular 2.2.4 release (third Wednesday
> in September), or wait for 2.3.0?
>
> Thoughts?
>
> > Just a part of the code:
> >
> >
> > $this->inputFilter = new InputFilter();
> > $factory = new InputFactory();
> >
> > $this->inputFilter->add(
> > $factory->createInput(
> > array(
> >  'name'   => 'website',
> >  'required'   => false,
> >  'filters'=> array(
> >  array('name' => 'StripTags'),
> >  ),
> > 'validators'  => array(
> > array(
> > 'name'  => 'Uri',
> > 'options'   => array(
> > 'uriHandler' => "\Zend\Uri\Http",
> > 'messages'   => array(
> > Uri::NOT_URI => "The input does not
> > appear to be a valid Url",
> > )
> > )
> > )
> > )
> > )
> > )
> > );
> >
> >
> > I found something in the 'Form' class, 'attachInputFilterDefaults'
> method.
> > Fields like 'email', 'url' are instances of InputProviderInterface and
> then
> > he gets getInputSpecification() ... And that will overwrite my settings.
> I
> > can fix this with setting 'preferFormInputFilter' on true. But I didn't
> have
> > to do that in 2.2.2 so ...
>
>
> --
> Matthew Weier O'Phinney
> Project Lead| matt...@zend.com
> Zend Framework  | http://framework.zend.com/
> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] zend framework 2.2.3 : non required form fields not working anymore?

2013-08-23 Thread Michael Gooden
Hi Wim,

This appears to be a problem with a patch introduced into 2.2.3.

We are actively working on the problem, I recommend that you downgrade to
2.2.2 until we can release a hotfix.

(When I say 'I' and 'we', I am referring to the community :)

Kind Regards,

Michael Gooden


On 23 August 2013 10:27, Wim Kumpen  wrote:

> Hello,
>
> Just checking if someone has the same problem after upgrading from 2.2.2 to
> 2.2.3.
> I have a form with validation. After upgrading, the not required fields,
> are
> suddenly required.
> Just a part of the code:
>
>
> $this->inputFilter = new InputFilter();
> $factory = new InputFactory();
>
> $this->inputFilter->add(
> $factory->createInput(
> array(
>  'name'   => 'website',
>  'required'   => false,
>  'filters'=> array(
>  array('name' => 'StripTags'),
>  ),
> 'validators'  => array(
> array(
> 'name'  => 'Uri',
> 'options'   => array(
> 'uriHandler' => "\Zend\Uri\Http",
> 'messages'   => array(
> Uri::NOT_URI => "The input does not
> appear to be a valid Url",
> )
> )
> )
> )
> )
> )
> );
>
>
> I found something in the 'Form' class, 'attachInputFilterDefaults' method.
> Fields like 'email', 'url' are instances of InputProviderInterface and then
> he gets getInputSpecification() ... And that will overwrite my settings. I
> can fix this with setting 'preferFormInputFilter' on true. But I didn't
> have
> to do that in 2.2.2 so ...
>
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/zend-framework-2-2-3-non-required-form-fields-not-working-anymore-tp4660795.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] Redirecting all requests to one route

2013-08-07 Thread Michael Gooden
Hi Tony,

Create a segment route of '/*', and make sure it is registered last. This
will catch all requests that could not be routed by existing routes.

Cheers,

Michael


On 8 August 2013 00:53, tonystamp  wrote:

> Hey all, i'm wondering if there's a way to redirect all requests to a
> single
> route?
>
> I am working on a site and want to upload the work-in-progress page, and
> have all requests sent to that route that displays that page.
>
> When i tried editing my .htaccess to send all requests to that page it was
> throwing up a 404, presumably because the request was not going through the
> framework.
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Redirecting-all-requests-to-one-route-tp4660699.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] Change 404.phtml layout

2013-07-29 Thread Michael Gooden
I would hook into the dispatch error event, and change the layout there.


On 30 July 2013 08:52, Ross  wrote:

> Hello.
>
> Currently 404.phtml is rendered using layout/layout.phtml. I want to
> change it to layout/clean.phtml. What is the proper way of doing that?
>
> Thank you.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


[fw-general] Re: [zf-contributors] Survey: to composer or not to composer

2013-05-30 Thread Michael Gooden
On 30 May 2013 22:45, Matthew Weier O'Phinney  wrote:

> 
> Composer simply... simplifies... usage.
>

I think this is the most important thing for me.

While the concept of libraries existed for Composer and ZF2, I usually
ended up either writing my own code to do the same thing or using chopped
up bits of libraries I found.

Composer has really improved the way I work, to such an extent that all new
projects I am doing have so little code written by me I feel like I am
scamming the client :p

I still use Zend\Loader for the internal application modules that will
never touch another project. My ZF2 is loaded via composer.

Regards,

Michael Gooden


Re: [fw-general] [zf2] Help me understand routing

2013-05-28 Thread Michael Gooden
Hi Xander,

Matus is correct, routes are examined in LIFO order by default, unless you
specify an explicit priority. This is important to remember when adding
routes in modules, as the order the modules are loaded in your Application
could affect your routing setup.

Cheers,

Michael Gooden


On 28 May 2013 03:44, Matus Zeman  wrote:

> Have you tried adding 'create' route after 'profile' one?
>
> Matus
>
>
> On 28 May 2013 08:41, Xander Guzman  wrote:
>
> > I have the following route defined
> >
> > 'campaigns' => array(
> > 'type'=> 'Zend\Mvc\Router\Http\Literal',
> > 'options' => array(
> > 'route'=> 'campaigns',
> > 'defaults' => array(
> > 'controller' =>
> > 'Application\Controller\Campaigns',
> > 'action' => 'index',
> > ),
> > ),
> > 'may_terminate' => true,
> > 'child_routes' => array(
> > 'create' => array(
> > 'type'  =>
> 'Zend\Mvc\Router\Http\Literal',
> > 'options' => array(
> > 'route'  => '/create',
> > 'action' => 'create',
> > ),
> > ),
> > 'profile' => array(
> > 'type'=>
> > 'Zend\Mvc\Router\Http\Segment',
> > 'options' => array(
> > 'route'=> '/:campaign-slug',
> > 'defaults' => array(
> > 'action' => 'campaign',
> > ),
> > ),
> > 'may_terminate' => true,
> > 'child_routes' => array()
> > ),
> >
> > My problem is the way I'm understanding it if I type in /campaigns/create
> > it should map to /create and if I enter anything else
> > /campaigns/foofoobunny that should match the /:campaign-slug route.
> Problem
> > is that it doesn't work, why is this? How could I make it so if I define
> an
> > explicit route it will match and if it doesn't it falls back to this
> > default dynamic route?
> >
>


Re: [fw-general] Re: zf2 - one/many-to-many relationships

2013-05-21 Thread Michael Gooden
Hey all,

Just to butt in here, this is how I do it:

*Hypothetical situation:*
*Entities:*
PhoneNumber
Company
Person
*Relations:*
Companies can have many PhoneNumbers
Persons can have many PhoneNumbers
The same PhoneNumber can belong to multiple Companies
The same PhoneNumber can belong to multiple Persons
The same PhoneNumber can belong to Company(s) and Person(s) at the same
time.
*Tables:*
phone_number (phone_id, ...)
company (company_id, ...)
person (person_id, ...)
company_phone (company_id, phone_id)
person_phone (person_id, phone_id)
*Mappers:
*
CompanyMapper
- find($id)
PersonMapper
- find($id)
PhoneMapper
- find($id)
- findByCompany($companyId) [does a join on phone_number and company_phone]
- findByPerson($personId) [does a join on phone_number and person_phone]

My notes:
I keep the findBy* in the PhoneMapper, because I do object hydration of the
Phone object, so it makes sense to do these queries here.

FYI, I use the AbstractDbMapper from ZfcBase. It works great for doing your
own object management.

Hope this helps.

Cheers,

Michael Gooden


On 22 May 2013 01:54, tonystamp  wrote:

> ok, so you have one mapper that communicates with two seperate tables (even
> if the second table just contains, for instance, 2 columns (foreign keys))?
> So i'm assuming that is two seperate TableGateway instances? Or you just
> have an adapter with custom sql queries?
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/zf2-one-many-to-many-relationships-tp4659910p4660088.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] Handling query string params within ZF2

2013-05-21 Thread Michael Gooden
Hi Vaclav,

With ZF2 query params are now first class citizens with regards to routing.

If you are assembling your outgoing urls in your controller or view, using
the url helpers, you can add query parameters like this:

```
$from = 0;
$to = 100;
$myUrl = $this->url('route-name', array(/*params*/), array('query' =>
array('fPriceFrom'=> $from, 'fPriceTo' => $to)));
```

This should work to *create* the query urls.

In order to get the values of parameters, you can do this:

```
$from = $this->getRequest()->getQuery('fPriceFrom', false);
$to = $this->getRequest()->getQuery('fPriceTo', false);
if ($from && $to) {
//we have from and to, do special query here
} else {
//no params, do default search
}
```

Hopefully, this helps. Hit me up if you get stuck.

Cheers,

Michael Gooden


On 22 May 2013 07:53, Václav Vaník  wrote:

> Hi,
>
> what is the best practise for handling query string params?
>
> In ZF1 I have filter form, submit with POST, then redirect with GET and
> final URL is something like: /product/index/fPriceFrom/0/fPriceTo/100
>
> select product where price is between 0 and 100. With magic default route,
> it was easy. I write simply in view script something like
>
> url(array('action' => 'add')); ?>">add
> product
>
> As I see in ZF2, default route is deprecated. I have to create routes I
> need. Ok, no problem. It makes me sense. But how to easy handle query
> string
> params? Should I write own view helper? Whats the suggested way?
>
> Thx.
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Handling-query-string-params-within-ZF2-tp4660091.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] Modules, the EventManager, and the SharedEventManager

2013-05-10 Thread Michael Gooden
Hi David,

It should not be firing twice, however you are trying to use the shared
event manager the wrong way.

If you want to have a listener fire for EVERY dispatch ever, then just
attach to normal event manager on EVENT_DISPATCH in one place. If you
attach it in the MyModule it will still fire when you access a controller
in the Application module. Is that what you need?

Cheers,

Michael


On 10 May 2013 15:01, David Muir  wrote:

> Michael,
>
> Thanks for the explanation. It does explain the issue I have having.
>
> So the gist is:
>
> $sharedEvents->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH
>
>
> means that this even will only be triggered if the context is that
> namespace. So the one in Application will fire if the context is
> "Application" and the one in MyModule will fire if the context is
> "MyModule".
>
> So as an experiment, in Application I tried attaching a listener to
> 'MyModule' instead of __NAMESPACE__ and it work as expected. It only fires
> when hitting a controller in MyModule.
>
> But what if I want to attach something that is triggered in all contexts
> on the dispatch event? I tried using the * wildcard, but now the shared
> listeners get hit twice:
>
>  shared event listener from application module called
> shared event listener from my module called
> event listener from application module called
> event listener from my module called
> shared event listener from application module called
> shared event listener from my module called
>
> If my understanding is correct, this happens because there are two
> EventManager involved. First is the Application's EventManager, which first
> triggers the shared events, then triggers the local events. Then the
> controller itself triggers MvcEvent::EVENT_DISPATCH on its own EventManager
> instance when the controller's dispatch() method gets called. This in turn
> triggers the shared events a 2nd time.
>
> I guess I got exactly what I asked for, but wasn't
> expecting MvcEvent::EVENT_DISPATCH to be triggered twice. Kind of feels
> wrong...
>
> Cheers,
> David
>
> On 10/05/2013, at 4:46 PM, Michael Gooden 
> wrote:
>
> Hi David,
>
> Keep in mind that you are working with the Zend\Mvc\Application's
> EventManager instance. Try and follow the code execution in the
> Application::run() function, to see when and why different events fire.
>
> I would hazard a guess and say that you are accessing a controller in the
> MyModule, and not in the main Application module. If you run a controller
> from the Application module, you will then see the 'shared event from
> application' message show instead of from mymodule. The reason this is
> happening is because the shared event manager listener you are attaching is
> listening for the event identifier of __NAMESPACE__. When the dispatch
> event gets called against a controller under MyModule, only the listener
> tied to the namespace of that controller will be fired. The reason you will
> always see both normal event listener messages is because those listeners
> are both attached to the dispatch event.
>
> I feel I am failing at explaining this, can you add me on Skype?
>
> Cheers,
>
> Michael Gooden
>
>
> On 10 May 2013 03:41, David Muir  wrote:
>
>> I'm getting some weird behaviour with the EventManager and
>> SharedEventManager when used in the Application module vs other modules.
>>
>> Application Module:
>>
>> public function onBootstrap(MvcEvent $e)
>> {
>> //$e->getApplication()->getServiceManager()->get('translator');
>> $eventManager= $e->getApplication()->getEventManager();
>> $moduleRouteListener = new ModuleRouteListener();
>> $moduleRouteListener->attach($eventManager);
>>
>> $eventManager->attach(MvcEvent::EVENT_DISPATCH, function ($event){
>> echo 'event listener from application module called' .
>> PHP_EOL;
>> });
>>
>> $sharedEvents = $eventManager->getSharedManager();
>>
>> $sharedEvents->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH,
>> function ($event){
>> echo 'shared event listener from application module called'.
>> PHP_EOL;
>> });
>>
>> }
>>
>>
>> My Module:
>>
>> public function onBootstrap(\Zend\EventManager\EventInterface $e)
>> {
>>
>> $eventManager= $e->getApplication()->getEventManager();
>> $sharedEvents = $eventManager-> getSharedManager();
>>
>> $eventMana

Re: [fw-general] Modules, the EventManager, and the SharedEventManager

2013-05-09 Thread Michael Gooden
Hi David,

Keep in mind that you are working with the Zend\Mvc\Application's
EventManager instance. Try and follow the code execution in the
Application::run() function, to see when and why different events fire.

I would hazard a guess and say that you are accessing a controller in the
MyModule, and not in the main Application module. If you run a controller
from the Application module, you will then see the 'shared event from
application' message show instead of from mymodule. The reason this is
happening is because the shared event manager listener you are attaching is
listening for the event identifier of __NAMESPACE__. When the dispatch
event gets called against a controller under MyModule, only the listener
tied to the namespace of that controller will be fired. The reason you will
always see both normal event listener messages is because those listeners
are both attached to the dispatch event.

I feel I am failing at explaining this, can you add me on Skype?

Cheers,

Michael Gooden


On 10 May 2013 03:41, David Muir  wrote:

> I'm getting some weird behaviour with the EventManager and
> SharedEventManager when used in the Application module vs other modules.
>
> Application Module:
>
> public function onBootstrap(MvcEvent $e)
> {
> //$e->getApplication()->getServiceManager()->get('translator');
> $eventManager= $e->getApplication()->getEventManager();
> $moduleRouteListener = new ModuleRouteListener();
> $moduleRouteListener->attach($eventManager);
>
> $eventManager->attach(MvcEvent::EVENT_DISPATCH, function ($event){
> echo 'event listener from application module called' . PHP_EOL;
> });
>
> $sharedEvents = $eventManager->getSharedManager();
>
> $sharedEvents->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH,
> function ($event){
> echo 'shared event listener from application module called'.
> PHP_EOL;
> });
>
> }
>
>
> My Module:
>
> public function onBootstrap(\Zend\EventManager\EventInterface $e)
> {
>
> $eventManager= $e->getApplication()->getEventManager();
> $sharedEvents = $eventManager-> getSharedManager();
>
> $eventManager->attach(MvcEvent::EVENT_DISPATCH, function ($event){
> echo 'event listener from my module called'.PHP_EOL;
> });
>
> $sharedEvents->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH,
> function ($event){
> echo 'shared event listener from my module called'.PHP_EOL;
> });
>
> }
>
>
>
> outputs:
>
> shared event listener from my module called
> event listener from application module called
> event listener from my module called
>
>
> Can someone explain why the shared event listener attached via the
> Application module never gets called?
>
> Secondary to this, I've seen some examples attach listeners to the shared
> manager, and others attach them to the event manager. When do I use one
> instead of the other?
>
> Cheers,
> David
>
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] Can't figure out zend route error.

2013-05-08 Thread Michael Gooden
Hi Xander,

There is no such route called 'logout'.

As your route you are trying to access is nested under the 'home' route,
you have to reference the route as 'home/logout' where necessary.

Also, you only need to include 'may_terminate' => true, if your route has
child_routes AND you want to be able to use the parent route. Using it for
routes on tips is unnecessary.

Cheers,

Michael Gooden


On 9 May 2013 04:37, Xander Guzman  wrote:

> I'm getting: Route with name "logout" not found' and I can't figure out
> why, below you'll find a copy of my route configuration any help would be
> appreciated.
>
> 'router' => array(
> 'routes' => array(
> 'home' => array(
> 'type' => 'Zend\Mvc\Router\Http\Literal',
> 'options' => array(
> 'route'=> '/',
> 'defaults' => array(
> 'controller' => 'Application\Controller\Index',
> 'action' => 'index',
> ),
> ),
> 'may_terminate' => true,
> 'child_routes' => array(
> 'campaigns' => array(
> 'type'=> 'Zend\Mvc\Router\Http\Literal',
> 'options' => array(
> 'route' => 'campaigns',
> 'defaults' => array(
> 'controller' =>
> 'Application\Controller\Campaigns',
> 'action' => 'index',
> ),
> ),
> 'may_terminate' => true,
> 'child_routes' => array(
> 'campaign-profile' => array(
> 'type'=>
> 'Zend\Mvc\Router\Http\Segment',
> 'options' => array(
> 'route'=> '/:campaign-slug',
> 'defaults' => array(
> 'action' => 'campaign',
> ),
> ),
> 'may_terminate' => true,
> ),
> ),
> ),
> 'users' => array(
> 'type' => 'Zend\Mvc\Router\Http\Literal',
> 'options' => array(
> 'route' => 'users',
> 'defaults' => array(
> 'controller' =>
> 'Application\Controller\Users',
> 'action' => 'users',
> ),
> ),
> 'may_terminate' => true,
> ),
> 'signup' => array(
> 'type' => 'Zend\Mvc\Router\Http\Literal',
> 'options' => array(
> 'route' => 'signup',
> 'defaults' => array(
> 'controller' =>
> 'Application\Controller\Users',
> 'action' => 'signup',
> ),
> ),
> 'may_terminate' => true,
> ),
> 'login' => array(
> 'type' => 'Zend\Mvc\Router\Http\Literal',
> 'options' => array(
> 'route' => 'login',
> 'defaults' => array(
> 'controller' =>
> 'Application\Controller\Users',
> 'action' => 'login',
> ),
> ),
> 'may_terminate' => true,
> ),
> 'logout' => array(
> 'type' => 'Zend\Mvc\Router\Http\Literal',
> 'options' => array(
> 'route' => 'logout',
> 'defaults' => array(
> 'controller' =>
> 'Application\Controller\Users',
> 'action' => 'logout',
> ),
> ),
> 'may_terminate' => true,
> ),
> 'sessions' => array(
> 'type' => 'Zend\Mvc\Router\Http\Literal',
> 'options' => array(
> 'route' => 'sessions',
> 'defaults' => array(
> 'controller' =>
> 'Application\Controller\Users',
> 'action' => 'sessions',
> ),
> ),
> 'may_terminate' => true,
> ),
> ),
> ),
> ),
> ),
>


Re: [fw-general] Begginer friendly tutorial

2013-05-06 Thread Michael Gooden
Step 3: Learn Composer
Step 4: Use publicly available modules to save time and effort
Step 5: ...
Step 6: PROFIT!


On 6 May 2013 12:58, Jason P.  wrote:

>
> Good one. So far this is what I get:
>
> First step: "Get started" guide
> Second step: master EventManager and ServiceManager
>
>
>
> El 06/05/13 12:26, Marco Pivetta escribió:
>
>  Jason, I can suggest you to learn the EventManager and ServiceManager
>> components in depth. Once you got that, the rest of Zend\Mvc is code that
>> glues those two concepts together ;)
>>
>> http://blog.evan.pro/**introduction-to-the-zend-**
>> framework-2-servicemanager<http://blog.evan.pro/introduction-to-the-zend-framework-2-servicemanager>
>> http://zf2.readthedocs.org/en/**develop/modules/zend.service-**
>> manager.intro.html<http://zf2.readthedocs.org/en/develop/modules/zend.service-manager.intro.html>
>> http://zf2.readthedocs.org/en/**develop/modules/zend.event-**
>> manager.event-manager.html<http://zf2.readthedocs.org/en/develop/modules/zend.event-manager.event-manager.html>
>>
>> Really, once you grasp those two, the rest is just fancy terms that are
>> mostly based on that stuff :)
>>
>>
>> Marco Pivetta
>>
>> http://twitter.com/Ocramius
>>
>> http://ocramius.github.com/
>>
>>
>> On 6 May 2013 12:22, Jason P.  wrote:
>>
>>
>>> I know, but it seemed a bit short. Maybe I've to give it a chance ;)
>>>
>>> Thanks!
>>>
>>>
>>>
>>> El 06/05/13 08:43, Michael Gooden escribió:
>>>
>>>   Hi Jason,
>>>
>>>>
>>>> There is actually a tutorial in the official documentation:
>>>> http://zf2.readthedocs.org/en/latest/index.html#userguide<http://zf2.readthedocs.org/en/**latest/index.html#userguide>
>>>> <**http://zf2.readthedocs.org/en/**latest/index.html#userguide<http://zf2.readthedocs.org/en/latest/index.html#userguide>
>>>> >
>>>>
>>>> It was originally written by Rob Allen, and it should be a very good
>>>> starting point for you.
>>>>
>>>> Regards,
>>>>
>>>> Michael Gooden
>>>>
>>>>
>>>> On 5 May 2013 21:14, Jason P.  wrote:
>>>>
>>>>
>>>>  Hi everyone.
>>>>>
>>>>> I'm in the mood of learning a PHP framework and I've been told that ZF
>>>>> is
>>>>> one of the best thanks to its modularity and flexibility, but at the
>>>>> cost
>>>>> of not being easy for begginers.
>>>>>
>>>>> What approach would you recommend to start learning this tool? I'm a
>>>>> programming student and I'm familiarized with PHP, Java, OOP and MVC
>>>>> pattern. Also, I've completed a brief tutorial about building a little
>>>>> MVC
>>>>> framework from scratch.
>>>>>
>>>>> Of course I know there's an official documentation with some examples,
>>>>> but
>>>>> I was searching for something more comprehensive but yet step by step,
>>>>> and
>>>>> not only a reference guide of the platform.
>>>>>
>>>>>
>>>>> Thanks!
>>>>>
>>>>> --
>>>>> List: fw-general@lists.zend.com
>>>>> Info: 
>>>>> http://framework.zend.com/**archives<http://framework.zend.com/archives>
>>>>> <http://framework.**zend.com/**archives<http://framework.zend.com/**archives>
>>>>> >
>>>>> <http://framework.**zend.com/**archives <http://zend.com/archives><
>>>>> http://framework.**zend.com/archives<http://framework.zend.com/archives>
>>>>> >
>>>>>
>>>>>>
>>>>>>  Unsubscribe: fw-general-unsubscribe@lists.**zend.com
>>>>> >>>> unsubscr...@lists.zend.com 
>>>>> 
>>>>> >>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>> --
>>> List: fw-general@lists.zend.com
>>> Info: 
>>> http://framework.zend.com/archives<http://framework.zend.com/**archives>
>>> <http://framework.**zend.com/archives<http://framework.zend.com/archives>
>>> >
>>> Unsubscribe: fw-general-unsubscribe@lists.zend.com>> unsubscr...@lists.zend.com >
>>>
>>>
>>>
>>>
>>
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/**archives<http://framework.zend.com/archives>
> Unsubscribe: 
> fw-general-unsubscribe@lists.**zend.com
>
>
>


Re: [fw-general] Begginer friendly tutorial

2013-05-05 Thread Michael Gooden
Hi Jason,

There is actually a tutorial in the official documentation:
http://zf2.readthedocs.org/en/latest/index.html#userguide

It was originally written by Rob Allen, and it should be a very good
starting point for you.

Regards,

Michael Gooden


On 5 May 2013 21:14, Jason P.  wrote:

>
> Hi everyone.
>
> I'm in the mood of learning a PHP framework and I've been told that ZF is
> one of the best thanks to its modularity and flexibility, but at the cost
> of not being easy for begginers.
>
> What approach would you recommend to start learning this tool? I'm a
> programming student and I'm familiarized with PHP, Java, OOP and MVC
> pattern. Also, I've completed a brief tutorial about building a little MVC
> framework from scratch.
>
> Of course I know there's an official documentation with some examples, but
> I was searching for something more comprehensive but yet step by step, and
> not only a reference guide of the platform.
>
>
> Thanks!
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/**archives<http://framework.zend.com/archives>
> Unsubscribe: 
> fw-general-unsubscribe@lists.**zend.com
>
>
>


Re: [fw-general] Re: Rest library missing in Zend 2

2013-04-26 Thread Michael Gooden
Hi Liudas,

The Zend/Rest/* library is unfortunately dead...

... BUT we have an even better solution: PhlyRestfully, created by none
other than Matthew Weier O'Phinney himself! Find it
here
.

The README has lots of help, but if you get stuck, please send a mail my
way.

Cheers,

Michael


On 26 April 2013 13:04, Liudas  wrote:

> Hi Michael,
>
> I would like to provide my own REST-based api, extending
> Zend/Rest/Server.php, as it was in 1 version.
>
> Tahnk you in advance,
> Liudas
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Rest-library-missing-in-Zend-2-tp4659838p4659840.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] Rest library missing in Zend 2

2013-04-26 Thread Michael Gooden
Hi Liudas,

It depends on what kind of REST you want to be doing.

Do you want to consume a RESTful service, or provide your own REST-based
API?

Regards,

Michael Gooden


On 26 April 2013 12:48, Liudas  wrote:

> Hallo,
>
> I have downloaded Zend 2.1.5 full framewrok and found that Rest library is
> misising.
> Is it not supported anymore?
>
> Thank you in advance,
> Reto
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Rest-library-missing-in-Zend-2-tp4659838.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] Setting HTTP headers in ZF2

2013-03-24 Thread Michael Gooden
I got curious, so I implemented it myself. I have this in my
Application/module.php onBootstrap() function, however you can place it
where you wish, as long as you attach the listener to the application's
main event manager.

$eventManager= $e->getApplication()->getEventManager();
$eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_FINISH,
function(\Zend\Mvc\MvcEvent $e) {
$response = $e->getResponse();
if ($response instanceof \Zend\Http\AbstractMessage) {
$header = new \Zend\Http\Header\ContentType();
$header->value = 'text/html; charset=utf-8';
$response->getHeaders()->addHeader($header);
}
}, 500);

Let me know if this works out for you.

Regards,

Michael Gooden


On 24 March 2013 14:13, Michael Gooden  wrote:

> Hi Ross,
>
> I would think a listener somewhere along the MvcEvent flow would be
> appropriate. Have a look here:
> http://zendframework2.de/en/cheat-sheet.html
>
> Without looking at the code I would suggest trying to attach a listener to
> MvcEvent::EVENT_FINISH that will grab the response from the event and
> modify the Content-Type header.
>
> If you don't come right swing me a mail and we can work it out together.
>
> Regards,
>
> Michael Gooden
>
>
> On 24 March 2013 13:07, Ross  wrote:
>
>> Hello
>>
>> I noticed in telnet that my server returns:
>> Content-Type: text/html
>>
>> I want it to include charset=utf-8 for every page.
>>
>> How can I do that?
>>
>> --
>> List: fw-general@lists.zend.com
>> Info: http://framework.zend.com/archives
>> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>>
>>
>>
>


Re: [fw-general] Setting HTTP headers in ZF2

2013-03-24 Thread Michael Gooden
Hi Ross,

I would think a listener somewhere along the MvcEvent flow would be
appropriate. Have a look here: http://zendframework2.de/en/cheat-sheet.html

Without looking at the code I would suggest trying to attach a listener to
MvcEvent::EVENT_FINISH that will grab the response from the event and
modify the Content-Type header.

If you don't come right swing me a mail and we can work it out together.

Regards,

Michael Gooden


On 24 March 2013 13:07, Ross  wrote:

> Hello
>
> I noticed in telnet that my server returns:
> Content-Type: text/html
>
> I want it to include charset=utf-8 for every page.
>
> How can I do that?
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] Would you use the Event-Manager for caching purposes?

2013-03-15 Thread Michael Gooden
Hi Ralf,

In addition to that example code, I also do the following:

In my update/save/etc method, I have a __FUNCTION__.'.post' event fired,
which my CacheListener implementation attaches to so I can overwrite the
existing cache with new value. This way I can have an aggressive caching
strategy (TTL: 1 hour or longer), while avoiding returning stale data from
the cache.

Additionally, you can use this pattern to implement a simple multi level
cache.
I can setup a Memcached CacheListener, with TTL of 5 minutes, and also a
File CacheListener with TTL of 20 minutes. If you attach them with your
prios correctly, you will return from memcache if available, otherwise from
file cache.

Now get some sleep.

Regards,

Michael Gooden


On 16 March 2013 00:29, Ralf Eggert  wrote:

> LOL,
>
> Just found, that the docs show a nicely example for using the Event
> Manager for caching...
>
>
> http://zf2.readthedocs.org/en/latest/modules/zend.event-manager.event-manager.html#examples
>
> I should go to bed. Never mind my mail.
>
> Good night.
>
> Ralf
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


Re: [fw-general] zend 2 AbstractRestfulController how to manage Exception

2013-03-15 Thread Michael Gooden
Hi wisher,

Matthew Weier O'Phinney has put together a great library called PhlyRestfully. 
It handles among other things, returning a standardised API-Problem response 
for exceptions.

Contact me directly if you need help implementing it.

Regards,

Michael Gooden

-Original Message-
From: whisher 
Date: Fri, 15 Mar 2013 11:18:11 
To: 
Subject: [fw-general] zend 2 AbstractRestfulController how to manage Exception
Hi,
I'm wondering how to manage Exception in
AbstractRestfulController 
I set up the
http://hounddog.github.com/blog/getting-started-with-rest-and-zend-framework-2/
project and I've tried with
public function create($data)
{
try{
$artist = $this->getRequest()->getPost('artist', null);
$title = $this->getRequest()->getPost('title', null);
$album = new Album();
$album->exchangeArray(array('artist'=>$artist,'title'=>$title));
$id = $this->getAlbumTable()->saveAlbum($album);
return $this->get($id);  
 }
 catch (Exception $e) {
return new JsonModel(array(
'meta' =>array(
'code'=>500,
'error-num'=>$e->getCode(),
'error-msg'=>$e->getMessage(),
)
));
}
   
 }
and also with
public function saveAlbum(Album $album)
{
try{
$this->tableGateway->insert($data);
$id = $this->tableGateway->getLastInsertValue();
return $id;
 }
 catch (Exception $e) {
return new JsonModel(array(
'meta' =>array(
'code'=>500,
'error-num'=>$e->getCode(),
'error-msg'=>$e->getMessage(),
)
));
}
 }

but I keeping on having the all Exception stack
I mean with the whole layout.

My goal is get a json like
{
  "meta": {
"error_type": "error type",
"code": 400,
"error_message": "error msg"
  }
}

What's the right way ?



--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/zend-2-AbstractRestfulController-how-to-manage-Exception-tp4659479.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com