ZF-6501: Sample Code "My_Component_HelloProvider" not work

Description

i try creating providers with http://framework.zend.com/svn/framework/…

but sample code "class My_Component_HelloProvider" not work. "class My_Component_Hello" is work.

and if coding "class My_Component_HelloProvider" wll raise "error Undefined Index " in /usr/share/php/Zend/Tool/Framework/Provider/Repository.php on line 226, and Fatal errors "Call to a member function getProvider() on a non-object "

Comments

I have had this problem with the example too, and tell me if im wrong, but this is what ive discovered, based on the source.

The reason why the example does not work is because of the interaction between Zend_Tool_Framework_Loader_IncludePathLoader and Zend_Tool_Framework_Provider_Signature.

There are a number of options for making the example work. The reason why the suggested class rename works is because: 1. The word 'Provider' is stripped by Zend_Tool_Framework_Provider_Signature from the classname, the provider name becomes 'Hello' regardless of whether the name of the class is 'HelloProvider' or 'Hello'. 2. The IncludePathLoader only loads files with name similar to 'Manifest' or 'Provider', so the filename must remain HelloProvider.php. 3. Invoking the 'Hello' provider expects a class that ends in _Hello, which is not the case in the example.

The incorrect determination of the providers classname can be avoided by providing a getName() public method in the class definition of HelloProvider, which returns 'HelloProvider'. But this is not the intention of the tutorial, as this results in a provider called hello-provider eg: zf say hello-provider.

The way that the included System provider and Project providers avoid this is to use manifest classes which provide instances of the providers, instead of inflecting the provider names from the classnames.

To have the example work as intended, either the instantiation of the provider must adhere to the rules of Signature, which is to strip, via preg, 'Provider' and 'Manifest' from the name OR you must provide a manifest which returns an instance of the Hello provider.

Ultimately Repository::_parseName() must follow the same rules as Signature::_processName(), which are currently different: the former using the classname in whole as the provider name, the latter using the name, stripped of 'Provider' or 'Manifest' strings.

Hopefully this provides some insight into the discrepancy, which only happens to providers that are free-standing i.e without manifest.

Documentation was heavily extended with information on how to get a provider loaded by Zend_Tool for 1.9.3 documentation (if its rebuild)