Where should My_Validate_PasswordConfirmation put in Zend framework? - zend-framework

I am using the password confirmation validator from the official Zend framwork document here:
http://framework.zend.com/manual/en/zend.form.elements.html
In Bootstrap.php, I have set the namespace as
'namespace' => 'My_'
The file is located at
application/validate/PasswordConfirmation.php
However, "Fatal error: Class 'My_Validate_PasswordConfirmation' not found" occurs in my Zend_Form.
What should I do to fix the problem?

I designed and implemented Zend_Filter_Input, including its namespace feature.
You have a backwards understanding of how this feature works. It's meant to allow you to use a short name for a validator class when the actual name of that class is longer. You're apparently doing the reverse, trying to name a class with a longer name than it actually has.
To fix this I recommend the following steps:
Name the class My_Validate_PasswordConfirmation
Put it in `application/My/Validate/PasswordConfirmation.php
Add namespace=>'My_Validate' to your Zend_Filter_Input options.
Invoke the validator as simply "PasswordConfirmation".
update: I spent some time on this. It seems my first idea was off target. The namespace issue you have has nothing to do with the feature of Zend_Filter_Input, it has to do with the Zend_Application bootstrap feature. It seems that you can specify a class prefix to the autoloader.
Here's another clue:
Zend_Loader_Autoloader_Resource makes
the assumption that all code you are
autoloading will use an underscore
separator between namespaces,
components, and classes. As a result,
you do not need to use the trailing
underscore when registering a resource
autoloader.
So try this:
'namespace' => 'My',
with no trailing underscore.

Related

Symfony - why generate form is not in Type folder

I have a question I ask myself since Symfony 2 and it is still the case on 3.2
When you use the console to generate formType of entity :
doctrine:generate:form
The EntityType is in the \Form folder but not in \Form\Type
Why ?
Sensiolabs itself recommand to put it in the Type folder....
There is a way to adapt this one?
No it doesn't recommend that.
As you can see in either Symfony Doc examples or Symfony Best Practices Guide, it both use Form and not Type folder/namespace.
The second one even straightly says:
Best Practice
Put the form type classes in the AppBundle\Form namespace, unless you use other custom form classes like data transformers.
Namespace of course, means also path at the same time.
In addition, best practices recommends creating a sub namespace if other custom form classes are used (like DataTransformer).
For example, i always use :
---Form
-----------DataTransformer
-----------Type
In this case all form classes are stored in Type folder (and namespace).

Problems compiling routes after migrating to Play 2.1

After migrating to Play-2.1 I stuck into problem that routes compiler stopped working for my routes file. It's been completely fine with Play-2.0.4, but now I'm getting the build error and can't find any workaround for it.
In my project I'm using cake pattern, so controller actions are visible not through <package>.<controller class>.<action>, but through <package>.<component registry>.<controller instance>.<action>. New Play routes compiler is using all action path components except for the last two to form package name that will be used in managed sources (as far as I can get code in https://github.com/playframework/Play20/blob/2.1.0/framework/src/routes-compiler/src/main/scala/play/router/RoutesCompiler.scala). In my case it leads to situation when <package>.<component registry> is chosen as package name, which results in error during build:
[error] server/target/scala-2.10/src_managed/main/com/grumpycats/mmmtg/componentsRegistry/routes.java:5: componentsRegistry is already defined as object componentsRegistry
[error] package com.grumpycats.mmmtg.componentsRegistry;
I made the sample project to demonstrate this problem: https://github.com/rmihael/play-2.1-routes-problem
Is it possible to workaround this problem somehow without dropping cake pattern for controllers? It's the pity that I can't proceed with Play 2.1 due to this problem.
Because of reputation I can not create a comment.
The convention is that classes and objects start with upper case. This convention is applied to pattern matching as well. Looking at a string there seems to be no difference between a package object and normal object (appart from the case). I am not sure how Play 2.1 handles things, that's why this is not an answer but a comment.
You could try the new # syntax in the router. That allows you to create an instance from the Global class. You would still specify <package>.<controller class>.<action>, but in the Global you get it from somewhere else (for example a component registry).
You can find a bit of extra information here under the 'Managed Controller classes instantiation': http://www.playframework.com/documentation/2.1.0/Highlights
This demo project shows it's usage: https://github.com/guillaumebort/play20-spring-demo

Why Zend autoloader require registering namespace, seems could be avoided

I would like to know why Zend autoloader require registering namespaces. At first it seems it could be avoided, so I would like to know what I am missing :
If I want to use an external class, I have to put in libraryFolder and when I use it, I have to reference its full name :
For example, if I want to use the class in /libraryFolder/myNamespace/package_name/Class/Name.php, I have to call \myNamespace\package_name\Class_Name.
So why do I have to register myNamespace ? Zend should find the class without registering thanks to the full name \myNamespace\package_name\Class_Name being given.
I know I am missing something but not sure what.
It seems to be a effort to put some limits on how far the autoloader will look for a class, however if you want the autoloader to load anything simply set : $autoloader->setFallbackAutoloader(true);
http://framework.zend.com/manual/1.12/en/zend.loader.autoloader.html

Warning: class implemented in both SDK

I am getting the following error when running my app:
objc[59714]: Class Message is implemented in both /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/PrivateFrameworks/MIME.framework/MIME and /Users/aditya15417/Library/Application Support/iPhone Simulator/4.3.2/Applications/4EFD7570-AD87-48E8-8606-1D5633F65AD9/CTest.app/CTest. One of the two will be used. Which one is undefined.
Why is this? How do I solve this?
Do you have a class named Message? Change its name, or stop using the MIME framework.
Objective-C doesn't have namespaces like C++ does, so name collisions are possible. This is why Apple prefixes most of its class and function names with two letters, like "NS..." and "CG...". I think the Cocoa coding guidelines recommend that you do the same (using your own prefix, of course).

How can I set boilerplate information for the files generated by catalyst.pl?

When I use catalyst.pl to auto-generate my application, the AUTHOR section of the POD includes only my name like this.
Kiffin Gish,,,
What are the missing fields and how can I use them? Is it possible to use another boilerplate for the PODs?
It's using the GECOS field from your line in the passwd file (courtesy of getpwuid). You can change the author name that shows up by setting the AUTHOR environment variable, although this doesn't seem documented. As for overriding the entire thing: not so much, unless you want to write your own catalyst.pl that uses a custom subclass of Catalyst::Helper, or submit the patch to -Runtime to let everyone do that.:)