Hi
Yeah the first error was an old checkout problem, the second I am
still having a problem with. I have this problem on both ubuntu PHP
5.2.4 and OSX MAMP 5.2.5, I am guessing that I must be doing something
wrong.
If I var_dump on line 94 of Zend_Application_Bootstrap_Base (Base.php)
var_dump(get_class_methods($this));
array
0 => string '_initFrontController' (length=20)
1 => string '_initRequest' (length=12)
2 => string 'run' (length=3)
3 => string '__construct' (length=11)
4 => string 'setOptions' (length=10)
5 => string 'getOptions' (length=10)
6 => string 'getClassResources' (length=17)
7 => string 'getClassResourceNames' (length=21)
8 => string 'registerPluginResource' (length=22)
9 => string 'unregisterPluginResource' (length=24)
10 => string 'hasPluginResource' (length=17)
11 => string 'getPluginResource' (length=17)
12 => string 'getPluginResources' (length=18)
13 => string 'getPluginResourceNames' (length=22)
14 => string 'setPluginLoader' (length=15)
15 => string 'getPluginLoader' (length=15)
16 => string 'getApplication' (length=14)
17 => string 'getEnvironment' (length=14)
18 => string 'bootstrap' (length=9)
19 => string '__call' (length=6)
20 => string '_executeResource' (length=16)
21 => string '_markRun' (length=8)
Heres my setup:
application/bootstrap.php
<?php
$paths = array(
get_include_path(),
'../library',
'../library/Incu',
'../library/Zapp'
);
set_include_path(join(PATH_SEPARATOR, array_reverse($paths)));
defined('APPLICATION_PATH')
or define('APPLICATION_PATH', realpath(dirname(__FILE__) .
'/../application'));
defined('APPLICATION_ENV')
or define('APPLICATION_ENV', 'development');
require_once 'Zend/Application.php';
/**
* Now there are multiple ways to set up the application. Firstly, the way via
* options or Zend_Config:
*/
$application = new Zend_Application(APPLICATION_ENV, array(
'bootstrap' => APPLICATION_PATH . '/bootstrap/Bootstrap.php',
'autoloadernamespaces' => array('Zend', 'SF')
)
);
$application->bootstrap();
//var_dump($application);
application/bootstrap/bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Base
{
public function _initFrontController()
{
$this->front = Zend_Controller_Front::getInstance();
}
protected function _initControllers()
{
die('XXX'); // never gets called?????
// runs _initFrontController() if not already run:
$this->bootstrapFrontController();
$this->front->addModuleDirectory(MODULE_PATH . '/modules');
}
public function _initRequest()
{
// runs _initFrontController() if not already run:
$this->bootstrapFrontController();
$this->request = new Zend_Controller_Request_Http;
$this->front->setRequest($this->request);
}
public function run()
{
$this->front->dispatch();
}
}
Full code here:
http://code.google.com/p/zendframeworkstorefront/source/browse/#svn/branches/TRY-KP-Zapp
hope this helps
Thx
Keith
2009/2/28 Matthew Weier O'Phinney <[email protected]>:
> -- keith Pope <[email protected]> wrote
> (on Saturday, 28 February 2009, 08:27 PM +0000):
>> Just doing some bits with Zend_App, In have two minor issues currently.
>>
>> When creating a bootstrap file, it keeps bugging me about abstract
>> method unregisterPluginResource saying that it needs to be
>> implemented.
>
> I'm thinking you don't have an up-to-date checkout, or that you're
> extending the wrong class.
>
> unregisterPluginResource() is defined in
> Zend_Application_Bootstrap_IResourceBootstrap, which is in turn
> implemented in Zend_Application_Bootstrap_Base -- and it's clearly
> defined (I'm looking at it right now -- lines 195-214 of that class
> file).
>
> So, either extend Zend_Application_Bootstrap_Base, or implement
> Zend_Application_Bootstrap_IResourceBootstrap in your bootstrap class.
>
>> Also to get the bootstrap to call my init methods they have to be
>> public not protected, I have tracked this to:
>>
>> $options = $application->getOptions();
>> $this->setOptions($options);
>> foreach (get_class_methods($this) as $method) {
>> if (5 < strlen($method) && '_init' === substr($method, 0, 5)) {
>> $this->_classResources[strtolower(substr($method, 5))]
>> = $method;
>> }
>> }
>>
>> The get_class_methods($this) seems to only return public methods?
>> Seems maybe more a PHP bug than anything, the only bug I could find
>> associated with this was http://bugs.php.net/bug.php?id=43483. My PHP
>> version is 5.2.5.
>
> get_class_methods() will return *all* methods when run on $this, and
> only *public* methods when run over a concrete instance. As an example,
> try the following:
>
> class Foo
> {
> public function foo()
> {
> }
>
> protected function _bar()
> {
> }
>
> public function __call($method, $args)
> {
> $methods = get_class_methods($this);
> echo "Methods internally:\n" . var_export($methods, 1) . "\n";
> }
> }
>
> $o = new Foo;
> $o->baz();
>
> $methods = get_class_methods($o);
> echo "Methods from instance:\n" . var_export($methods, 1) . "\n";
>
> You should then get the following output:
>
> Methods internally:
> array (
> 0 => 'foo',
> 1 => '_bar',
> 2 => '__call',
> )
> Methods from instance:
> array (
> 0 => 'foo',
> 1 => '__call',
> )
>
> The same behavior is true even when extending the class -- if you were
> to define "class Bar extends Foo {}" and then substitute "$o = new Bar;"
> above, you'd get the exact same behavior.
>
> This has been the documented behavior of get_class_methods() since
> 5.0.0; if you're not seeing that, then I'm wondering if you've got a PHP
> version with a vendor patch of some sort; if so, then you'll need to
> make the methods public to work with your PHP version.
>
> (BTW, Zend_View unit tests have relied on this behavior since before the
> first public preview release of ZF...)
>
>> My bootstrap:
>>
>> class Bootstrap extends Zend_Application_Bootstrap_Base
>> {
>> public function _initFrontController()
>> {
>> $this->front = Zend_Controller_Front::getInstance();
>> }
>>
>> // not called???
>> protected function _initControllers()
>> {
>> // runs _initFrontController() if not already run:
>> $this->bootstrapFrontController();
>>
>> $this->front->addModuleDirectory(MODULE_PATH . '/modules');
>> }
>>
>> // called!
>> public function _initRequest()
>> {
>> // runs _initFrontController() if not already run:
>> $this->bootstrapFrontController();
>>
>> $this->request = new Zend_Controller_Request_Http;
>> $this->front->setRequest($this->request);
>> }
>>
>> public function run()
>> {
>> $this->front->dispatch();
>> }
>>
>> // had to add this????
>> public function unregisterPluginResource($resource){}
>> }
>>
>> My setup:
>>
>> $paths = array(
>> get_include_path(),
>> '../library',
>> '../library/Incu',
>> '../library/Zapp'
>> );
>> set_include_path(join(PATH_SEPARATOR, array_reverse($paths)));
>>
>> defined('APPLICATION_PATH')
>> or define('APPLICATION_PATH', realpath(dirname(__FILE__) .
>> '/../application'));
>> defined('APPLICATION_ENV')
>> or define('APPLICATION_ENV', 'development');
>>
>> require_once 'Zend/Application.php';
>>
>> /**
>> * Now there are multiple ways to set up the application. Firstly, the way
>> via
>> * options or Zend_Config:
>> */
>> $application = new Zend_Application(APPLICATION_ENV, array(
>> 'bootstrap' => APPLICATION_PATH . '/bootstrap/Bootstrap.php',
>> 'autoloadernamespaces' => array('Zend', 'SF')
>> )
>> );
>>
>> $application->bootstrap();
>>
>> var_dump($application);
>
>
> --
> Matthew Weier O'Phinney
> Software Architect | [email protected]
> Zend Framework | http://framework.zend.com/
>
--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------