Issue Type: Docs: Problem Created: 2009-05-03T01:35:34.000+0000 Last Updated: 2009-09-19T10:26:12.000+0000 Status: Resolved Fix version(s): - 1.9.3 (22/Sep/09)
Reporter: Kazusuke Sasezaki (sasezaki) Assignee: Ralph Schindler (ralph) Tags: - Zend_Tool
Related issues: Attachments:
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 "
Posted by mosen f (mosen) on 2009-07-09T18:53:41.000+0000
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.
Posted by Benjamin Eberlei (beberlei) on 2009-09-19T10:26:12.000+0000
Documentation was heavily extended with information on how to get a provider loaded by Zend_Tool for 1.9.3 documentation (if its rebuild)
Have you found an issue?
See the Overview section for more details.