(on Saturday, 28 February 2009, 10:35 PM +0200):
> Matthew Weier O'Phinney wrote:
>
>
>
> No -- but it does reflect that the proposal needs to be updated. :)
> There is a better example in the example.php file inside DASPRiD's user
> branch.
>
>
> Yes, but it's only the index.php ;) Not the bootstrapper code...
>
> http://framework.zend.com/svn/framework/standard/branches/user/dasprid/
> Zend_Application/
>
> I checked for documentation, got some questions:
>
> 1.This component MUST allow setting the application include_path (aka library)
>
> How could be set this ?
By providing the "includePaths" key (case insensitive) in the options
passed to the Zend_Application constructor:
$app = new Zend_Application(APPLICATION_ENV, array(
'includePaths' => array(
'.',
dirname(__FILE__) . '/library',
),
));
Alternately, specify an "includePaths" key in a config file passed to
the Zend_Application constructor.
> 2. What are the minimal include path to be done into index.php (so not through
> Zend_App). Just
>
> set_include_path(
> BASE_PATH . '/library' . PATH_SEPARATOR
> . get_include_path()
> );
Assuming BASE_PATH is the directory above public/, that's the basics.
> 3. How is gonna be used zend_app to give same effect as resource autoloader and
> autoloader code from below:
>
> require 'Zend/Loader/Autoloader.php';
> require 'Zend/Loader/Autoloader/Resource.php';
>
> Zend_Loader_Autoloader::getInstance()->registerNamespace('X');
>
> $loader = new Zend_Loader_Autoloader_Resource(array(
> 'namespace' => 'Default_',
> 'basePath' => MODULE_PATH . '/default'
> ));
>
> $loader->addResourceType('Model', 'models', 'Model');
There are two things going on here, and they are separate. By default,
Zend_Loader_Autoloader will be registered when Zend_Application is
instantiated. You can specify namespaces with the 'autoloaderNamespaces'
configuration key (again, case insensitive); this should be an array of
namespaces. As an example:
$app = new Zend_Application(APPLICATION_ENV, array(
'autoloaderNamespaces' => array(
'Imagis_',
'Phly_',
),
));
Resource autoloading is different. It would be handled in one of two
places: an initializer in your bootstrap, or via the "modules" bootstrap
resource. This latter will (eventually) initialize a
Zend_Application_Module_Autoloader instance (this is a concrete instance
of Zend_Loader_Autoloader_Resource that has resources defined per the
recommended directory structure) per module in your application, and, if
a bootstrap class is available for that module, register it with that
bootstrap.
I say eventually, as neither Ben nor I have put together this last bit
of functionality in the Modules resource yet.
> 4. How could be set the "php.ini settings to initialize" ?
By passing a set of key/value pairs to the "phpSettings" key when
instantiating Zend_Application:
$app = new Zend_Application(APPLICATION_ENV, array(
'phpSettings' => array(
'display_errors' => true,
'error_reporting' => E_ALL | E_STRICT,
),
));
Regarding the settings in questions 1, 3, and 4, these could be in a
config file as well, and you could simply pass the path to a config file
when instantiating Zend_Application. As an example, consider this:
$app = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/site.ini'
);
where APPLICATION_PATH . '/configs/site.ini' reads as follows:
[production]
phpSettings.display_errors = false
phpSettings.error_reporting = 771
autoloaderNamespaces.imagis = "Imagis_"
autoloaderNamespaces.phly = "Phly_"
includePaths.cwd = "."
includePaths.lib = APPLICATION_PATH "/../library"
[development : production]
phpSettings.display_errors = true
phpSettings.error_reporting = 8191
As you can see, this makes the application code simpler, and makes it
easier to switch settings per environment (which is also one of the
goals of Zend_Application).
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论