[fw-general] Dynamic form validation

2015-10-06 Thread Greg Frith
Hi all,

An issue I come across reasonably regularly with ZF2 forms is dynamically 
setting validation rules based on other elements in the form.

For example, let’s say I have a checkout form, where I capture users personal 
details and payment details.  So would could maybe have a PaymentForm, with a 
PaymentDetails fieldset and a PersonalDetails fieldset.  Each fieldset could 
have its own input filter and hence validate itself when the form is validated. 
 All good.

Now, what if we want the user to either be able to pay via credit card or 
PayPal.  For this we might take the PaymentDetails fieldset further, by adding 
two sub fieldsets, CreditCardDetails and PayPal details.  Within the 
PaymentDetails fieldset there might be a select option which allows the user to 
choose a credit card type or PayPal.  If they choose PayPal, any values in the 
CreditCard fieldset are irrelevant, and shouldn’t be validated.

I belive I should be using validation groups for this, but at what point do I 
set the validation group, should I do this in my controller action where the 
form is submitted, but before it is validated:  Essentially getting the 
submitted value for the ‘payment type’ select option and manipulating the form 
input groups accordingly??  This I believe will work, but it would seem to tie 
the forms underlying logic to the controller a bit too much.

Am I missing something, or would this be the ‘recommended way’?

Cheers,
Greg.



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




[fw-general] Form collections and dependencies

2015-05-27 Thread Greg Frith
 work around.  In actual fact, there isn't much validation 
that can be done here, the user selects options for which there is always a 
default value.  

---
2015-05-27T10:43:00+01:00 DEBUG (7): post data is Zend\Stdlib\Parameters Object
(
[storage:ArrayObject:private] => Array
(
[divertsFieldset] => Array
(
[diverts] => Array
(
[0] => Array
(
[id] => 40
[destinationSetId] => 6
)

[1] => Array
(
[id] => 41
[destinationSetId] => 9
    )

    [2] => Array
(
[id] => 42
[destinationSetId] => 19
)

[3] => Array
(
[id] => 43
[destinationSetId] => 11
)

)

)

)

)
2015-05-27T10:43:00+01:00 DEBUG (7): form is not validArray
(
[divertsFieldset] => Array
(
[diverts] => Array
(
[5] => Array
(
[destinationSetId] => Array
(
[isEmpty] => Value is required and can't be 
empty
)

)

)

)

)

---

Cheers,
Greg.





























-- 
Greg Frith
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)



Re: [fw-general] Validating route params are loading entities from route params

2015-05-22 Thread Greg Frith
Thanks for your advice and the link Daniel.  I'll take a look sounds like a 
good option.  To save the controller also having to do a similar DB query to 
pull the entity back, I'm guessing that I could store it in a session variable 
from within the preDispatch.  I'm also using Doctrine, so another alternative 
would be to just query again and allow the doctrine entity cache to take care 
of this 'caching' element.

Cheers,  

Greg

On Friday, 22 May 2015 at 14:20, Daniel Latter wrote:

> Hi Greg,
>  
> You could register a preDispatch event in your module's module.php.
>  
> For example, we use a preDispatch event to check if a user is logged in when 
> accessing certain pages.
>  
> You could easily check for a valid "TopEvent" from inside your preDispatch 
> method, and redirect accordingly.
>  
> For example:  
>  
> https://gist.github.com/rettal/4a6e9ae973ed09fae382
>  
> The example above checks if logged in, but can easily be adapted to suit your 
> needs I think,
>  
> Daniel.
>  
>  
>  
>  
> On 22 May 2015 at 13:35, Greg Frith  (mailto:gfr...@gmail.com)> wrote:
> > Hi all,
> >  
> > I'm developing a ZF2 site which has a booking process for events.  The 
> > booking process part of the site has consistent URLs like:
> >  
> > http://mysite.com/book/TopEvent/availability
> > http://mysite.com/book/TopEvent/seats
> > http://mysite.com/book/TopEvent/payment
> > http://mysite.com/book/TopEvent/confirm
> >  
> > I have an event entity stored in a relational database, that amongst other 
> > things has a 'url_name' field which is used to reference the event in urls, 
> > a bit nicer than using plain old ids.  So in the above URL examples, the 
> > 'url_name' is TopEvent.
> >  
> > I have a controller names BookingController which has all the actions for 
> > the above sample URLs, for example seatsAction.  Currently, at the start of 
> > each action I'm having to pull the 'url_name' parameter from the params, 
> > and search for the event by url_name in my database.  If no event is found, 
> > I return 404.  I have a controller plugin to help with this, and the code 
> > looks something like:
> >  
> > public function seatsAction()
> > {
> > // Check we have valid event
> > if (!$event = $this->SIL()->getEventFromRoute()) {
> > $this->logger->err("On seats page with no valid event, returning 404");
> > $this->getResponse()->setStatusCode(404);
> > return;
> > }
> > ….
> >  
> >  
> > If I have 8 actions in my booking controller, this gets a bit repetitive.  
> > Essentially, I'd like a way to return a 404 on all routes/action where the 
> > event cannot be found.
> >  
> > And finally to the crux of my mail, I'd like some advice on the best way to 
> > do this?
> >  
> > Perhaps I should be listening for some event within my controller 
> > (dispatch?) and doing my check here (can I return 404 from this).
> >  
> > Or should I override the parent controllers onDispatch event?
> >  
> > Or, could I take this further and create a custom router that validates 
> > this part of the URL against the database?  If I went down this route, 
> > could that custom router also load the entity for use within that request?
> >  
> > Any advise greatly appreciated.
> >  
> > Cheers,
> > Greg.
> >  
> > :wq



[fw-general] Validating route params are loading entities from route params

2015-05-22 Thread Greg Frith
Hi all,  

I'm developing a ZF2 site which has a booking process for events.  The booking 
process part of the site has consistent URLs like:

http://mysite.com/book/TopEvent/availability
http://mysite.com/book/TopEvent/seats
http://mysite.com/book/TopEvent/payment
http://mysite.com/book/TopEvent/confirm

I have an event entity stored in a relational database, that amongst other 
things has a 'url_name' field which is used to reference the event in urls, a 
bit nicer than using plain old ids.  So in the above URL examples, the 
'url_name' is TopEvent.

I have a controller names BookingController which has all the actions for the 
above sample URLs, for example seatsAction.  Currently, at the start of each 
action I'm having to pull the 'url_name' parameter from the params, and search 
for the event by url_name in my database.  If no event is found, I return 404.  
I have a controller plugin to help with this, and the code looks something like:

public function seatsAction()
{
// Check we have valid event
if (!$event = $this->SIL()->getEventFromRoute()) {
$this->logger->err("On seats page with no valid event, returning 404");
$this->getResponse()->setStatusCode(404);
return;
}
….


If I have 8 actions in my booking controller, this gets a bit repetitive.  
Essentially, I'd like a way to return a 404 on all routes/action where the 
event cannot be found.

And finally to the crux of my mail, I'd like some advice on the best way to do 
this?

Perhaps I should be listening for some event within my controller (dispatch?) 
and doing my check here (can I return 404 from this).

Or should I override the parent controllers onDispatch event?

Or, could I take this further and create a custom router that validates this 
part of the URL against the database?  If I went down this route, could that 
custom router also load the entity for use within that request?

Any advise greatly appreciated.

Cheers,
Greg.

:wq

Re: [fw-general] Route summary tool

2014-02-20 Thread Greg
Isn't that Apigility?


On Thu, Feb 20, 2014 at 7:29 PM, David Muir  wrote:

> Has anyone created a tool to list a summary of routes available in
> an application?
> What I'm after is a table showing the route name, the route itself, the
> type and the available parameters and constraints without having to
> mentally parse the various arrays from each module to find the route I'm
> after.
>
> Cheers,
> David
>
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


-- 
Greg


Re: [fw-general] Rasmus Lerdorf opinion on PHP frameworks: "They all suck!"

2014-02-06 Thread Greg
My first impression is that the route event should only return a route
matched (SRP?); its simpler and would allow the route match to be retrieved
from the service manager without needing a route event (or if there is no
matched route). The service manager could then have a default route match
configured, 404 ?.


On Thu, Feb 6, 2014 at 3:05 AM, Marco Pivetta  wrote:

> On 6 February 2014 00:57, franz de leon  wrote:
>
> > reading the article, it made me think about routing that it is indeed
> > pretty costly. what do you think of an adapter in zf2 that would actually
> > generate .htaccess (mod rewrite) files as a feature? in production this
> > will work in a caching way to step over the php routing logic.
> >
>
> Routing is still a feature that the framework should handle. There's a
> couple of things going on here:
>  - if routing is managed by different files, you end up having multiple
> application entry points (duplication)
>  - routing is no big performance deal, and DASPRiD is even working on
> making it faster even if it usually accounts for less than 5% of the page
> load time
>  - moving routing to files denies custom routes, which is the real power of
> a router. Routing is not just a pattern matching mechanism, you can plug
> any logic into a route. People tend to throw "not found" exceptions in
> controllers - I think that is a mistake.
>  - moving routing out of your application requires your developers to have
> more knowledge about the environment the application runs in, and reduces
> portability
>  - moving routing out of your application makes changing routes assembling
> across your application a nightmare, requiring you to manually change a lot
> of paths whenever it is happening.
>
> So yeah, seems like the usual "squeeze performance out of it" for no big
> benefit.
> I had this discussion before with people that highly value performance, and
> I still think caching is the way to go here, instead of trying to split
> tasks among different in-homogeneous tools.
>
> If your app is THAT application critical for some paths, then you just
> rewrite your varnish config in order to deal with routing in THAT
> particular edge case, maybe serving the response from a load balanced tree
> of machines or a dedicated micro-service built with C or something  like
> that :P
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>



-- 
Greg


Re: [fw-general] What are the benefits of OO vs procedural programming for the web

2013-12-05 Thread Greg
Its about the collaboration of objects and the injection of their
dependencies; it's a lot easier and more versatile via OOP.



On Thu, Dec 5, 2013 at 3:10 PM, dennis-fedco wrote:

> I've been reading Stack Overflow on
>
> whats-the-benefit-of-object-oriented-programming-over-procedural-programming
> <
> http://programmers.stackexchange.com/questions/120019/whats-the-benefit-of-object-oriented-programming-over-procedural-programming
> >
>
> It is a good (although not the best) overview of why OO was created and how
> it can help organize and reduce errors on large cohesive projects.
> With my advance apologies to the "oh here we go again on OO vs Proc" crowd,
> I think this question needs to be asked as I personally have not really
> seen
> the side of the question I am about to ask addressed in a clear decisive
> manner.
>
> So here we go... HTTP is request/response protocol, so I do not see
> procedural programming approach to the web as being necessarily handicapped
> when OO vs Proc is considered.  So my question is:  What drives OO
> frameworks, such as ZF2/3 to be object oriented?
>
> In defense of Proc:
> Example:  for each HTTP request, each individual web page to be
> seen inside
> the browser can be written as its own mini-MVC structure just using
> straight
> PHP without the "burden" of OO, Design Patterns, etc.
>
> Granted, this sounds a little basic.  But before one protests
> prematurely,
> a lot of the "ugly thorns" of procedural programming can be taken care of.
> i.e database/model connector part can be shared among all the
> per-page-scripts, any code duplication, validation, etc, can be moved out
> into a functions library, views are separated, and you can still write
> function tests, use test driven development and so on and so forth.
>
> Granted, to write good procedural code one needs to be well
> organized and
> "behave".  Procedural code does not have to be spaghetti code. It can be
> clean, awesome, and well-separated.  This separation needs to be enforced
> by
> the programmer and the programming team, opposed to the language constructs
> themselves.  Doing so placed a tad more burden on the programmer, i.e. each
> script will need to be maintained by the programmer and the programmer will
> need to be conscious of what code needs to be changed where, in order to
> not
> write themselves into a tangles of spaghettiness.  Things such as data
> validation/cleaning, variable output, and so on will require better
> organization and code self-disciplining skills on the part of the
> programmer
> to not mess those up.  In the end, if you apply some solid organization
> skills and a good directory structure, you can write procedural code that
> is
> modular, flexible, secure, and high performing.
>
> My main point is this:  OO, with its encapsulation, and so on, is not
> really
> needed when we are dealing with "writing small scripts, one script for each
> page for HTTP's Request/Responce protocol", even when it comes to large
> projects.
> And since you are dealing with an individual page requests, the execution
> scope is small, heck you can even use global variables in the scripts, not
> that I'd recommend it, without fear of them clashing with globals in the
> other scripts - that is, natural encapsulation is already happening with
> procedural approach to HTTP at per-page level, without the need for OO.
>
> So what is it about the need for OO that drives OO frameworks such as ZF2?
> Why not spend more time on organizing the programmer instead of organizing
> the tool?
> Learning good organization skills is hard.  But so is learning OO.  Why not
> invest in better programmers, tutorials, classes, rather than the tools?
>  Is
> the driver behind OO frameworks more that there will always be disorganized
> programmers no matter what tools you use, so might as well write a better
> tool?
>
> Because, I don't think that OO is "just another flavor" of doing things in
> programming.  It is more of a way to organize the programming tool
> available
> to the programmer.
>
> In the end, is OO here just to "put/enforce some organization on fellow
> programmers, who otherwise would be too tempted/lazy/ignorant to abuse
> freedoms and powers of procedural code to create bad code"?
> Or is there any other real good solid reason for using and needing OO?
>
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/What-are-the-benefits-of-OO-vs-procedural-programming-for-the-web-tp4661285.html
> Sent from the Zend Framework mailing list archive at Nabble.com.




-- 
Greg


Re: [fw-general] Route Namespaces + InjectTemplateListener

2013-03-01 Thread Greg
>

> > Since it seems like all defined namespaces in the route config must end
> > with \Controller, I'm wondering if deriveControllerSubNamespace should
> just
> > remove the term Controller from the end of $namespace and then just
> remove
> > the first segment of the namespace (i.e the module name)?
>
> That's not a safe assumption.
>


Actually at the time, I was forgetting to update the controllers invokables
config, so yes it is not necessary to Controller at the end or at all.



>
> If I don't have many controllers, or many classes for that matter, I
> will often flatten my directory structure. As such, I might not have a
> "\Controller" subnamespace. And we make no requirements about
> appending the word "Controller" to the class, either. I've also seen
> people group a controller and its dependencies in a subnamespace
> without using a subnamespaced-module. The point is: we don't make many
> assumptions about how the code inside a module is structured -- and
> imposing something like what you're wanting would break code for a lot
> of folks.
>
>

The problem I ran into is because there _are_ assumptions being made as
specified by the code comment:

// Remove the first two elements representing the module and controller
directory.


Two things are happening prior to deriveControllerSubNamespace being called:

$module  = $this->deriveModuleNamespace($controller);
$namespace = $routeMatch->getParam(ModuleRouteListener::MODULE_NAMESPACE)

If the routing config specifies a namespace, then
deriveControllerSubNamespace is called. $module is then prepended to the
subnamespace if the derive method determines that one exists otherwise
$module is set with the entire rout config $namespace value.


Actually just now I changed the Controller namespace to Controllerx and
with the change I made it still fell into what I would of expectated:

Without the change the template path resolves to:

application/controllerx/index/index

With the change it resolves to

application/admin/controllerx/index/index


The reason why I find this desirable, is that there is only one template
stack path for all my sub-namespaces, as well as being PSR-0 compliant.



>
> In the meantime, you could create a controller or module-specific
> listener for injecting the view template name.
>


I realized that yesterday, but in this case its not desirable to overriding
it like that. It means deviating away from the standard documentation, it
would be preferred to pull the listener to use from the service config etc,
and also using a custom override could break it for other modules as you
noted.




-- 
Greg


[fw-general] Route Namespaces + InjectTemplateListener

2013-02-27 Thread Greg
Looking at the Skeletal app, I made the following changes

1. Moved the Controller director to src/Application/Admin
2. Moved the view index directory to view/application/admin.
3. Added namespace Application\Admin\Controller to the 'home' route
4. Changed the default route namespace to Application\Admin\Controller
5. Changed the invokables configuation to Application\Admin\Controller\Index
6. Created the controller
src/Application/Admin/Controller/IndexController.php

I then got the following error:

Unable to render template "application/controller/index/index";

I'm thinking this should still of worked and should look for
application/admin/index/index.

Looking at the comment in
InjectTemplateListener::deriveControllerSubNamespace

// Remove the first two elements representing the module and controller
directory.

Makes me wonder if this assumption is too rigid?

Since it seems like all defined namespaces in the route config must end
with \Controller, I'm wondering if deriveControllerSubNamespace should just
remove the term Controller from the end of $namespace and then just remove
the first segment of the namespace (i.e the module name)?

Making those changes to deriveControllerSubNamespace seems to work

protected function deriveControllerSubNamespace($namespace)
{
if (!strstr($namespace, '\\')) {
return '';
}

if ('Controller' == substr($namespace, -10)) {
$namespace = substr($namespace, 0, -11);
}

$nsArray = explode('\\', $namespace);

// Remove the first two elements representing the module and controller
directory.
$subNsArray = array_slice($nsArray, 1);
if (empty($subNsArray)) {
return '';
}
return implode('/', $subNsArray);
}


Some extra tweaking would probably be needed if the module has no namespace
(i.e. line 99 of InjectTemplateListener.php).

Or have I misunderstood something in the configuration?


-- 
Greg


Re: [fw-general] Different ZF directories depending on installation choice

2013-02-22 Thread Greg
Ok sorry ... I'm trying to catch up / understand in some regards ... my
main concern is identifying whether a commitment has to made early on to
using a composer setup and how significant of an impact it would be to
introduce later on (updating other checkouts etc). Seems like if there is a
chance of adopting composer later on then its better to start with it to
begin with.


On Fri, Feb 22, 2013 at 12:03 PM, Matthew Weier O'Phinney
wrote:

> On Fri, Feb 22, 2013 at 10:19 AM, Greg  wrote:
> > So what I'm potentially trying to achieve is
> >
> > 1. Setup the project as if it was a git clone (for the contribution
> > guidelines)
> > 2. Utilize composer in replacement for a project initialization script.
> >
> > I think the answer to my question is 'php composer.phar install
> > --prefer-source'?
>
> Yes -- "--prefer-source", or use something like "2.1.*@dev" for the
> version (which will grab from source as a git clone as well).
>
> > On Fri, Feb 22, 2013 at 9:17 AM, Matthew Weier O'Phinney <
> matt...@zend.com>
> > wrote:
> >>
> >> On Fri, Feb 22, 2013 at 9:13 AM, Greg  wrote:
> >> > Is there a way to make it resolve to the same directory?
> >>
> >> Yes -- you can setup your git submodule to point to
> >> vendor/zendframework/zendframework.
> >>
> >> However, if you do so, you'll need to setup autoloading yourself, and
> >> if you end up using composer, you have the potential for odd
> >> behavior/conflicts -- which is why we used separate directories.
> >>
> >> > On Fri, Feb 22, 2013 at 4:07 AM, Marco Pivetta 
> >> > wrote:
> >> >
> >> >> Composer is not adopted by all users, thus the two possible paths.
> What
> >> >> is
> >> >> exactly your question about then?
> >> >>
> >> >> Marco Pivetta
> >> >>
> >> >> http://twitter.com/Ocramius
> >> >>
> >> >> http://ocramius.github.com/
> >> >>
> >> >>
> >> >> On 22 February 2013 08:30, Greg  wrote:
> >> >>
> >> >>> Am I doing something wrong or are there two possible different
> >> >>> installation
> >> >>> directories for ZF2?
> >> >>>
> >> >>> Following each installation option for the skeleton application
> >> >>>
> >> >>> http://framework.zend.com/downloads/skeleton-app
> >> >>>
> >> >>> seems to lead to two different installation directories, i.e
> >> >>>
> >> >>> ZF2 or zendframework/zendframework
> >> >>>
> >> >>> It would be nice if which ever way would allow the user to explore
> >> >>> more of
> >> >>> composer's capabilities, e.g autoloading, project initialization? I
> >> >>> may of
> >> >>> missed of some configuration info?
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Greg
> >> >>>
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Greg
> >>
> >>
> >>
> >> --
> >> 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
> >>
> >>
> >
> >
> >
> > --
> > Greg
>
>
>
> --
> 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
>
>
>


-- 
Greg


Re: [fw-general] Different ZF directories depending on installation choice

2013-02-22 Thread Greg
So what I'm potentially trying to achieve is

1. Setup the project as if it was a git clone (for the contribution
guidelines)
2. Utilize composer in replacement for a project initialization script.

I think the answer to my question is 'php composer.phar install --prefer-
source'?




On Fri, Feb 22, 2013 at 9:17 AM, Matthew Weier O'Phinney
wrote:

> On Fri, Feb 22, 2013 at 9:13 AM, Greg  wrote:
> > Is there a way to make it resolve to the same directory?
>
> Yes -- you can setup your git submodule to point to
> vendor/zendframework/zendframework.
>
> However, if you do so, you'll need to setup autoloading yourself, and
> if you end up using composer, you have the potential for odd
> behavior/conflicts -- which is why we used separate directories.
>
> > On Fri, Feb 22, 2013 at 4:07 AM, Marco Pivetta 
> wrote:
> >
> >> Composer is not adopted by all users, thus the two possible paths. What
> is
> >> exactly your question about then?
> >>
> >> Marco Pivetta
> >>
> >> http://twitter.com/Ocramius
> >>
> >> http://ocramius.github.com/
> >>
> >>
> >> On 22 February 2013 08:30, Greg  wrote:
> >>
> >>> Am I doing something wrong or are there two possible different
> >>> installation
> >>> directories for ZF2?
> >>>
> >>> Following each installation option for the skeleton application
> >>>
> >>> http://framework.zend.com/downloads/skeleton-app
> >>>
> >>> seems to lead to two different installation directories, i.e
> >>>
> >>> ZF2 or zendframework/zendframework
> >>>
> >>> It would be nice if which ever way would allow the user to explore
> more of
> >>> composer's capabilities, e.g autoloading, project initialization? I
> may of
> >>> missed of some configuration info?
> >>>
> >>>
> >>> --
> >>> Greg
> >>>
> >>
> >>
> >
> >
> > --
> > Greg
>
>
>
> --
> 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
>
>
>


-- 
Greg


Re: [fw-general] Different ZF directories depending on installation choice

2013-02-22 Thread Greg
Is there a way to make it resolve to the same directory?


On Fri, Feb 22, 2013 at 4:07 AM, Marco Pivetta  wrote:

> Composer is not adopted by all users, thus the two possible paths. What is
> exactly your question about then?
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>
>
> On 22 February 2013 08:30, Greg  wrote:
>
>> Am I doing something wrong or are there two possible different
>> installation
>> directories for ZF2?
>>
>> Following each installation option for the skeleton application
>>
>> http://framework.zend.com/downloads/skeleton-app
>>
>> seems to lead to two different installation directories, i.e
>>
>> ZF2 or zendframework/zendframework
>>
>> It would be nice if which ever way would allow the user to explore more of
>> composer's capabilities, e.g autoloading, project initialization? I may of
>> missed of some configuration info?
>>
>>
>> --
>> Greg
>>
>
>


-- 
Greg


[fw-general] Re: [zf-contributors] ZF2 command line tool?

2012-11-24 Thread Greg
I haven't looked, but it makes me wonder if the tool can list all available
commands, i,e you don't have to target a specific module to see the list of
commands for that module?

That hints towards the thought which I'm not sure how feasible or
absolutely why/possible, but for example, listing/dumping the configuration
for the entire application. Service definitions? Autoloader configuration?
Registered Listeners? Anything that is configured during the bootstrap
process? Not sure if routes could be done? Available Events?


On Sat, Nov 24, 2012 at 8:42 AM, Artur Bodera  wrote:

> On Fri, Nov 23, 2012 at 8:21 PM, Raphael de Almeida 
> wrote:
>
>> An active module could add new functions on ZF2 Tool
>>
>
> It already can!
>
> Any module can add one or more command-line commands:
>
>
> http://framework.zend.com/manual/2.0/en/modules/zend.console.introduction.html#writing-console-routes
>
>
>
> --
>   __
>  /.)\   +48 695 600 936
>  \(./   abod...@gmail.com
>
>
>
>



-- 
Greg


[fw-general] MvcEventManager (or EventServiceManger)

2012-11-17 Thread Greg
After looking at the ViewManager, I'm even more now under the belief that
some EventManagers should be able to pull listeners from the application
config via the SM.

In the case of the ViewManager(s) these would no longer be needed. And more
beneficially, it seems that the event listeners that are currently being
created and registered in the ViewManager's onBootstrap method would then
only be created on demand - thats a lot less objects and pre-initialization
(or listener registrations), and in some cases for events that might not
even occur in that request.

I was originally thinking that there could just be an MvcEventManager which
would have a dependency on the SM. For example, if the MvcApplication had
an MvcEventManager then the bootstrap method would not need to attach any
listeners at all.

I previously created a gist of this here <https://gist.github.com/3422930>.
Pulling from the config, may only be suitable in particulars areas due to
the status of the autoloader, i.e it should work for MvcEvents but might
not work for all of the ModuleManager events (loadModules).



-- 
Greg


Re: [fw-general] Decouple the SendResponseListener from the View Manager?

2012-11-16 Thread Greg
That's done... #2992


On Fri, Nov 16, 2012 at 12:27 PM, Matthew Weier O'Phinney
wrote:

> -- Greg  wrote
> (on Friday, 16 November 2012, 11:44 AM -0600):
> > In Mvc\Application::bootstrap there is
> >
> > $events->attach($serviceManager->get('RouteListener'));
> > $events->attach($serviceManager->get('DispatchListener'));
> > $events->attach($serviceManager->get('ViewManager'));
> >
> > And SendResponseListener is part of the ViewManager.
> >
> > I'm wondering if the ResponseListener should be attached in the bootstrap
> > instead? E.g
> >
> > $events->attach($serviceManager->get('ResponseListener'));
> >
> > This would move the SendResponseListener out of the View namespace which
> > seems better since it doesn't use or require any View objects?
>
> That makes sense to me.
>
> I actually plan to make all the factories inside the ViewManager into
> discrete factory classes as well, so that they can be
> replaced/overridden easily. That would be a good time to move the
> SendResponseListener out as well.
>
> Can you create an issue for me, please?
>
> --
> 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
>
>
>


-- 
Greg


[fw-general] Slim ZF2 Application

2012-11-16 Thread Greg
I've been looking at what it would mean to have a bare minimal application
bootstrap, i.e no modules (or ModuleManager) and just one single
application.config.php file for routes, controllers, and service_manager
directives.

This is an interesting exercise not only because it could provide a slim
ZF2 framework, but also because it shows how the Module Manager could be
decoupled and become an optional add on, e.g if a module is specified in
the config then use it.

Some observations:

These configurations could be added to the Mvc\Service\ServiceManageConfig

'RouteListener' => 'Zend\Mvc\RouteListener',
'DispatchListener' => 'Zend\Mvc\DispatchListener',



Moved all of the factory configurations from the
Mvc\Service\ServiceListenerFactory to the ServiceManagerConfig. The
ServiceListenerFactory actually ended up not being used at all.

Added a Default ControllerLoader to the ServiceManagerConfig which would
configure the ControllerManager with the controllers config from
application.config.php.

'ControllerLoader' => 'Zend\Mvc\Service\ControllerLoaderDefaultFactory',

public function createService(ServiceLocatorInterface $serviceLocator)
{
$configuration = $serviceLocator->get('Config');

$cConfig = isset($configuration['controllers']) ?
$configuration['controllers'] : array();

$controllerLoader = new \Zend\Mvc\Controller\ControllerManager(new
\Zend\ServiceManager\Config($cConfig));
$controllerLoader->setServiceLocator($serviceLocator);
$controllerLoader->addPeeringServiceManager($serviceLocator);

return $controllerLoader;
}


At this point, without invoking the ModuleManager or loadingModules, the
Mvc\Application init method reduced to

public static function init($configuration = array())
{
$smConfig = isset($configuration['service_manager']) ?
$configuration['service_manager'] : array();

$serviceManager = new ServiceManager(new
Service\ServiceManagerConfig($smConfig));
$serviceManager->setService('Config', $configuration);
//$serviceManager->setService('ApplicationConfig', $configuration);

//$serviceManager->get('ModuleManager')->loadModules();
return $serviceManager->get('Application')->bootstrap();
}

This still provides view templates and layouts via the ViewManager and
view_manager application.config.php settings.

The question I suppose it so what? Well its bare minimal, alternatively for
me I suppose, its been a way of getting my teeth into what happening.
However it does potentially show that it should be possible to decouple the
ModuleManager  and more easily clearly show what overrides are needed in
order to support modules.

Anyhow, just sharing some some of my thoughts towards what could be a slim
ZF2 framework. Took some sweat figuring out the ControllerLoader, so you
might as well hear about it :)


Regards,


-- 
Greg


[fw-general] Decouple the SendResponseListener from the View Manager?

2012-11-16 Thread Greg
In Mvc\Application::bootstrap there is

$events->attach($serviceManager->get('RouteListener'));
$events->attach($serviceManager->get('DispatchListener'));
$events->attach($serviceManager->get('ViewManager'));

And SendResponseListener is part of the ViewManager.

I'm wondering if the ResponseListener should be attached in the bootstrap
instead? E.g

$events->attach($serviceManager->get('ResponseListener'));

This would move the SendResponseListener out of the View namespace which
seems better since it doesn't use or require any View objects?



Regards,

-- 
Greg


Re: [fw-general] Form values, filtering and validation

2012-11-15 Thread Greg
I prefer displaying the original input, rather than the filtered value.
Seems like a single general 'Invalid Email Address' error message should
suffice; telling a user about their DNS entry because of a typo would just
be like talking a foreign language?


On Thu, Nov 15, 2012 at 8:59 AM, Andreas Möller  wrote:

> Hello Matthew,
>
>
> > I understand what you're getting at -- as I mentioned in my comment on
> > the gist, that's how I originally coded it. However, the feedback I
> > received then (after the initial release in beta4) was that this
> > situation was more confusing to end users.
> >
> > I can definitely see both sides; I'm just not sure how we can
> > accommodate both.
>
> It seems like I would have to remove filters that
>
> * trim
> * strip tags
> * strip newlines
>
> to make it work half the way I'm used to from ZF1.
>
> Seems, though, like this is more an issue out of the scope of the
> framework, as it's connected with user experience issues, isn't it?
>
> > You can override this behavior by providing your own view helpers at
> > this stage -- so if it's important to you, you can definitely make this
> > happen inside your application.
> >
> > As for the framework, we *may* be able to provide a flag in the
> > AbstractHelper in the form component that would allow toggling this,
> > though it would likely require changes to each of the helpers to honor
> > that flag.
>
> Sounds like a great solution to me.
>
> > Anybody else want to throw in some ideas or feedback on this issue?
>
> Interested to hear more about this.
>
>
> Best regards,
>
> Andreas
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>


-- 
Greg


[fw-general] Re: [ZF2] Overriding Zend\Mvc\Application and/or its Factory

2012-11-14 Thread Greg
Turns out its the same one liner as in a module config but now in the
config/autoload/global.config.php (at least with out errors).

Which makes me wonder about the documentation about the 'Application'
instances here:
https://zf2.readthedocs.org/en/latest/modules/zend.mvc.services.html?highlight=global.config.php#application-configuration-options
.





On Mon, Nov 12, 2012 at 3:46 PM, Greg  wrote:

>
> config/application.config.php
>
>
> return array(
> 'service_manager' => array(
> //'use_defaults' => true,
> 'factories'=> array(
> //'Application' => 'Zend\Mvc\Service\ApplicationFactory',
> 'Application' => 'Application\Mvc\Service\ApplicationFactory',
> ),
> ),
> );
>
>
> What config options are required to specify which Mvc\ApplicationFactory
> to use?
>
> It looks like the ServiceManagerConfig::configureServiceManager method
> will always end up trying to initialize the 'Application' factory config.
> Whereas I think it should check to see if one has already been specified
> instead of resorting to forcing the defaultServiceConfigurations?
>
> I also could not see how to specify the allow_override flag, and wonder
> why it is not part of the ServiceManagerConfig? I realize that even if I
> was able to specify this value, it would not be what I want anyway. Since
> in the above example, I would not want the
> defaultServiceConfiguration['factories']['Application'] value to override
> the existing configuration.
>
>
> A while ago, I did end up going down another route, and made some progress
> via the service_listener_options, however once it was set up for the
> Application factory config, things went south, because the code or
> configuration pertaining to 'Config' => Zend\Mvc\Service\ConfigFactory,
> which may of been just because it was the next entry in the
> defaultServicesConfig?
>
> I don't have the config options for what I tried awhile back anymore, but
> it was to do with:
>
> $serviceListener->addServiceManager(
> $newServiceManager['service_manager'],
> $newServiceManager['config_key'],
> $newServiceManager['interface'],
> $newServiceManager['method']
> );
>
>
> So how in the global config/application.config.php file is it possible to
> override the 'Application' service?
>
> Would it be feasible to see the global config/application.config.php file
> specify all the default services that the ServiceListenerFactory setups,
> and allow users to easily swap them out via the global config file, even as
> example test case?
>
>
> --
> Greg
>



-- 
Greg


[fw-general] [ZF2] Overriding Zend\Mvc\Application and/or its Factory

2012-11-12 Thread Greg
config/application.config.php


return array(
'service_manager' => array(
//'use_defaults' => true,
'factories'=> array(
//'Application' => 'Zend\Mvc\Service\ApplicationFactory',
'Application' => 'Application\Mvc\Service\ApplicationFactory',
),
),
);


What config options are required to specify which Mvc\ApplicationFactory to
use?

It looks like the ServiceManagerConfig::configureServiceManager method will
always end up trying to initialize the 'Application' factory config.
Whereas I think it should check to see if one has already been specified
instead of resorting to forcing the defaultServiceConfigurations?

I also could not see how to specify the allow_override flag, and wonder why
it is not part of the ServiceManagerConfig? I realize that even if I was
able to specify this value, it would not be what I want anyway. Since in
the above example, I would not want the
defaultServiceConfiguration['factories']['Application'] value to override
the existing configuration.


A while ago, I did end up going down another route, and made some progress
via the service_listener_options, however once it was set up for the
Application factory config, things went south, because the code or
configuration pertaining to 'Config' => Zend\Mvc\Service\ConfigFactory,
which may of been just because it was the next entry in the
defaultServicesConfig?

I don't have the config options for what I tried awhile back anymore, but
it was to do with:

$serviceListener->addServiceManager(
$newServiceManager['service_manager'],
$newServiceManager['config_key'],
$newServiceManager['interface'],
$newServiceManager['method']
);


So how in the global config/application.config.php file is it possible to
override the 'Application' service?

Would it be feasible to see the global config/application.config.php file
specify all the default services that the ServiceListenerFactory setups,
and allow users to easily swap them out via the global config file, even as
example test case?


-- 
Greg


Re: [fw-general] ZF2 Documentation

2012-11-09 Thread Greg
I haven't tried to follow much recently. Honestly, until such time that I
see decent documentation pertaining to /config/application.config.php, I
won't be happy (and I'm not going to track down those who know to then
write it up). Sorry...

To explain, a couple months ago I tried to figure out how to specify my own
Application class, and naturally thought it can be easily done in global
config file, and trying to make it work drew me to a brick wall (if I
recall it was due to the ServiceListenerFactory), it turned out be a simple
one liner in modules/Application/config/module.config.php, by then I was
struggling to perceive the intentions and goals (reading the code doesn't
always clarify this any better). Either its a bug or needs documentation.

I'd like to see a configuration file with every single option specified
with comments, even if the option is commented out.

I realize that it will (hopefully) come out in the wash. Until then...

Regards,


-- 
Greg


[fw-general] Re: [zf-contributors] ZF2 EventManager now in ZF1 trunk

2012-03-20 Thread Greg
On Tue, Mar 20, 2012 at 8:48 AM, Matthew Weier O'Phinney
 wrote:
> I've fielded a large number of requests
> from ZF1 users who would like the functionality for their ZF1
> applications -- no more, no less.

I appreciate that, but I'm still concerned that significant changes to
the Event system will cause disruptions to the ZF1 implementation. The
late pull request for the SharedEventManager could be one such
example.

Anyhow I realize its also about choice.


>
> I actually haven't been discussing retrieving event listeners from the
> DIC at all -- I _have_ been discussing injecting a "SharedEventManager"
> into EventManager instances, so we don't need to use the singleton
> StaticEventManager version.

Well this is the first ML post mentioning the SharedEventManager, and
my comment was based off a comment you made in another thread:

http://zend-framework-community.634137.n4.nabble.com/ZF2-speed-td4414795i20.html#a4428769

I actually then stumbled on Symfony2's ContainerAwareEventDispatcher
which lazy loads listeners from the DIC.


> StaticEventManager follows the design of Zeta Components' SignalSlot
> more than any other implementation. The purpose is, quite simply, to
> allow attaching listeners without having direct access to the EM
> instance and/or component composing the EM instance. This is a
> well-defined use case at this time.

At the time I ran into some documentation which looked like Java code.
Either way, the documentation did not elaborate very much on the best
practices of the static usage - which is my concern and potentially
now why there is the Shared instance instead. I don't see jumping
around the object graph as good practice.

> Additionally, as explained before, there are no ties between DIC and the
> EventManager; the only question is if there's a way to alter the EM to
> be more DI friendly with regards to shared event collections. Since we
> have no DIC in ZF1 -- and no plans to backport it, as it relies much too
> heavily on PHP 5.3-specific features -- I see no conflict here.

Thats another discussion I think, I don't want to come off overly
incorrect or harsh, so I'd rather wait to see how the ZF2 Definitions
evolve - but that doesn't mean it is impossible for ZF1 to have a
Container of some form.



Regards,

Greg

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




[fw-general] Re: [zf-contributors] ZF2 EventManager now in ZF1 trunk

2012-03-20 Thread Greg
Hi Jurian,


On Tue, Mar 20, 2012 at 3:43 AM, Jurian Sluiman  wrote:
> Might this solve some of your
> concerns? https://github.com/zendframework/zf2/pull/944

Thanks for letting me know. I'll take another look later on. Although
I still think it may be a little too soon to be pushing this into ZF1,
all the examples and blog posts use the static event manager, and if
any other changes to the ZF2 event system happen it might mean these
changes can't be applied within ZF1 due to BC concerns.


Regards,

Greg

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




[fw-general] Re: [zf-contributors] ZF2 EventManager now in ZF1 trunk

2012-03-20 Thread Greg
Hi Matthew,


I'm concerned that this code is being pushed into ZF1 so soon. In my
mind (tonight), PHP event driven programming boils down to how
processes are either registered or implemented. And with the right SOA
this isn't really a problem. Furthermore, registering event
listeners/handlers in PHP from a performance point of of view could
happen in various ways (some may still be unknown to me). Yet in
another thread you stated that in the next ZF2 beta release you would
like to iron out if and how event listeners can be retrieved from the
DIC. This concerns me in that we may now end up going down a 'bolted
on' path within ZF1 (and ZF2).

As you know, I am extremely concerned by the usage of the
StaticEventManager. I would also say, that as you previously stated
that this concept was modeled after a Java implementation, that I am
concerned about its usage in PHP. Back then when I read the Java
documentation (which I can't find anymore), it was not very elaborate,
but given that static usage in a Java web application is significantly
different than within PHP as that static Java resources persist across
all web requests, it leads me to believe that the static usage in Java
is only for low level processes, e.g cache, profiling etc - although
it was not very explicitly stated as such in their documentation.
However, to date in ZF2 the usage of the StaticEventManager is for
high level processes that cannot be contained, as you say, within the
object the graph.

I would like to see event handlers, but I would rather wait to see it
solidified in ZF2, with well defined use cases, prior to it being back
ported to ZF1.

This suggests to me, that we would need to see a ZF1 DIC implementation first.


Regards,

Greg

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




Re: [fw-general] Multiple spl_autoload registered handlers

2011-08-25 Thread Greg
Hi Ralph,

>
> Thats not true.  Autoloaders that are shipped with code should only be
> responsible for loading the code they are responsible for (in the least).

Ok, I can agree with that. But thats were overheads can occur
depending on the implementation of the rest of the spl registered
handlers.

As example, suppose the StandardAutoloader has a registered namespace.
And when the StandardAutoload::autoload function is called and it
determines that the class name is for that namespace but the class can
not be located then by returning false, the next registered spl
autoloader is called - but we just determined that the autoloader
shipped for that namespace could not find the class - so whats the
point in asking any of the other autoloaders?

For example, we want to find the Url view helper, heres our registered
helper namespaces/prefixes.

$prefixes = array(
  'Default_View_Helper_',
  '\Application\View\Helper\',
  'Zend_View_Helper_'
);


foreach($prefixes as $p) {
  $class = $p . 'Url';

  if (class_exists($p . 'Url')) {
return $this->helper['Url'] = new $class();
  }
}

If there are two spl registered handlers, ClassMap (which knows all of
the classes in the application) and the StandardAutoloader (and in ZF2
lets say it is fallback enabled). Then if 'Default_View_Helper_Url'
does not exist in the ClassMap Autoloader why should the fallback
strategy of the StandardAutoloader even be executed - it would be a
waste of time and i/o (which for ZF1 is not possible to prevent, if I
can recall, unless there is only one registered spl autoloader).


Its fine, I can work with what is there.


Regards,

-- 
Greg

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




Re: [fw-general] Multiple spl_autoload registered handlers

2011-08-25 Thread Greg
Hi Matthew,

>
> Again, why is this a problem, exactly? What if you have another
> autoloader registered later that _can_ handle it?

If the first dedicated autoloader for that namespace couldn't handle
it, chances are no other handler will (or should not).

>
> But spl_autoload _IS_ a stack

I realize that, the point was that the application code cannot break
out of the execution loop if desired.

As much as I appreciate that the zf2-quickstart example, is exactly
that, but it does somewhat exemplify the point I'm trying to make
since in that example, the StandardAutoloader would execute given the
namespaces registered even though there are class maps also - I
realize it is just example code.

My original post was more to draw awareness to potential overhead that
could be incurred if the we're not cognitive of the implications
(depending on how and what is being used).


Regards,

-- 
Greg

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




Re: [fw-general] Multiple spl_autoload registered handlers

2011-08-24 Thread Greg
Hi Matthew,

>> My point, or preference is, is that we should try and encourage only
>> registering one autoloader handler for the application.
>
> Why, exactly? What problem does this solve?
>
> This is in fact how the StandardAutoloader (PSR-0 implementation) in ZF2
> works -- you register explicit namespace/path pairs; if the requested
> class does not match the given namespace, it moves on to the next
> handler.

In my opinion, therein lays the problem. Each handler's register
method is registering with spl_autoload_register, which the developer
cannot halt if a class for a particular namespace is not found, since
the handler's autoload method typically returns false, causing the
spl_autoloader to move onto the next registered handler (there is no
way of preventing _spl_ from continuing?).

For example, say the StandardAutoloader is registered and has had
namespace 'Ant' registered with it. And another handler is also
registered with the spl_autoload_register (similar to what's in the
quickstart). Then if class_exists is called for 'Ant\test', the
standard autoloader will return false (since it doesn't exist),
causing the spl_autoloader to move onto the next registered handler
when it shouldn't, especially when chances are none of the other
handlers know anything about that namespace.

So instead, I'm thinking, there should be only one (stack like)
handler registered via spl_autoload_register, and any other handlers
would register with that single stack like handler instead of directly
registering with the spl_autoloader. This would give the handler a way
to indicate that the autoloading mechanism should halt its process and
not waste any more cycles or file/io lookups.

For example, with the ZF1 code I wanted to try an optimize the
autoloading mechanism after introducing the Class Map back port you
provided. Try making that handler the only autoloader for ZF1, its not
clean. And with a class map to hand there is no need for the View
Helper to file hunt, try changing file_exists to class_exists and
notice the unnecessary subsequent autoloader calls if more than one
handler is registered with spl.


Regards,

Greg

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




Re: [fw-general] Multiple spl_autoload registered handlers

2011-08-24 Thread Greg
Hi Ralph,

>> if (false === class_exists('ClassA')) { //dynamically check to see if
>> a local overriding class exists via the autoloader
>>   $class = new DefaultClass();
>> } else {
>>   $class = new ClassA();
>> }
>
> What is an "overriding class"?


In the above 'overriding' is the 'preferred' class to use, else use a
default one (which doesn't have to be of the same namespace).

> By doing that, you can be sure that the stack of autoloaders is exactly as
> you expect it to be.  You can also use the PHP 5.3 only feature of
> spl_autoload_register "prepend flag" to ensure things are in the order you
> expect them to be in:

Even with the prepend flag it doesn't alleviate the problem, because
if 'Class A' is not found in the first registered autoloader, all of
the other (if any) autoloaders are then called - which in the above
example would be unnecessary.

To me the problem is somewhat similar to finding a ZF1 View Helper, it
iterates through until it finds one.

My point, or preference is, is that we should try and encourage only
registering one autoloader handler for the application. I've also
wonder it should be similar to ZF1's plugin priority stack, which may
also then provide the developer more control of the execution stack
(if needed). I realize that in ZF2 this may not be an issue if say
only the Class Map autoloader is the only registered handler.

For example, if the handler could prevent the autloader stack from
automatically continuing onto calling the subsequent registered
handlers because the one for that namespace knows it could not find
and that none of the handlers will either.


Regards,

-- 
Greg

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




[fw-general] Multiple spl_autoload registered handlers

2011-08-16 Thread Greg
I'm not sure whether this may be an issue in the end or not. But I am
reading reference to fallback autoloader handlers which causes me
concern if the developer has to go through hoops to ensure that the
application only has one spl_autoload registered handler. My concern
here is that if a call to class_exists is used to determine whether a
custom (project/module specific) class should be loaded instead of a
default class I realize that there might be some grounds of a DI
but the following code is what concerns me:


if (false === class_exists('ClassA')) { //dynamically check to see if
a local overriding class exists via the autoloader
  $class = new DefaultClass();
} else {
  $class = new ClassA();
}


Having multiple registered spl_autoload handlers will incur
unnecessary cycles, and the developer will not have the ability of
controlling the autoloading stack (e.g circumventing it), I'm
wondering if it would be better to have one registered handler similar
to the ZF1 plugin priority stack.


-- 
Greg

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




Re: [fw-general] ZF, Doctrine Integration. i made an architectural error over Models.

2011-06-02 Thread Greg
There are other ways, but it might not be unfeasible to create a
listQuery action helper which would combine the search helper's query
and the controllers DQL. E.g in the Story controller

$query = $this->_helper->pagerQuery('Model_Entity_Story_PagerQuery', true);
$pager = $this->_helper->pagination($query);

Where the pagerQuery helper creates a Model_Entity_Story_PagerQuery
that is a Doctrine_Query object which can then be passed to the
pagination helper (Doctrine_Pager). Alternatively,

$pager = $this->_helper->pager('Model_Entity_Story_PagerQuery', true);

Where the search and pagination helpers assign the respective
properties to the Query object.


-- 
Greg

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




Re: [fw-general] Module Bootstrap

2011-05-04 Thread Greg
Instead of overriding the FrontController itself, you could override
the Front Controller bootstrap resource
(Zend_Application_Resource_Frontcontroller) - it should be possible to
specify the dir location for your overriding resources. Then in that
custom front controller resource class, it could be possible to
override the init() method to manipulate the controllerdirectory array
prior to calling the parent init() method, eg:

My_Resource_Frontcontroller
  extends Zend_Application_Resource_Frontcontroller
{

public function init()
{

   //bootstrap dependencies used to figure out which modules to load
  //e.g
  $db = $this->getBootstrap()->bootstrap('db');

  //controller dirs
 $controllerdirectory = array(
   'default' => '/modules/default/controllers'
 );

  $this->setOption('controllerdirectory', $controllerdirectory);

  parent::init(); //sets desired controller dirs in the front controller

}

}

-- 
Greg

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




[fw-general] dijit theme in layout scripts?

2011-03-14 Thread Greg
Hi all!
I have Dojo working great in my bootstrap/loader, controllers and view
scripts, but I would like to use a few Dojo Dijits in my Layouts.
Particularly in some partials for navigation.
In the layout script I have just a simple button for now:

$btnTasks = new Zend_Dojo_Form_Element_Button('btnTasks');
$btnTasks->setAttribs(array(
'onClick' => "window.location.replace('task');",
'label' => 'Tasks'
));

Which renders this:

 
btnTasks


The "dojo" portion of this works, I get a button and it works, but there's
no theme or styles rendered. It's just a standard, ugly form button. The
theme and styles work great in controllers and views, just not in the
layout. Which is odd, because part of the layout is calling the
"addStyleSheetModule" for Dojo.

Any idea why the styles are not working on the layouts only?

Thanks for your help!

Greg Fischer
1st Byte Solutions
http://www.1stbyte.com/


Re: [fw-general] Re: Error handling in Zend

2010-12-20 Thread Greg
>> For the time being, I need to sort out how to maintain my querystring when I
>> redirect.
>>

To maintain the query string, don't redirect upon error? Swallow the
error and display an error page with a http 500 header - There is a
need for two types of error pages potentially, one for general errors
that the application can still handle while still rendering a page
suitable for the user to then navigate away from, the other is a fatal
error page that really is nothing more than a static page (at which
point its up to you how to display it)?

>> > If you want to use a try/catch block in your index.php, I would use it
>> > only on the ->bootstrap() call of the $application, not run() as nothing
>> > will be emitted.  If you insist on throwing exceptions and catching them
>> > in the index.php, add this value to you application.ini:
>> >

A recent observation of mine is that when in production if the
bootstrap method swallows the error, the run method is still invoked
which is unnecessary and causes other errors, so for example,

$application->bootstrap()->run();

Its seems like the run method should check to see if the bootstrap was
invoked successfully.


>> >> What I really want to do is just pop a jquery dialog box on the page that
>> >> pops the error (or the previous page if there is something like a 404
>> >> error). In order to do this I am trying the following:


The error controller could respond accordingly based upon if it is an
ajax request. I'd be less inclined to do that for the fatal error
page?


-- 
Greg


Re: [fw-general] iframe tag embedded in a view (html5)

2010-11-04 Thread Greg
You probably copied and pasted the dodgy double quotes.

Try replacing them with "


On 04/11/2010 20:03, whisher wrote:
> Hi,
> I'm trying to embedded a youtube video 
> in a view using html5.
> So following 
> http://techie-buzz.com/youtube/html5-embed-code-youtube-videos.html
> I put in the view a iframe tag
> but I've got 
> invalid controller specified (%E2%80%9Dhttp:)
> Stack trace:
> Request Parameters:
>
> array (
>   'controller' => '%E2%80%9Dhttp:',
>   '' => 'www.youtube.com',
>   'embed' => 'JW5meKfy3fY”',
>   'action' => 'index',
>   'module' => 'default',
> )
> and I've not idea how can work it out :(
> Could you help me ?
>
>



Re: [fw-general] Multi Php Versions

2010-10-27 Thread Greg
Thanks for sharing Rob, that's a really interesting program.

I use both apache and IIS, but i am using IIS 6.0. I don't suppose you
know if there is a version for that?

Regards,
Greg

On 27/10/2010 20:49, Paul wrote:
> Interesting, although I prefer to work w/ Apache as that is what our
> production servers are using.
>
> On 10/27/2010 3:43 PM, Rob Allen wrote:
>> On 27 Oct 2010, at 01:31, Paul wrote:
>>
>>> A few of our developers are on windows machine, so we thought the
>>> best way forward was to go with Zend Server CE for windows   So we
>>> downloaded Zend Server CE for Windows  w/ php 5.2, so they we could
>>> continue development on our legacy sites, but then follow the
>>> article above to also be able to play w/ php 5.3.  Unfortunately we
>>> could not get this to work on Windows w/ the current version of Zend
>>> Server CE (would either not get Apache to start up or pages were be
>>> returned as plain text).
>>>
>>> Does anyone have any experience doing this on Windows or able to
>>> translate Matthew's article for windows (instead of Ubuntu).  Also I
>>> noticed that Zend Server CE is already running php under FastCGI,
>>> compared to the article where it assumed Zend Server used mod_php?
>>>
>> Hi,
>>
>> I use IIS7 on Windows and so use the PHP Manager for IIS here:
>> http://phpmanager.codeplex.com/
>>
>> Regards
>>
>> Rob..
>>
>>



[fw-general] Using numeric keys and formSelect view helper

2010-07-04 Thread Greg

Hi,

I'm trying to use the formSelect view helper by passing as my options 
argument (data fetched from database):


$options = array(
1=>'Option 1',
3=>'Option 2',
4=>'Option 3',
7=>'Option 4',
9=>'Option 5',
);

But as soon as it gets into Zend_View_Abstract::_call(), the options 
array becomes:


$options = array(
0=>'Option 1',
1=>'Option 2',
2=>'Option 3',
3=>'Option 4',
4=>'Option 5',
);

So it loses it's indexing so I can't store the value in the 
database...does anyone know why this is happening or have a solution to 
this other than adding some text to the key to force it to be a string?


I'm using PHP 5.3.1 if that helps.

Thanks,
Greg


Re: [fw-general] PHPUnit Cannot override final method Zend_Controller_Action::_forward()

2010-03-23 Thread Greg
The problem was occurring in the code coverage report. Today I tried
putting phpunit into my path and that seems to of done the trick.

Thanks,

Greg.


On Tue, Mar 23, 2010 at 7:24 AM, Matthew Weier O'Phinney
 wrote:
> -- Greg  wrote
> (on Monday, 22 March 2010, 09:29 PM -0500):
>> When running PHPUnit I get the following error
>>
>> OK (1 test, 1 assertion)
>>
>> Generating code coverage report, this may take a moment.
>> Fatal error: Cannot override final method
>> Zend_Controller_Action::_forward() in
>> modules/default/controllers/IndexController.php on line 20
>>
>> I'm using PHPUnit 3.4.11 and ZF 1.10.1
>
> Are you mocking Zend_Controller_Action or one of your controllers, by
> any chance? That's the only reason I can think of for the above error.
>
>> And when I remove the final declaration from the _forward method I
>> also run into another problem where it throws a fatal error that a
>> particular controller class cannot be redeclared - there are several
>> other controllers that extend this one and I tried to change the
>> require statements to require_once but that didn't work.
>>
>> Does anyone know what I'm doing wrong?
>
> --
> 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
>



-- 
Greg


[fw-general] PHPUnit Cannot override final method Zend_Controller_Action::_forward()

2010-03-22 Thread Greg
Hi,

When running PHPUnit I get the following error

OK (1 test, 1 assertion)

Generating code coverage report, this may take a moment.
Fatal error: Cannot override final method
Zend_Controller_Action::_forward() in
modules/default/controllers/IndexController.php on line 20

I'm using PHPUnit 3.4.11 and ZF 1.10.1

And when I remove the final declaration from the _forward method I
also run into another problem where it throws a fatal error that a
particular controller class cannot be redeclared - there are several
other controllers that extend this one and I tried to change the
require statements to require_once but that didn't work.

Does anyone know what I'm doing wrong?


Thanks,


-- 
Greg


[fw-general] Action controller view variable assignments (also question regarding 2.0 Compatibility)

2010-02-20 Thread Greg
Elsewhere I posed a thought a about automatically assigning variables
to the view within the Action Controller and it was said that this
might not be compatible either with ZF 2.0 or the way that Action
Helpers interact with contoller variables.

However I'm still unsure as why in the case of Action Helpers this
might be a problem.

The following is what I had in mind:

public function &__get($key) {
if ('_' === substr($key, 0, 1)  || !isset($this->_data[$key])) {
trigger_error('Key "'.$key.'" does not exist', 
E_USER_NOTICE);
$result = null;
return $result;
}

return $this->_data[$key];
}

public function __set($key, $value)
{
if ('_' === substr($key, 0, 1)) {
throw new VF_Exception('Setting ... is not allowed');
}

$this->_data[$key] = $value;
if (isset($this->view)) {
$this->view->assign($key, $value);
}
}

Although not 100% elegant, it does present a means  to working around
when two action methods then have to handle view variable assignment
(generally for the same view script).

Otherwise some common method would need to be available to the Action
Controller?

I'm running into two types of cases of view variable assignments:

[1] Those that are actually used by the Controller, e.g form
[2] Supplementary data used within the view script.

For [2] I'm thinking this could/should probably be handled by a View
Helper instead.

It would be great to know how others are handling their view variable
assignments prior to view script being rendered. Or there are any
problems perceived with using the magic methods above.?

Thanks,


[fw-general] Pdo Pgsql serialized session data truncating

2010-02-09 Thread Greg
Its seems like there is some kind of isssue (or bug) when using the
Pdo_Pgsql adapter for session handling (Zend_Session) and the session
data is being truncated

I'm starting to think it is the php PDO pgsql driver itself, or its
execute method.

Does anyone know if this is a known problem, or not experienced this
problem with the postgres pdo driver?

Are there any workarounds or solutions I might try?


-- 
Greg


Re: [fw-general] Re: A question about bootstrapping modules

2010-01-31 Thread Greg
I use something based on the following, merging the configs also
allows the admin to extend (override) the default config production
settings, e.g. in the default module the session.name might be 'app'
and in the admin it might be set to 'admin-app', but the rest of the
session settings as speficied in the default config would be used
(only the session name is overridden).

file: /config.ini

[production]
default.module = 'default'
session.name = 'app'
session.domain = 'test.com'
database.name = 'app_prod'

[development]
database.name = 'app_dev'




file: /admin/config.ini

[production]
default.module = 'admin'
session.name = 'admin-app'

[development]


file: /index.php
setBootstrap(APPLICATION_PATH.'/bootstrap/Bootstrap.php',
'Bootstrap')
->bootstrap()
->run();

file: /admin/index.php
merge(new Zend_Config_Ini(
APPLICATION_PATH.'/configs/admin/application.ini',
APPLICATION_BOOTSTRAP_MODE));

$application = new Zend_Application(APPLICATION_ENV, $config);

$application->setBootstrap(APPLICATION_PATH.'/bootstrap/Bootstrap.php',
'Bootstrap')
->bootstrap()
->run();


Re: [fw-general] Files which are outside the public folder

2010-01-30 Thread Greg
For large files, http://tn123.ath.cx/mod_xsendfile/ is a good
alternative to reading the file through php but allowing php to still
maintain access control.




On Fri, Jan 29, 2010 at 1:29 PM, holografix .  wrote:
> Hi
>
> You can watch this cast and download the code. Maybe it helps you.
>
> http://www.zendcasts.com/protecting-assets-with-zend-controller-plugins/2009/10/
>
> Cheers
> holo
>
> 2010/1/29 Ralph Schindler 
>>
>> Well, this is gonna be tricky.  Ideally, they are simply served from the
>> public directory.  But if you want to add some level of access control
>> around them, you'll need to put them outside of the public/ directory, and
>> wrap the download in a PHP script that will do your access control.
>>
>> Normally, I'd say to do this inside a controller, but Video files can get
>> large.  In addition, by using the Zend_Controller request, it will
>> output-buffer the output by default.. Which might cause problems.
>>
>> Your best bet is to do a downlaod.php script, and do something similar in
>> here, example 1:
>>
>> http://php.net/manual/en/function.readfile.php
>>
>> In the script, you'll have to do some kind of quick access control, like
>> checking Zend_Auth for a user, or even perhaps checking the cookie against
>> your database.
>>
>> Hope that helps,
>> Ralph
>>
>> Kuzma wrote:
>>>
>>> Hello!
>>> I've tried to search for the solution or any information about this
>>> question
>>> but I haven't found anything.
>>> The problem is:
>>> I have a page which loads JS video player which plays video files from
>>> the
>>> public folder to all users:
>>>  as example  video/id/xx/main.flv But I need, that logged in users can
>>> see and another video files which are
>>> secured. In other words that someone won't download files directly.
>>> I understand that this files must be put outside public folder but in
>>> this
>>> way I don't understand how to generate links to player.
>>> Thank you!
>>>
>>>
>>>
>
>



-- 
Greg


Re: [fw-general] Re: A question about bootstrapping modules

2010-01-30 Thread Greg
One way to achieve this is to have separate bootstrap index.php files,
i.e /admin/index.php which would then specify a specific config file
to use which merges with the main (default module) config. Both
config.ini specify the default module, and because of merging the two
configs setting the default module to be admin in the admin config.ini
will allow you to determine which specific controller directory to
specify.

$module = isset($options['module']) ? $options['module'] :
'default';

$frontController = Zend_Controller_Front::getInstance();


$frontController->setControllerDirectory(APPLICATION_PATH.'/modules/'.$module.'/controllers',
$module)

The module Directory is not specified since it will read admin, and
default as available modules to bootstrap.


If you google, Matthew mentioned another method that someone used
whereby using a controller plugin to only call iniActive methods for
the current module - but for me that still meant loading a module
bootstrap class which would wouldn't be required in this particular
usage.


Re: [fw-general] why is every module bootstrap executed during initialization?

2009-12-16 Thread Greg
A work around could be to not specify the modules directory but
instead specify the controller directory of the module in question (in
Application/Bootstrap) - in this case each module would have their own
bootstrap (index.php) script and the current module name could be
specified in a respective config file - so potentially there would be
two bootstrap classes executed, one for the Application/Bootstrap and
then the respective Module/Bootstrap.



On Wed, Dec 16, 2009 at 4:40 PM, Hector Virgen  wrote:
> You can test the request from within your plugin:
> public function dispatchLoopStartup(Zend_Controller_Request_Abstract
> $request)
> {
> if ('admin' != $this->_request->getModuleName()) {
> return;
> }
> // Perform pluginy things here
> }
>
> --
> Hector
>
>
> On Wed, Dec 16, 2009 at 2:18 PM, Guillaume ORIOL  wrote:
>>
>> Thank you Matthew but I don't understand your last remark.
>>
>> Let's say I have two modules, each of which has its own plugin registered
>> at bootstrap:
>> class Default_Bootstrap extends Zend_Application_Module_Bootstrap
>> {
>>public function _initPlugin()
>>{
>>$plugin = new Plugin_Foo();
>>$front = Zend_Controller_Front::getInstance();
>>$front->registerPlugin($plugin);
>>}
>> }
>>
>> class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
>> {
>>public function _initPlugin()
>>{
>>$plugin = new Admin_Plugin_Bar();
>>$front = Zend_Controller_Front::getInstance();
>>$front->registerPlugin($plugin);
>>}
>> }
>>
>> If I perform a request on the default module, both plugins are executed.
>> According to your last remark, I thought only one plugin should have bee
>> executed.
>> --
>> Guillaume
>>
>> Le 16/12/09 21:54, Matthew Weier O'Phinney a écrit :
>>>
>>> -- Guillaume ORIOL  wrote
>>> (on Wednesday, 16 December 2009, 09:33 PM +0100):
>>>
>>>>
>>>> I wonder why, in a modular application, all module bootstraps are
>>>> executed during initialization and not only the one corresponding to
>>>> the matched module?
>>>>
>>>> What would be the way to get only one of them executed (I would like
>>>> to connect a different plugin to each module)?
>>>>
>>>
>>> All module bootstraps are executed... because at bootstrap time, the
>>> requested module is not yet known. (It happens during _routing_.)
>>>
>>> Module bootstraps should be used for:
>>>
>>>  * Setting up autoloading of module resources (happens already,
>>>automatically)
>>>
>>>  * Performing any module-specific tasks that need to happen on every
>>>request
>>>
>>>  * Registering module-specific plugins
>>>
>>> This latter area is where you should execute code that should only be
>>> executed if the module is the one requested.
>>>
>>
>>
>
>



-- 
Greg


[fw-general] Zend_Ldap ZF 1.9 account Canonical Form

2009-11-17 Thread Greg
Hi,

I seem to be having difficulties connecting to the ldap server (which
I'm told they think is an AD).

What it seems to be boiling down to is that Zend_Ldap is building the
canonical username dn from the supplied username and the baseDn. From
what I read it seems that in order to build the username dn the
username dn and password must be passed as the config options before
building the username dn for any other given username - which in some
senses is kind of odd.

Instead what I had to resort to was to build the username dn, and set
the password into the config array prior to using the Zend_Ldap
connector.

Because if the username option is not in a dn format and the
accountCanonicalForm is 1 (DN) then the initial ldap_bind even though
it returns not false (i.e a respource) the subsequent search then
fails because the bind did not have the correct credentials (ie.
authorised and correct username dn).

So the following will not work

$options = array(
  'host' => 'ldap.server.net',
  'port'   => 636,
  'useSsl' => true,
  'accountCanonicalForm'   => 1,
  'baseDn' => 'OU=People,DC=server,DC=net',
  'bindRequiresDn' => true,
);

$ldap = new Zend_Ldap($options);

$canonicalName = $ldap->getCanonicalAccountName($username,
Zend_Ldap::ACCTNAME_FORM_DN);


Is there something to config that I'm missing, I have tried specifying
various account Filters... but it seems to be the underlying issuer is
that $username used in the initial ldap_bind is not in dn form unless
set as part of the config options.



-- 
Greg


[fw-general] Parameters and redirects

2009-02-19 Thread Greg Frith

Hi all,

I have just sent the below message from a different account, but there  
seems to have been some problem in my subscription and the message  
hasn't been circulated.  I have checked the archives and can only  
apologise if the message does finally appear and I end up double  
posting.


A simple one I hope...  I'm trying to put together a redirect request,  
based on parameters from an original request.  Essentially, I want to  
replace one parameter and then redirect the request with all the  
additional original parameters.  I could do something like this, but  
can't help thinking there must be a nicer way.


$params = $this->_getAllParams();
$params['new_param'] = 'some new param value';
unset($params['old_param']);

unset($params['action']);
unset($params['controller']);
unset($params['module']);

$this->_helper->Redirector->gotoRoute($params,'newRoute');

Obviously the bit I'm most unhappy about is having to unset the  
controller, action and module name to prevent these being passed as  
params to the new route.  I thought $this->_request->getUserParams()  
might have done the trick, but unfortunately not.


It works, but its not nice...  Any advice most welcome.

:wq


Re: [fw-general] Form_Decorator_File issues with multiFile

2008-10-15 Thread Greg Jones
On Wed, 15 Oct 2008 10:54:48 +0100, Thomas Weidner <[EMAIL PROTECTED]>  
wrote:



Greg,

First:
You should always note the release or revision you are using. ;-)


Sorry, it's 1.6.2. Thanks, what you say makes sense. I'll add a request  
for the decorator issue and see if it's just me who wants to be able to do  
that.


I have the form displaying as I want it now, but when it comes to  
receiving and validating the multifiles, am I meant to do anything  
special? I'm still exploring, but it seems the only way I can get it to  
work at the moment is by modifying isValid and receive on Element_File and  
making them build the array of names to pass to the adapter methods (so  
if($this->isArray()), loop using $this->_counter and build up an array of  
$name.'_'.$i values to use in place of $this->getName() as the argument to  
$adapter->isValid()/$adapter->receive(), in both cases -  
http://pastie.org/292898 maybe makes this clearer) - if I don't do this,  
then I get an undefined index 'name' on 1150 of  
File_Transfer_Adapter_Abstract. Is this a bug or am I doing it wrong?


Greg.


[fw-general] Form_Decorator_File issues with multiFile

2008-10-15 Thread Greg Jones

Hi,

I'm trying to make use of the multiFile option for the Form_Element_File  
component, but having a bit of trouble. In all my forms so far, I've used  
array('Label', 'ViewHelper', 'Errors') with setElementDecorators() at the  
end of adding elements to the form, and it's worked just fine (including  
with individual type='file' elements), but with multiFile set, I still  
just get the one input actually rendered. I did a bit of digging, and it  
seems that the specific File decorator isn't being used, I just assumed  
ViewHelper would work that out, but seemingly not. Firstly then, is there  
anyway I can tell the form/element at the time of adding the multiFile  
that I want to set some decorators, and not have them over-written by a  
call to setElementDecorators later on?


Second, it seems that the File decorator is losing the content of any  
other decorators its used alongside (Label and Errors, for example).  
Looking at the code, it's only returning its own markup, and there's no  
reference to $content after its passed in - should it not be doing the  
append/prepend logic that the other decorators seem to?



Greg.


[fw-general] File uploads when using Subforms doesn't seem to work

2008-10-03 Thread Greg Jones

Hi,

I'm trying to get file uploads working, with Zend_Form_Element_File, where  
the element sits inside a subform. I've put together a small form that  
exhibits the problem, form-code (http://pastie.org/284170) and when I  
submit the form, I get the error:


Notice: Undefined index: name in  
/var/www/[vhost]/library/Zend/File/Transfer/Adapter/Abstract.php on line  
743


and the value for the file element is just '../data/tmp/'.

It seems that while the Transfer_Adapter is preparing the files array and  
takes account of the array-indexing used by the subform, when the 'value'  
is passed through to do the validation, it's being left out. The contents  
of the _files property of the adapter is here (http://pastie.org/284174),  
and I can't figure out what's going on past that.


If I add the file-element to the form ($this->addElement() instead of  
$sub_form->addElement()), everything works as I'd expect it to - no  
Notice, and the value contains a filename, not just folder.


Greg


[fw-general] Call actions via CLI

2008-08-28 Thread Greg Frith

Hi all,

I'm currently using curl to call some actions at timed intervals using  
cron.  This is a far from ideal method, but has provided a quick fix  
for now.  I'd much prefer to call the actions via CLI, but I notice  
that there is currently no way to handle such requests.


I appreciate there is currently a proposal in placed for  
Zend_Controller_Request_Cli (http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Request_Cli 
), but this doesn't looked to have been touched for some time.


Just wondering if there are any plans afoot to proceed with a CLI  
request object, or how others are currently using ZF with the CLI.


:wq
Greg.


[fw-general] Debug Plugin

2008-08-11 Thread Greg Freeman

Has anyone made some kind of debug plugin to show the queries that have
executed for a page with the profiler etc and styled it into a toolbar?
(similar to symfony I guess).
-- 
View this message in context: 
http://www.nabble.com/Debug-Plugin-tp18938417p18938417.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Context Dependent Menus

2008-08-08 Thread Greg Freeman

Thanks, I believe

$this->_helper->viewRenderer->setResponseSegment('menu1');

in the menu action would be simpler though.


beberlei wrote:
> 
> You should use the named segments of the Response Object.
> 
> In your main action, you use the action stack to render multiple actions:
> 
> $this->_helper->actionStack('menuaction', 'menucontroller', 'default', 
> array(params));
> 
> then in MenuController::menuAction you call:
> 
> $this->getHelper("ViewRenderer")->setNoRender();
> $this->getResponse()->appendBody($view->render('foo/bar.phtml'), 'menu1');
> 
> The response is then not appended to the Main Content but to another
> named segment called 'menu1'
> 
> in your layout.phtml you can then echo this named segment with:
> layout()->menu1; ?>
> 
> hope it helps.
> 
> On Friday 08 August 2008 07:42:26 Greg Freeman wrote:
>> What is the best way to create context dependent menu's etc in ZF? Does
>> ZF
>> have anything similar to slots or component slots such as those available
>> in symfony?
>>
>> Thanks
> 
> 
> 
> -- 
> Benjamin Eberlei
> http://www.beberlei.de
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Context-Dependent-Menus-tp18885867p1706.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Context Dependent Menus

2008-08-07 Thread Greg Freeman

What is the best way to create context dependent menu's etc in ZF? Does ZF
have anything similar to slots or component slots such as those available in
symfony?

Thanks
-- 
View this message in context: 
http://www.nabble.com/Context-Dependent-Menus-tp18885867p18885867.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Online payment components in ZF?

2008-06-11 Thread Greg Freeman

Is there any news on Zend_Service_Paypal? Has it been discontinued?
-- 
View this message in context: 
http://www.nabble.com/Online-payment-components-in-ZF--tp16447668p17788288.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Where does View helpers pull layouts from ? (outdated Zend_Layout code)

2008-06-05 Thread Greg Maruszeczka
On Thu, 5 Jun 2008 12:55:56 -0700 (PDT)
sean-k <[EMAIL PROTECTED]> wrote:

> 
> I'm sorry to post such an elementary question but I haven't been able
> to find an answer to my question.  
> 
> I use to have this code 
> Zend_Layout::startMvc(array('layoutPath'=>'../application/default/layouts'));
> That would add layout.pthml to my output.
> 
> I have read that Zend_Layout is in the core now(RC1), but where would
> I put the layout.phtml file so that it gets processed?  
> 
> Thanks,
> Sean
> 
> 


'layoutPath' => '../application/default/layouts'

-- 
   
Greg Maruszeczka

http://websagesolutions.com
skype: websage.ca
googletalk: gmarus

"Those who are possessed by nothing possess everything."
-- Morihei Ueshiba


Re: [fw-general] valid html issue

2008-05-29 Thread Greg Donald
On 5/29/08, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
> The helpers that are doctype aware are only considering whether or not
>  they are HTML or XHTML -- strictness is not considered.
>
>  Additionally, you can always switch doctype temporarily within your
>  application view scripts if they need to emit differently than the rest
>  of the application

Is there a way to do it in the bootstrap?

Something like this pseudo code?

if controller name == 'admin' && action name == 'index'
  // set frameset doctype
else
  // set regular doctype

I guess I could use $_SERVER['REQUEST_URI'] if nothing else.


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] valid html issue

2008-05-29 Thread Greg Donald
On 5/29/08, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
> You need to set the doctype in
>  your bootstrap or an early-running plugin so that it can be used in your
>  action view scripts; when you set it in the layout, it's too late, as
>  these have already been rendered.

That would seem problematic since it would force the application to
only use a single doctype, using XHTML1_STRICT when I really need to
use XHTML1_FRAMESET for example.

I guess I'll just use regular html tags and skip this particular helper.


-- 
Greg Donald
http://destiney.com/


[fw-general] valid html issue

2008-05-28 Thread Greg Donald
I'm using

doctype( 'XHTML1_STRICT' ); ?>

in my layout.  Then I'm creating a form like this:

$form = new Zend_Form;
$form->setAction( '/user/signup' )->setMethod( 'post' );
$form->addElement( new Zend_Form_Element_Text( 'username' ) );

which creates an input field that's missing the closing slash near the end:



Is there anything else I'm supposed to do to get valid html?


Thanks,


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] helper 'DocType' not found

2008-05-28 Thread Greg Donald
On 5/28/08, Greg Maruszeczka <[EMAIL PROTECTED]> wrote:
> You need $this->doctype('XHTML1_STRICT'), method name all
>  lowercase, despite what it says in the docs...

I see.  Thanks.


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] helper 'DocType' not found

2008-05-28 Thread Greg Maruszeczka
On Wed, 28 May 2008 11:19:35 -0500
"Greg Donald" <[EMAIL PROTECTED]> wrote:

> In the docs:
> 
> http://framework.zend.com/manual/en/zend.layout.quickstart.html
> 
> it shows something like this:
> 
> docType( 'XHTML1_STRICT' ); ?>
> 



You need $this->doctype('XHTML1_STRICT'), method name all
lowercase, despite what it says in the docs...


-- 
   
Greg Maruszeczka

http://websagesolutions.com
skype: websage.ca
googletalk: gmarus

"Those who are possessed by nothing possess everything."
-- Morihei Ueshiba


[fw-general] helper 'DocType' not found

2008-05-28 Thread Greg Donald
In the docs:

http://framework.zend.com/manual/en/zend.layout.quickstart.html

it shows something like this:

docType( 'XHTML1_STRICT' ); ?>

But when I try to use it in my layout I get errors:

Fatal error: Uncaught exception 'Zend_View_Exception' with message
'helper 'DocType' not found in path' in
/usr/local/apache2/ZendFramework-1.5.2/library/Zend/View/Abstract.php:1004
Stack trace: #0
/usr/local/apache2/ZendFramework-1.5.2/library/Zend/View/Abstract.php(497):
Zend_View_Abstract->_loadClass('helper', 'DocType') #1
/usr/local/apache2/ZendFramework-1.5.2/library/Zend/View/Abstract.php(294):
Zend_View_Abstract->getHelper('docType') #2 [internal function]:
Zend_View_Abstract->__call('docType', Array) #3
/usr/local/apache2/htdocs/rated/application/views/layouts/application.phtml(1):
Zend_View->docType('XHTML1_STRICT') #4
/usr/local/apache2/ZendFramework-1.5.2/library/Zend/View.php(46):
include('/usr/local/apac...') #5
/usr/local/apache2/ZendFramework-1.5.2/library/Zend/View/Abstract.php(769):
Zend_View->_run('/usr/local/apac...') #6
/usr/local/apache2/ZendFramework-1.5.2/library/Zend/Layout.php(729):
Zend_View_Abstract->render('application.pht...') #7
/usr/local/apache2/ZendFramework-1.5.2/library/Zend/Layout/Cont in
/usr/local/apache2/ZendFramework-1.5.2/library/Zend/View/Abstract.php
on line 1004

In my boostrap I have this:

require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();

So shouldn't that give me proper file scope for all of ZF, including
this helper it can't seem to find?


Thanks,


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] layout content not rendering

2008-05-28 Thread Greg Donald
On 5/28/08, Bradley Holt <[EMAIL PROTECTED]> wrote:
> This all looks correct except for one thing. I know the example in the
> documentation uses all uppercase 'CONTENT' but it also says:
>
> "contentKey: the layout variable used for default content (when used with
> the MVC). Default value is 'content'. Accessors are setContentKey() and
> getContentKey()."

That was the problem.

Thanks,


-- 
Greg Donald
http://destiney.com/


[fw-general] layout content not rendering

2008-05-27 Thread Greg Donald
In my bootstrap I'm trying to setup a default layout:

$layout = Zend_Layout::startMvc( array( 'layout' => 'application',
'layoutPath' =>
"$dirname/../views/layouts",
'contentKey' => 'CONTENT' ) );

I'm not exactly sure what to do with that new $layout variable however.


So then in my layout file, application.phtml, I have this:

layout()->content; ?>

But it produces nothing.


My controller looks like this:

render();
  }
}


My view file, index.phtml, looks like this:

In index view


So what do I have to do to get the content from my view template to
render in my layout?


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Zend_Debug -- or better?

2008-05-27 Thread Greg Donald
On Tue, May 27, 2008 at 11:36 AM, Philip G <[EMAIL PROTECTED]> wrote:
>
> Currently, the debug implementation looks pretty ... bleak. Is there more to
> this not documented? Or would I be using something else in combination?

I am curious about this too.  Is there any sort of shell into the environment?

If anyone is familiar, I was wanting something like Ruby on Rail's
script/console, or script/server --debugger.  They provide me command
line access directly into the running application environment.


Thanks,


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] leaving Zend

2008-05-24 Thread Greg Donald
On Sat, May 24, 2008 at 7:15 AM, Daniel Rossi <[EMAIL PROTECTED]> wrote:
> I'm sure everyone has been waiting for the
> existence of a framework since PHP5 came out,

No, not everyone.

http://www.phpwact.org/php/mvc_frameworks

I found Mojavi quite usable, and that was about 4 or 5 years ago.

Not to mention other scripting languages such as Ruby, Python and
Perl, and the web frameworks written in them.  But then I always heard
competition is a good thing.  :)


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] MVC - where can I learn more about the "model"?

2008-05-13 Thread Greg Donald
On 5/13/08, Rishi Daryanani <[EMAIL PROTECTED]> wrote:
>  I have
>  not yet come across any mention of the "models"
>  subdirectory.
>
>  Where can I learn more about this and what it's used
>  for?

ZF doesn't have what you may have come to expect as an actual "model"
component from other web frameworks.  Instead it has Zend_Db and
Zend_Db_Table.


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Web services & licensing issue

2008-05-08 Thread Greg Donald
On 5/8/08, Marcus Bointon <[EMAIL PROTECTED]> wrote:
>  So you're saying that you think all public web pages are copyright-free?

Yes, they are protected under the fair use doctine:

http://en.wikipedia.org/wiki/Fair_use


Fair use is a doctrine in United States copyright law that allows
limited use of copyrighted material without requiring permission from
the rights holders


Why would a site purposely build a web service around a copyrighted
work, not require authentication to it, then fault me for accessing
it?


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Web services & licensing issue

2008-05-08 Thread Greg Donald
On 5/8/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  Personally, I've never been in a position where I didn't check T&C
>  and/or license agreement of a service that I was consuming.  I've never
>  simply "assumed" that I could use at will.

Do you also query the webmasters of all publicly available web pages
you encounter before allowing your browser to render them?

A webservice is just a fancy buzzword for "we wrap our content in XML
for your convenience".  If it's not supposed to be public then it
should require authentication.


-- 
Greg Donald
http://destiney.com/


[fw-general] Re: Zend_Rest_Client

2008-04-28 Thread Greg Donald
On Fri, Apr 25, 2008 at 4:23 PM, David Rogers <[EMAIL PROTECTED]> wrote:
> WebServicesX.com looks like a SOAP-based XML-RPC service, which employs a
> WSDL that would tell you what you could ask the server for, etc. In that
> case, the component you're looking for is Zend_Soap, which is still in
> incubation.
>
>  Sorry, but them's the breaks. :D

Thanks for the reply.  /me waits patiently.


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Zend_Uri

2008-04-25 Thread Greg Donald
On Fri, Apr 25, 2008 at 7:13 AM, Wil Sinclair <[EMAIL PROTECTED]> wrote:
> I would greatly appreciate if everyone ignores Greg's value judgments in
>  responding to this mail. After all, he is entitled to his opinion, even
>  if you feel it doesn't align with yours or a substantial set of our list
>  subscribers. :)

You got it man, no more negative "opinions" from me.

>  Greg, once again I respectfully ask you to consider your audience. This
>  list has a long history of productive discussion and next to no flame
>  wars. If you're more interested in conflict than a discussion about ZF,
>  then you are off topic for this list and I would respectfully ask you to
>  take it elsewhere.

No flamewars intended.  Having a lot of previous "framework"
experience in PHP and other languages I came into this having
expectations that were obviously too high.. I mean it's not my fault I
thought ZF would be rockin', it is toughted as a "Web 2.0 Framework"
afterall.

At this point I just trying to figure out what's not working or
missing so I can go around it.  Sorry if I offended anyone.


-- 
Greg Donald
http://destiney.com/


[fw-general] Re: model validation

2008-04-25 Thread Greg Donald
On Mon, Apr 21, 2008 at 3:20 PM, Greg Donald <[EMAIL PROTECTED]> wrote:
> Is Zend_Db the "model" portion of ZF?  If so, where does one define
>  data validations?  I found Zend_Validator but it doesn't seem to be
>  used with Zend_Db in any of the documentation I've read up to now.
>  Wouldn't the two go hand in hand?  What am I missing here?  Is there
>  other documentation not listed on the Zend site?

Anyone know where I might find an example for how to best go about
connecting these two since they aren't already connected in any way?

In a nutshell I'd like to make saving the model fail if it doesn't validate.


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Re: web services

2008-04-25 Thread Greg Donald
On Fri, Apr 25, 2008 at 2:52 PM, till <[EMAIL PROTECTED]> wrote:
> require_once 'Zend/Rest/Client.php';
>  $client = new Zend_Rest_Client('http://www.webservicex.net/');
>  $client->symbol('EBAY');
>  $result = $client->get('/stockquote.asmx/GetQuote');
>
>  var_dump($result);
>  ?>
>
>  When "stockquote.asmx is added to the endpoint (in construct), it
>  fails for me as well. I am still stuck on 1.5PR though. Maybe Darbey
>  or Matthew can enlighten us.


Thanks, I guess.


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Re: zend rest service

2008-04-25 Thread Greg Donald
On Fri, Apr 25, 2008 at 2:56 PM, till <[EMAIL PROTECTED]> wrote:
>  The way this works is that you attach your service class to the REST
>  server and let it handle all requests from there.  And the methods if
>  the class have to be statics, that's all. I know there is no real
>  example, but I think it works along the lines of Zend_XmlRpc_Server
>  (haven't tried it though).


No real example, I see.


Thanks,


-- 
Greg Donald
http://destiney.com/


[fw-general] Re: zend rest service

2008-04-25 Thread Greg Donald
On Wed, Apr 23, 2008 at 3:40 PM, Greg Donald <[EMAIL PROTECTED]> wrote:
> In these docs:
>
>  http://framework.zend.com/manual/en/zend.rest.server.html
>
>  there is a require for My/Service/Class.php.  What might that class look 
> like?


Anyone?


Thanks,


-- 
Greg Donald
http://destiney.com/


[fw-general] Re: web services

2008-04-25 Thread Greg Donald
On Wed, Apr 23, 2008 at 3:04 PM, Greg Donald <[EMAIL PROTECTED]> wrote:
> Is this the part of ZF to use to consume web services?
>
>  http://framework.zend.com/manual/en/zend.rest.client.html
>
>
>  I'm trying to work with this:
>
>  http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=EBAY
>
>
>  Here's my non-working code:
>
>  require_once 'Zend/Rest/Client.php';
>  $client = new Zend_Rest_Client(
>  'http://www.webservicex.net/stockquote.asmx' );
>  $client->symbol = 'EBAY';
>  $this->view->result = $client->GetQuote();


Anyone have any insight into this issue?  At least let me know if I'm
headed in the right direction?


Thanks,


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Zend_Uri

2008-04-25 Thread Greg Donald
On Thu, Apr 24, 2008 at 2:58 PM, Josh Team <[EMAIL PROTECTED]> wrote:
> I think the idea

I have a clear understanding of what a framework is for, thanks.

> with any large framework

ZF is not large by any stretch of the imagination, especially when you
discount the useless parts.

> is to replace code replication all
> over the place the "many serious web developers already have" into one,
> coherent, reusable & maybe integrated code piece with the framework.

It's an edge case at best, a 30 second task for Google, or a 10 second
task to copy and pasting from an existing code base.  Regular
expressions for URL validation are not in short supply.

And then recognize the fact that Zend_Uri isn't aware of anything in
the Zend_Route* stuff, so where is the reuse exactly?  Do they think
we're so incapable that we can't code up a valid URL using an anchor
tag?  It's insulting.


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] inconsistent case folding

2008-04-25 Thread Greg Donald
On Thu, Apr 24, 2008 at 3:30 PM, Josh Team <[EMAIL PROTECTED]> wrote:
> I do know all Zend_Framework classes are easily extended for
> extra functionality needs.

In this particular instance I don't need "extra" functionality.  I
just need the existing functionaility to work consistently.


-- 
Greg Donald
http://destiney.com/


[fw-general] Zend_Uri

2008-04-24 Thread Greg Donald
Are there any plans to make Zend_Uri aware of Zend_Controller_Router* ?

Being able to do something like

Zend_Uri::factory( 'controller' => 'foo', 'action' => 'bar' );

_might_ be useful.

Otherwise Zend_Uri seems fairly useless.  Any serious web developer
already has a good URL validation regex lying around.


-- 
Greg Donald
http://destiney.com/


[fw-general] inconsistent case folding

2008-04-24 Thread Greg Donald
Anyone know why CASE_FOLDING seems to only work in one direction?

I have

$options = array(
Zend_Db::CASE_FOLDING => Zend_Db::CASE_LOWER
);

And I'm using the PDO driver the docs say is required for case folding:

$db = new Zend_Db_Adapter_Pdo_Oci( array(
  'username' => $config->db->username,
  'password' => $config->db->password,
  'dbname'   => $config->db->dbname,
  'host' => $config->db->host,
  'port' => $config->db->port,
  'options'  => $options
));

So then

$select->from( $stats, array( 'count' ) )

doesn't work, but

$select->from( $stats, array( 'COUNT' ) )

does work.  Why the inconsistent behaviour?


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Zend_Registry is good for?

2008-04-24 Thread Greg Donald
On 4/24/08, till <[EMAIL PROTECTED]> wrote:
> IMO, Zend_Registry offers a clean API that is what makes it maintainable.

How exactly is using the existing PHP $GLOBALS array unmaintainable?
There's already a suitable API for it, it's called PHP.

>  Some people do:
>
>  if (!isset($foo['bar'])) ...
>  if (!$foo['bar'])
>  if ($foo['bar'] !== null)
>
>  I guess there are more ways to check if "bar" exists in $foo and
>  offering a clean approach is an advantage for me, isRegistered is
>  exactly one.

No, it's not exactly one, it just adds _one more_ way to all the
existing ways.  It doesn't make the existing ways go away, they still
very much exist.

>  Let alone the other methods mentioned in the docs, such as access
>  methods (as object, as array).

There is absolutely nothing in Zend_Registry that can't be done with
smaller syntax and less overhead using just PHP arrays.  It's
pointless.

> Oh yeah, I guess you can search for everything like that. =)

There's no guessing to it, grep works great, and if the result list is
long then piping to another grep to reduce the results further is
always an option.  I use grep -v _all the time_.

>  I mean, point taken that works for a small app, I don't wanna skim
>  through the output of a larger one. But I guess that is totally up to
>  what you prefer.

Preference to less overhead shouldn't ever be a preference, it should
be job #1 on any developer's mind.  Less code, not more, faster code
not slower.  OO for the sake of OO is a waste of resources.

>  Yes, because they are already called components, and no because this
>  type of framework is called a glue framework.

The world already has a glue framework, it's called Perl.


-- 
Greg Donald
http://destiney.com/


Re: [fw-general] Zend_Registry is good for?

2008-04-24 Thread Greg Donald
On 4/23/08, till <[EMAIL PROTECTED]> wrote:
> Of course you can do that, but Zend_Registry for me offers the
>  advantage of clean maintainable code.

How exactly is using the existing PHP $GLOBALS variable unclean or
unmaintainable?

>  Do a couple unsets to your $GLOBALS['registry'] and a dozen checks if
>  a value is set, then hide it in the middle of an application and then
>  let someone else figure out the code. As of when it's used, and where
>  etc..

grep -r GLOBALS .

> In general, many things you could achieve by coding it up
>  yourself, but that is not really the point of a framework.

Zend "Components" seems a much more appropriate name since nothing is
integrated with anything else.  Wrapping an OO layer around an
existing feature doesn't make it a framework.


-- 
Greg Donald
http://destiney.com/


[fw-general] Zend_Registry is good for?

2008-04-23 Thread Greg Donald
What is gained by using Zend_Registry?  Seems to me I could more
easily use the existing PHP $GLOBALS or even $GLOBALS['registry'] if I
wanted/needed a namespace.


Zend_Registry::set('index', $value);

versus

$GLOBALS['index'] = $value;


$value = Zend_Registry::get('index');

versus

$value = $GLOBALS['index'];


foreach ($registry as $index => $value) {
echo "Registry index $index contains:\n";
var_dump($value);
}

versus

foreach ($GLOBALS['registry'] as $index => $value) {
echo "Registry index $index contains:\n";
var_dump($value);
}


I really don't see the point.


-- 
Greg Donald
http://destiney.com/


[fw-general] zend rest service

2008-04-23 Thread Greg Donald
In these docs:

http://framework.zend.com/manual/en/zend.rest.server.html

there is a require for My/Service/Class.php.  What might that class look like?

I'm amazed at how the page contains "Zend_Rest_Server is intended as a
fully-featured REST server" when it doesn't even show how one might
begin to process a single one of the the four REST verbs.


-- 
Greg Donald
http://destiney.com/


[fw-general] web services

2008-04-23 Thread Greg Donald
Is this the part of ZF to use to consume web services?

http://framework.zend.com/manual/en/zend.rest.client.html


I'm trying to work with this:

http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=EBAY


Here's my non-working code:

require_once 'Zend/Rest/Client.php';
$client = new Zend_Rest_Client(
'http://www.webservicex.net/stockquote.asmx' );
$client->symbol = 'EBAY';
$this->view->result = $client->GetQuote();


Thanks,


-- 
Greg Donald
http://destiney.com/


[fw-general] rest docs example has a bad url

2008-04-23 Thread Greg Donald
The docs here:

http://framework.zend.com/manual/en/zend.rest.client.html

show using this URL in the example:

http://framework.zend.com/rest


I'm guessing something needs fixed or updated?



-- 
Greg Donald
http://destiney.com/


[fw-general] model validation

2008-04-21 Thread Greg Donald
Is Zend_Db the "model" portion of ZF?  If so, where does one define
data validations?  I found Zend_Validator but it doesn't seem to be
used with Zend_Db in any of the documentation I've read up to now.
Wouldn't the two go hand in hand?  What am I missing here?  Is there
other documentation not listed on the Zend site?


Thanks,


-- 
Greg Donald
http://destiney.com/


[fw-general] Admin Area

2008-04-03 Thread Greg Freeman

What is the best method for creating an admin area for a zend framework
application?

I am looking for some examples if possible i.e do you use a module or two
different bootstrap files (like some other frameworks).

If you could provide the directory structure that you use as well that would
be greatly appreciated.
-- 
View this message in context: 
http://www.nabble.com/Admin-Area-tp16482518p16482518.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Form - config & HtmlTag

2008-04-02 Thread Greg Frith
div

input_submit




    



:wq
Greg

On 2 Apr 2008, at 16:21, Matthew Weier O'Phinney wrote:


Answer way down below...

-- Greg Frith <[EMAIL PROTECTED]> wrote
(on Wednesday, 02 April 2008, 03:17 PM +0100):
I fear this might not be my first post to the group in the next day  
or
to in relation to Zend_Form, I just don't seem to be getting a  
complete

grasp of it yet.

My first problem.  I am trying to implement mark-up for an element  
like

this:


Password:

Forgotten Password


I configure my form using an XML config.  I can get the form element
wrapped in the div without any problems using the following config
snippet (which is the element configuration for this element):


password

Password:


alnum
true


StringLength

5
20





ViewHelper


label


HtmlTag

div
input_password






Now I understand that I cannot add a second HtmlTag decorator, but  
can
anyone suggest any other way of achieving my element layout (adding  
the
additional 'Forgotten Password' after the  
input

element) without using a customer decorator class?


Actually, you *can* add additional decorators of the same class using
aliasing. Try this:

   
   
   
   
   
   ViewHelper
   
   
   Label
   
   
   
   HtmlTag
   
   
   div
   input_password
   
   
   
   
   HtmlTag
   
   
   p
   
   
   
   
   

The relevant parts are the  and  decorators -- notice that the
type in each is an array consisting of a single key/value pair -- the
key is the internal alias by which you'll refer to it, and the value  
is

the actual decorator type.

That said, you probably want to use the element description for  
setting
that particular content, and then add a 'Description' decorator to  
your

decorator stack.

--
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/




[fw-general] Zend_Form - config & HtmlTag

2008-04-02 Thread Greg Frith

Hi all,

I fear this might not be my first post to the group in the next day or  
to in relation to Zend_Form, I just don't seem to be getting a  
complete grasp of it yet.


My first problem.  I am trying to implement mark-up for an element  
like this:



Password:

Forgotten Password


I configure my form using an XML config.  I can get the form element  
wrapped in the div without any problems using the following config  
snippet (which is the element configuration for this element):



password

Password:


alnum
true


StringLength

5
20





ViewHelper


label


HtmlTag

div
input_password






Now I understand that I cannot add a second HtmlTag decorator, but can  
anyone suggest any other way of achieving my element layout (adding  
the additional 'Forgotten Password' after the  
input element) without using a customer decorator class?


The more observant amongst the group might notice I posted a different  
Zend_Form question a week or so ago...  Don't worry...  I'm not that  
slow, I've only just got back to my forms today!!


:wq
Greg.




[fw-general] Zend_Form, config and numeric option values

2008-03-19 Thread Greg Frith

Hi all,

I've hit a slight issue with Zend_Form and my XML config file and am  
wondering if anyone can suggest a way to work around this.  Here is  
the definition for one of my forms fields from my config file:



radio

How would you rate the show:

<5>Loved it
<4>It was good
<3>So / So
<2>Not so Great
<1>Not my thing




I think the problem should be quite evident.  I wish values for each  
option to be numeric, however numeric values are not valid XML element  
names as passed in via the multiOptions block.


Can anybody suggest any alternative way of creating the options from  
an XML config which would allow me to use numeric values.  I  
appreciate I could set the options on this element from within my  
code, but I would rather avoid this if at all possible.


:eq
Greg Frith.


Re: [fw-general] Warning: require_once(Zend/Mime.php) [function.require-once]: failed to open stream

2008-03-03 Thread Greg Maruszeczka
On Sat, 1 Mar 2008 16:58:26 -0800 (PST)
Maceman <[EMAIL PROTECTED]> wrote:

> 
> Warning: require_once(Zend/Mime.php) [function.require-once]: failed
> to open stream: No such file or directory in
> /home/gameany/public_html/library/Zend/Gdata/App/MediaEntry.php on
> line 35
> 
> Fatal error: require_once() [function.require]: Failed opening
> required
> 'Zend/Mime.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')
> in /home/gameany/public_html/library/Zend/Gdata/App/MediaEntry.php on
> line 35
> 
> 
> That is the error I get when trying to use the Google Data Library. It
> didn't come with a Mime.php file. Whats up?



Did you only pull out the Gdata sub-directory from the rest of the
framework in your app? You need to account for any intra-framework
dependencies as well. In this case Mime.php, which is in the root Zend
directory (at least my copies of 1.0.4 and 1.50RC1).

Also make sure your include_path actually includes the Zend root
directory or it won't find it even if it is there.

HTH,
GM

-- 
   
Greg Maruszeczka

http://websagesolutions.com
skype: websage.ca
googletalk: gmarus


Re: [fw-general] Warning: require_once(Zend/Mime.php) [function.require-once]: failed to open stream

2008-03-01 Thread Greg Maruszeczka
On Sat, 1 Mar 2008 16:58:26 -0800 (PST)
Maceman <[EMAIL PROTECTED]> wrote:

> 
> Warning: require_once(Zend/Mime.php) [function.require-once]: failed
> to open stream: No such file or directory in
> /home/gameany/public_html/library/Zend/Gdata/App/MediaEntry.php on
> line 35
> 
> Fatal error: require_once() [function.require]: Failed opening
> required
> 'Zend/Mime.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')
> in /home/gameany/public_html/library/Zend/Gdata/App/MediaEntry.php on
> line 35
> 
> 
> That is the error I get when trying to use the Google Data Library. It
> didn't come with a Mime.php file. Whats up?



Did you only pull out the Gdata sub-directory from the rest of the
framework in your app? You need to account for any intra-framework
dependencies as well. In this case Mime.php, which is in the root Zend
directory (at least my copies of 1.0.4 and 1.50RC1).

Also make sure your include_path actually includes the Zend root
directory or it won't find it even if it is there.

HTH,
GM

-- 
   
Greg Maruszeczka

http://websagesolutions.com
skype: websage.ca
googletalk: gmarus


Re: [fw-general] Zend_Form Config

2008-02-15 Thread Greg Frith

Hi all,

Thanks to assistance from Matthew, I have now resolved this problem by  
changing my Zend code base to the latest trunk (r8024).


Apologies for reporting this issue without first checking the latest  
code.  FYI I was previously using 1.5.0PR.


:wq
G.

On 15 Feb 2008, at 08:18, Greg Frith wrote:



On 14 Feb 2008, at 21:50, Matthew Weier O'Phinney wrote:


Thanks Matthew,

Have tried this (see below) but still the extra prefix and path  
are not added

to element pluginloaders.


Odd -- I just tried this on my own box, using the config you  
provided,
and it worked fine; here's a portion of a var_export() I did on my  
form

object:

   'VALIDATE' =>
   Zend_Loader_PluginLoader::__set_state(array(
  '_prefixToPaths' =>
 array (
   'Zend_Validate_' =>
   array (
 0 => 'Zend/Validate/',
   ),
   'WETB_Validate_' =>
   array (
 0 => 'WETB/Validate/',
   ),
 ),
  '_loadedPlugins' =>
 array (
   'WordChars' => 'WETB_Validate_WordChars',
   'StringLength' => 'Zend_Validate_StringLength',
 ),
  '_useStaticRegistry' => NULL,
   )),

As you can see, the plugin loader has the path, and the validator was
loaded (I created a dummy validator so I could test).

Are you using current trunk? If not, could you send me a copy of your
code and config file offline so I can see if I can diagnose the  
issue?


--
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/


Hi Matthew,

No sorry, I should have specified earlier, I am using version  
1.5.0PR.  I will check out the trunk and try again before we go any  
further.


Many thanks,

:wq
Greg




Re: [fw-general] Zend_Form Config

2008-02-15 Thread Greg Frith


On 14 Feb 2008, at 21:50, Matthew Weier O'Phinney wrote:


Thanks Matthew,

Have tried this (see below) but still the extra prefix and path are  
not added

to element pluginloaders.


Odd -- I just tried this on my own box, using the config you provided,
and it worked fine; here's a portion of a var_export() I did on my  
form

object:

   'VALIDATE' =>
   Zend_Loader_PluginLoader::__set_state(array(
  '_prefixToPaths' =>
 array (
   'Zend_Validate_' =>
   array (
 0 => 'Zend/Validate/',
   ),
   'WETB_Validate_' =>
   array (
 0 => 'WETB/Validate/',
   ),
 ),
  '_loadedPlugins' =>
 array (
   'WordChars' => 'WETB_Validate_WordChars',
   'StringLength' => 'Zend_Validate_StringLength',
 ),
  '_useStaticRegistry' => NULL,
   )),

As you can see, the plugin loader has the path, and the validator was
loaded (I created a dummy validator so I could test).

Are you using current trunk? If not, could you send me a copy of your
code and config file offline so I can see if I can diagnose the issue?

--
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/


Hi Matthew,

No sorry, I should have specified earlier, I am using version  
1.5.0PR.  I will check out the trunk and try again before we go any  
further.


Many thanks,

:wq
Greg

Re: [fw-general] Zend_Form Config

2008-02-14 Thread Greg Frith

On 14 Feb 2008, at 13:11, Matthew Weier O'Phinney wrote:


-- Greg Frith <[EMAIL PROTECTED]> wrote
(on Thursday, 14 February 2008, 12:24 PM +):
I'm trying to use my XML config file to add custom validator paths  
to every

element in a Zend_Form instance.

Here is an extract from my configuration file (this is the config  
tree I pass

to new Zend_Form):

userRegister
/authentication/register/
post



The above should be singular (even though it allows for multiple
entries): 'elementPrefixPath'. That should solve your issue, including
the exception from attempting to load the custom validator class.


Thanks Matthew,

Have tried this (see below) but still the extra prefix and path are  
not added to element pluginloaders.


userRegister
/authentication/register/
post


WETB_Validate
WETB/Validate
validate




text

Surname:



StringLength

1
20





.

function registerAction() {
$form = new Zend_Form($this->config->forms->userRegistration);

$fn = $form->getElement('firstname');

$p = $fn->getPluginLoader('validate');
print_r($p->getPaths());

.

Will still output:

Array ( [Zend_Validate_] => Array ( [0] => Zend/Validate/ ) )

:wq
G






WETB_Validate
WETB/Validate
validate




select
.

Here is a snippet of the function I am then using to test:

function registerAction() {
$form = new Zend_Form($this->config->forms->userRegistration);
$fn = $form->getElement('firstname');
$p = $fn->getPluginLoader('validate');
print_r($p->getPaths());
.

The print_r statement outputs:

Array ( [Zend_Validate_] => Array ( [0] => Zend/Validate/ ) )

I would expect this array to also contain the custom path.

In addition, the plugin loader throws an exception if I try to use  
a custom

validator class.

Any ideas?

:wq
Greg.


--
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/




[fw-general] Zend_Form Config

2008-02-14 Thread Greg Frith

Hi all,

I'm trying to use my XML config file to add custom validator paths to  
every element in a Zend_Form instance.


Here is an extract from my configuration file (this is the config tree  
I pass to new Zend_Form):


userRegister
/authentication/register/
post


WETB_Validate
WETB/Validate
validate




select
.

Here is a snippet of the function I am then using to test:

function registerAction() {
$form = new Zend_Form($this->config->forms->userRegistration);

$fn = $form->getElement('firstname');

$p = $fn->getPluginLoader('validate');
print_r($p->getPaths());
.

The print_r statement outputs:

Array ( [Zend_Validate_] => Array ( [0] => Zend/Validate/ ) )

I would expect this array to also contain the custom path.

In addition, the plugin loader throws an exception if I try to use a  
custom validator class.


Any ideas?

:wq
Greg.

[fw-general] Separation of Public/Admin

2007-10-08 Thread Greg Freeman

Hello,

I have been using symfony for some time and it has helped my productivity a
lot. I am really interested in giving ZF a go in an upcoming project.

I have used ZF components before like lucene (fantastic by the way).

One thing I am used too in symfony is the separation of applications (i.e
public frontend / admin backend). How do you achieve this in ZF? I have only
read about module separation not application separation.

Thank You!

Btw thanks to Matthew Weier O'Phinney for the great webinar on zend
controllers - very informative.
-- 
View this message in context: 
http://www.nabble.com/Separation-of-Public-Admin-tf4586595s16154.html#a13092317
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Deploy Zend MVC application

2007-08-29 Thread Greg Maruszeczka
On Wed, 29 Aug 2007 07:30:53 -0700 (PDT)
Kexiao  Liao <[EMAIL PROTECTED]> wrote:

> 
> When we deploy Zend MVC application to the production site using
> apache web server, the Zend MVC requires the boostrapper file reside
> the apache document_root directory or you can make an alias in the
> apache httpd.conf file and put the boostrapper file(index.php) in the
> directory related to that alias. 
> 
> Can we deploy Zend MVC application to the production site without
> above requirement?
> 
>


Hi,

If you're just uncomfortable with putting your bootstrapper code in the
public view why not just do something like this in your index.php
residing in the document_root?

index.php:

http://websage.ca


[fw-general] Zend Rest

2007-08-17 Thread Greg Freeman

I'm a little confused with zend rest. Could someone provide me with an
example to connect to youtube's api?

http://youtube.com/dev_rest

Help appreciated thanks.
-- 
View this message in context: 
http://www.nabble.com/Zend-Rest-tf4285416s16154.html#a12198709
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Routing problem

2007-08-15 Thread Greg Frith

Hi all,

I'm having some routing problems which I don't necessarily think the  
group are going to be able to answer directly, but maybe give me some  
pointers as to how I may debug further.


I have developed a site on my local machine where everything is  
working just fine.  Yesterday I copied the site over to a second  
development server for my colleagues to start reviewing.  However, on  
the development server I'm getting an awful lot of  
Zend_Controller_Dispatcher_Exception exceptions thrown with the  
message 'Invalid controller specified ().


I say an awful lot as not every request results in this.  My default  
index controller works fine, as does my Book controller, but all  
others fail (please note that book controller is the real thing, and  
not a typical library book example file!  Its part of a booking  
process).  My directory structure is as follows:


www/application/
www/application/config/
www/application/modules/
www/application/modules/default/
www/application/modules/default/controller/
www/application/modules/default/controller/BookController.php
www/application/modules/default/controller/ComingSoonController.php
www/application/modules/default/controller/IndexController.php
www/application/modules/default/controller/StaticPagesController.php
www/application/modules/default/views/
www/application/templates/
www/htdocs/ <- doc root

As I say, the BookController and IndexController work fine, but  
ComingSoonController and StaticPagesController are not found.


During a request for /comingsoon/index the request object looks like  
this:


2007-08-15T08:03:32+01:00 DEBUG (7): Zend_Controller_Request_Http Object
(
[_requestUri:protected] => /default/ComingSoon/index/
[_baseUrl:protected] =>
[_basePath:protected] =>
[_pathInfo:protected] => /default/ComingSoon/index/
[_params:protected] => Array
(
[module] => default
[controller] => ComingSoon
[action] => index
)

[_aliases:protected] => Array
(
)

[_dispatched:protected] => 1
[_module:protected] => default
[_moduleKey:protected] => module
[_controller:protected] => ComingSoon
[_controllerKey:protected] => controller
[_action:protected] => index
[_actionKey:protected] => action
)

So the correct modules, controller and action parameters are being  
taken from the URL.


All the controllers are working fine with exactly the same code on a  
local development machine.  The only real difference being the the  
development machine has a local hostname and uses Apache Virtual  
Hosts, whereas the new testing server on which the site fails is  
accessed over the internet via its IP address.  There is no domain  
registered against it.


Some relevant lines from my bootstrap:

// Get front controller
$controller = Zend_Controller_Front::getInstance();

$modules = array('default',"$modulesDir/default/controller/");

$controller->setControllerDirectory($modules);

*  NOTE THE ABOVE LINES HAVE BEEN ADDED TO TRY AND RESOLVE THE  
ISSUE, THEY WERE NOT REQUIRED ON THE WORKING SERVER *


// Add some additional routes - if we keep these they should come  
from a config

$router = $controller->getRouter();
$router->addRoute('shows', new Zend_Controller_Router_Route 
('shows/:event',

array('controller'=>'findashow','action'=>'showInfo')));
$router->addRoute('InsiderTips',new Zend_Controller_Router_Route 
('insidertips/:article',

array('controller'=>'staticPages',
'artion'=>'index',
'article'=>'insidertips',
'category'=>'insidertips')));
$router->addRoute('whyus',new Zend_Controller_Router_Route 
('whyus/:article',

array('controller'=>'staticPages',
'artion'=>'index',
'article'=>'whyus',
'category'=>'whyus')));
$router->addRoute('whybookapackage',new Zend_Controller_Router_Route 
('whybookapackage/:article',

array('controller'=>'staticPages',
'artion'=>'index',
'article'=>'whybookapackage',
'category'=>'whybookapackage')));

Could anyone suggest any where I might start looking and debugging  
further?  Perhaps somewhere where the actual path to the action  
controller is generated and an attempt is made to instantiate the  
class might give me some clues as to what's going wrong?


--
Greg Frith
[EMAIL PROTECTED] : +44 7970 925 257

MSN: [EMAIL PROTECTED]
Jabber: [EMAIL PROTECTED]
Skype: gregfrith





  1   2   >