What are the best ways to make Zend-Framwork run faster besides Zend Optimizer?
If I remember correctly, parsing .ini files in PHP takes a long time. Therefor I cache it (the file won't change during a request)
Are there any other ways to improve ZF's performance?
I cache my application.ini Like this:
Make sure you have the following directory (your cache dir): /application/data/cache
I extend Zend_Application with My_Application, see code:
<?php
require_once 'Zend/Application.php';
class My_Application extends Zend_Application
{
/**
* Flag used when determining if we should cache our configuration.
*/
protected $_cacheConfig = false;
/**
* Our default options which will use File caching
*/
protected $_cacheOptions = array(
'frontendType' => 'File',
'backendType' => 'File',
'frontendOptions' => array(),
'backendOptions' => array()
);
/**
* Constructor
*
* Initialize application. Potentially initializes include_paths, PHP
* settings, and bootstrap class.
*
* When $options is an array with a key of configFile, this will tell the
* class to cache the configuration using the default options or cacheOptions
* passed in.
*
* #param string $environment
* #param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config of configuration options
* #throws Zend_Application_Exception When invalid options are provided
* #return void
*/
public function __construct($environment, $options = null)
{
if (is_array($options) && isset($options['configFile'])) {
$this->_cacheConfig = true;
// First, let's check to see if there are any cache options
if (isset($options['cacheOptions']))
$this->_cacheOptions =
array_merge($this->_cacheOptions, $options['cacheOptions']);
$options = $options['configFile'];
}
parent::__construct($environment, $options);
}
/**
* Load configuration file of options.
*
* Optionally will cache the configuration.
*
* #param string $file
* #throws Zend_Application_Exception When invalid configuration file is provided
* #return array
*/
protected function _loadConfig($file)
{
if (!$this->_cacheConfig)
return parent::_loadConfig($file);
require_once 'Zend/Cache.php';
$cache = Zend_Cache::factory(
$this->_cacheOptions['frontendType'],
$this->_cacheOptions['backendType'],
array_merge(array( // Frontend Default Options
'master_file' => $file,
'automatic_serialization' => true
), $this->_cacheOptions['frontendOptions']),
array_merge(array( // Backend Default Options
'cache_dir' => APPLICATION_PATH . '/data/cache'
), $this->_cacheOptions['backendOptions'])
);
$config = $cache->load('Zend_Application_Config');
if (!$config) {
$config = parent::_loadConfig($file);
$cache->save($config, 'Zend_Application_Config');
}
return $config;
}
}
And I change my index.php (in the public root) to:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** My_Application */
require_once 'My/Application.php';
// Create application, bootstrap, and run
$application = new My_Application(
APPLICATION_ENV,
array(
'configFile' => APPLICATION_PATH . '/configs/application.ini'
)
);
$application->bootstrap()
->run();
Reload the page and you see the ini file cached. Good luck.
Parsing .ini files may be a little slow, but I wouldn't expect that to be anywhere near the slowest part of a typical ZF application. Without seeing any results, it seems like including a bunch of files (Zend_Cache_*) may in some cases be even slower than parsing a simple .ini file. Anyway, that's just one area...
ZF has published a good guide on optimization:
http://framework.zend.com/manual/en/performance.classloading.html
In short,
Utilize caching where it matters: database queries / complex operations, full page cache, etc.
Strip require_once calls in favor of auto-loading as per the documentation.
Cache PluginLoader file/class map
If you want to get a bit more into it,
Skip using Zend_Application component
Enable some sort of op-code cache
Do other typical PHP optimization methods (profiling, memory caching, etc.)
see also http://www.kimbs.cn/2009/06/caching-application-ini-for-zend-framework-apps/
Why did you deleted your last question?
I had a good link for you:
I heard things like this before, but
the combination is often related to
migration from one platform to other.
Check at this link:
http://devblog.policystat.com/php-to-django-changing-the-engine-while-the-c
Related
I'm trying to find out how to change the default storage location (including it's subfolders) on a Lumen project. For several reasons, given the current configuration of the production web server, Lumen throws a permission denied exception when trying to write logs or compile Blade views.
The only alternative, without involving the sysadmin, is to move the storage folder to a tmp folder on the webserver.
On laravel there seems to be a method called "useStoragePath", but it doesn't seem to be available on Lumen (5.2.x).
The default paths seem to be "hardcoded", I found this:
Project\vendor\laravel\lumen-framework\src\Application.php
/**
* Get the storage path for the application.
*
* #param string|null $path
* #return string
*/
public function storagePath($path = null)
{
return $this->basePath().'/storage'.($path ? '/'.$path : $path);
}
And for the logs (same file):
/**
* Get the Monolog handler for the application.
*
* #return \Monolog\Handler\AbstractHandler
*/
protected function getMonologHandler()
{
return (new StreamHandler(storage_path('logs/lumen.log'), Logger::DEBUG))
->setFormatter(new LineFormatter(null, null, true, true));
}
Bottom line: Is there any clean way of overriding the default storage path keeping in mind this restrictions?:
It should not involve the sysadmin (sym links, changing permissions, etc.)
Not tampering with the vendor folder.
On Line 286 of vendor/laravel/lumen-framework/src/helpers.php:
if (! function_exists('storage_path')) {
/**
* Get the path to the storage folder.
*
* #param string $path
* #return string
*/
function storage_path($path = '')
{
return app()->storagePath($path);
}
}
The key here is this line:
if (! function_exists('storage_path'))
That means if a function named storage_path hasn't already been defined, then Lumen will use its own implementation.
All you have to do is simply write your own function that returns your own custom path.
Because Lumen has far fewer rules than Laravel, how you do this is entirely up to you. That said, I would suggest doing it the following way:
Place a file called helpers.php under your app directory
Add any and all custom helper functions into this file including your own storage_path implementation
Make sure this file is loaded before Lumen itself. In order to do that, you need to place your require statement before composer's autoloader. This can be done at the very first line under bootstrap/app.php:
require_once __DIR__ . '/../app/helpers.php';
require_once __DIR__ . '/../vendor/autoload.php';
try {
(new Dotenv\Dotenv(__DIR__ . '/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}
....
I would like to know why when I clone my ZF2 project to a local machine to do some testing it completly stops working.
In my local machine I have two subfolders, one with a cakePHP project and the other with the ZF2 I've cloned.
The cakePHP project is working fine since it was there first, but the ZF2, when I try to access to the public folder it prints me:
{"error":"Something went wrong"}
A really generic error... I have no clue about what is going on.
I've tried some general debug attemps like
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
with no success at all, I've also checked the .htaccess RewriteBase directive to match my subfolder and the DB configuration is done too.
I have researched a bit in the project and the file which displays the error is module/RestfulV2_2/Module.php (Reading the README.md I've discovered is part of ZF2 Restful Module Skeleton):
/**
* #param MvcEvent $e
* #return null|\Zend\Http\PhpEnvironment\Response
*/
public function errorProcess(MvcEvent $e)
{
/** #var \Zend\Di\Di $di */
$di = $e->getApplication()->getServiceManager()->get('di');
$eventParams = $e->getParams();
/** #var array $configuration */
$configuration = $e->getApplication()->getConfig();
$vars = array();
if (isset($eventParams['exception'])) {
/** #var \Exception $exception */
$exception = $eventParams['exception'];
if ($configuration['errors']['show_exceptions']['message']) {
$vars['error-message'] = $exception->getMessage();
}
if ($configuration['errors']['show_exceptions']['trace']) {
$vars['error-trace'] = $exception->getTrace();
}
}
if (empty($vars)) {
$vars['error'] = 'Something went wrong';
}
/** #var PostProcessor\AbstractPostProcessor $postProcessor */
$postProcessor = $di->get(
$configuration['errors']['post_processor'],
array('vars' => $vars, 'response' => $e->getResponse())
);
$postProcessor->process();
if (
$eventParams['error'] === \Zend\Mvc\Application::ERROR_CONTROLLER_NOT_FOUND ||
$eventParams['error'] === \Zend\Mvc\Application::ERROR_ROUTER_NO_MATCH
) {
$e->getResponse()->setStatusCode(\Zend\Http\PhpEnvironment\Response::STATUS_CODE_501);
} else {
$e->getResponse()->setStatusCode(\Zend\Http\PhpEnvironment\Response::STATUS_CODE_500);
}
$e->stopPropagation();
return $postProcessor->getResponse();
}
The line which is calling the error in my index.php is:
Zend\Mvc\Application::init(require 'config/application.config.php')- run();
And the only line I found where the error function is called some way is this one in my modele.php :
$sharedEvents->attach('Zend\Mvc\Application', MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'errorProcess'), 999);
Can you help me to solve this? I'm inexperienced with ZF2 but I know that with cakePHP to make it work you need to clear the cache folder. Is there any similar process in ZF2? Should I virtualize two servers to avoid conflics?
Thank you in advance.
EDIT : I've already made virtual hosts to avoid any possible conflict between my two frameworks but the error output is still the same.
EDIT2 : Here is my application.config.php file:
return array(
// This should be an array of module namespaces used in the application.
'modules' => array(
'Restful',
'MvlabsSnappy',
'Qrcode',
'Application',
'RestfulV2',
'RestfulV2_2'
),
// These are various options for the listeners attached to the ModuleManager
'module_listener_options' => array(
// This should be an array of paths in which modules reside.
// If a string key is provided, the listener will consider that a module
// namespace, the value of that key the specific path to that module's
// Module class.
'module_paths' => array(
'./module',
'./vendor',
),
// An array of paths from which to glob configuration files after
// modules are loaded. These effectively override configuration
// provided by modules themselves. Paths may use GLOB_BRACE notation.
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
// Whether or not to enable a configuration cache.
// If enabled, the merged configuration will be cached and used in
// subsequent requests.
//'config_cache_enabled' => $booleanValue,
// The key used to create the configuration cache file name.
//'config_cache_key' => $stringKey,
// Whether or not to enable a module class map cache.
// If enabled, creates a module class map cache which will be used
// by in future requests, to reduce the autoloading process.
//'module_map_cache_enabled' => $booleanValue,
// The key used to create the class map cache file name.
//'module_map_cache_key' => $stringKey,
// The path in which to cache merged configuration.
//'cache_dir' => $stringPath,
// Whether or not to enable modules dependency checking.
// Enabled by default, prevents usage of modules that depend on other modules
// that weren't loaded.
// 'check_dependencies' => true,
),
// Used to create an own service manager. May contain one or more child arrays.
//'service_listener_options' => array(
// array(
// 'service_manager' => $stringServiceManagerName,
// 'config_key' => $stringConfigKey,
// 'interface' => $stringOptionalInterface,
// 'method' => $stringRequiredMethodName,
// ),
// )
// Initial configuration with which to seed the ServiceManager.
// Should be compatible with Zend\ServiceManager\Config.
// 'service_manager' => array(),
);
First I would open index.php or whatever used as initial file (DirectoryIndex) and temporarily completely replace whole its content with something very base and simple, for example just these two lines:
<?php
phpinfo();
And then make sure that it started to work after that - with that simple code which just displays your php configuration. So we'll find out that there is no error in server configurations, permissions and etc. and nothing prevents your script from run.
Then I would do the same at your old project location just to get phpinfo() from that place too and waste some time trying to compare them. Maybe you missed something important and you'll now see it.
If no - next step I would check your DB connectivity if your project uses any DB... also with some very simple commands like connect, bind, ....
And finally I'd try to restore original project content step by step from its begin, and look at which step it will fail. It doesn't matter that there maybe no any output - you may put echo __LINE__ . ' works!<br/>'; between blocks, so your index.php will look like:
<?php
// original code block 1
echo __LINE__ . ' works!<br/>';
// original code block 2
echo __LINE__ . ' works!<br/>';
And you'll see in browser where it fails.
This is a very base description of my debug principals, but hope it will help.
The error could be anything. However, assuming the posted code is executed, it will suppress an error message without the correct configuration.
Try adding the following config to local.config.php.
return [
'errors'=> [
'show_exceptions' => [
'message' => true,
'trace' => true
],
],
];
If an exception is being thrown and that listener is catching it, then the $eventParams is something you should debug.
I was not able to find a good resource which is describing the following Zend_Tool command:
zf create project path name-of-profile file-of-profile
Not even here:
http://framework.zend.com/manual/en/zend.tool.usage.cli.html
Does somebody know a good resource regarding this command?
Note: I'm interested in the name-of-profile and file-of-profile part. Usage, examples, etc.
Maybe even a visual approach like in this references:
http://marklodato.github.com/visual-git-guide/index-en.html
http://osteele.com/archives/2008/05/commit-policies
I am not familiar enough with the internals of ZF Tool Project, but have a look at
http://framework.zend.com/manual/en/zend.tool.project.create-a-project.html
http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Tool/Project/Provider/Project.php
Afaik (which is not much) Zend Tool maintains an XML file to keep track of your project. This is required for any subsequent actions to be applied correctly to your project through Zend Tool.
The DocBlock for the create action in the Project Provider says:
/**
* create()
*
* #param string $path
* #param string $nameOfProfile shortName=n
* #param string $fileOfProfile shortName=f
*/
When run without the two optional arguments, the method will eventually create a new project file with
$newProfile = new Zend_Tool_Project_Profile(array(
'projectDirectory' => $path,
'profileData' => $profileData
));
with $profileDate being the content of the default configuration file. If you specify $fileOfProfile, you can override the configuration file and supply your own file, e.g.
if ($fileOfProfile != null && file_exists($fileOfProfile)) {
$profileData = file_get_contents($fileOfProfile);
}
Obviously, you have to supply a full path to the file for this to work. The alternative is to supply a file identifier, which Zend Tool will then try to find in a predefined location, e.g.
$storage = $this->_registry->getStorage();
if ($profileData == '' && $nameOfProfile != null && $storage->isEnabled()) {
$profileData = $storage->get('project/profiles/' . $nameOfProfile . '.xml');
}
I have no clue what the storage part is about. Like I said, I am not familiar with Zend Tool's inner workings. If I understand correctly, you can use the additional two arguments to load an existing project in a new location or customize the default one.
You might want to browse the ChangeLog to find out more about it.
A few questions regarding the basics of Zend Framework 1.9.
i followed the quickstart guide, and basically, bootstrapping involves,
a. from index.php:
$ZEND_FRAMEWORK_LIB_PATH = '/appl/ZendFramework-1.9.7/library';
defined('APPLICATION_PATH') || define('APPLICATION_PATH', (realpath(dirname(__FILE__) . '/../application')));
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
set_include_path(implode(PATH_SEPARATOR, array((dirname(dirname(__FILE__)) . '/library'), $ZEND_FRAMEWORK_LIB_PATH, get_include_path(),)));
require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV, (APPLICATION_PATH . '/configs/application.ini'));
$application->bootstrap()->run();
b. Then in the Bootstrap.php, i have
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array("namespace" => "Default_", "basePath" => dirname(__FILE__),));
return $autoloader;
}
protected function _initDoctype()
{
$this->bootstrap("view");
$view = $this->getResource("view");
$view->doctype("XHTML1_STRICT");
}
For a start, a few things i don't understand:
a. If a user access the site not via the default index.php, does that mean that bootstrapping (and indeed, all the code in the index.php including setting of environment etc, will be bypassed?)
b. There is no place that explicitly calls the Bootstrap's _initAutoload() or _initDoctype() methods. So when are these methods implicitly invoked?
c. Since in the index.php, i have already "passed in" the config file '/configs/application.ini' to the Zend_Application constructor, is there any way to retrieve the config entries elsewhere?
In my application, i have to work with different databases (so i can't just use resources.db.*). So in the same application.ini file, i have, e.g.
custdb.adapter = "PDO_MYSQL"
custdb.params.host = "localhost"
custdb.params.username = "username"
custdb.params.password = "password"
custdb.params.dbname = "custdb"
What's the best practice to manage the DB adapter?
a. Is it possible to (and should i) create the DB adapter in index.php OR Bootstrap.php and retrieve it elsewhere when needed (and how)?
b. Or is possible to (and should i) just retrieve the config entries elsewhere (how?) and instantiate the DB adapter as and when needed?
Thanks!
Here's a few answers.
2a. All request are redirected to index.php. This is done with mod_rewrite and specified in the .htaccess file.
2b. The bootstrap calls any method prefixed with _init. See Zend Framework - Theory of Operation
2c. Yes. Zend::Config. You could store an instance in Zend::Registry for easy access. Eg:
$config = new Zend_Config((APPLICATION_PATH . '/configs/application.ini'));
$application = new Zend_Application(APPLICATION_ENV, $config);
Zend_Registry::set('config', $config);
Check the API reference to see the constructors for these two classes.
I don't think the Quick start is that helpful. I'd recommend a getting a book. I enjoyed "Zend Framework 1.8 Web Application Development" by Keith Pope.
To answer question 3, ZF uses the Application Resource Plugin Zend_Application_Resource_Db to ingest the config and create a database adapter instance.
If your need for multiple databases is an environmental thing, you can easily namespace your DB params in your application.ini file.
[production]
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = user
resources.db.params.password = pass
resources.db.params.dbname = production_db
[staging : production]
resources.db.params.dbname = staging_db
[development : production]
resources.db.params.dbname = development_db
In this example, we're setting up common info in the [production] section and overriding it for our staging and development environments. Which config is applied is controlled by the environment variable in your app's .htaccess
If you need to access multiple databases in a single application, then I would recommend rolling your own Application Resource Plugin, and creating some kind of structure to hold multiple connections.
It's not as difficult as it might seem. Read up on it here and create a subclass of of Zend_Application_Resource_ResourceAbstract. Using this class, you can easily grab resources.* in your config file using:
$this->getBootstrap()-getResource('mydb')`
You would then have access to your plugin via the bootstrap object:
$bootstrap->getPluginResource('mydb')
Hope that helps.
EDIT: I forgot to mention, if you have a resource plugin as part of your application.ini, the Zend_Application bootstrapper will automatically know to include it as part of the bootstrap proccess, so you don't need to define any _init() method in your bootstrap file. It's kind of magic like that.
Also, as far as storing an adapter instance, I'd probably just user Zend_Registry.
thanks for all your replies! It really helped my understanding of the concept of ZF.
i've also gone through the references and source codes to get a deeper understanding, and this is what i adopted:
In my application.ini i have:
custom.db.customers.adapter = "PDO_MYSQL"
custom.db.customers.params.host = "localhost"
custom.db.customers.params.username = "username"
custom.db.customers.params.password = "password"
custom.db.customers.params.dbname = "custdb"
Then, in my Bootstrap.php i have:
protected function _initCustomDbCustomers()
{
$config = $this->getOptions();
$cfgCustom = $config['custom'];
if (null != $cfgCustom)
{
$cfgCustomDb = $cfgCustom['db'];
if (null != $cfgCustomDb)
{
$cfgCustomDbCustomers = $cfgCustom['customers'];
if (null != $cfgCustomDbCustomers)
{
$resrcCustomDbCustomers = new Zend_Application_Resource_Db($cfgCustomDbCustomers);
return $resrcCustomDbCustomers
}
}
}
}
Of course, in my index.php, i call:
$application->bootstrap();
$application->run();
Then, in the controller where i need to get the DB adapter, i do:
$bootstrap = $this->getInvokeArg('bootstrap');
$resrcCustomDbCustomers = $bootstrap->getResource('customDbCustomers');
$adpCustomDbCustomers = $resrcCustomDbCustomers->getDbAdapter();
// Do Stuffs With DB Adapter
Is this a Good/Bad way to do things? And is there any pitfall i should watch for?
Thanks!
I am using Zend_Application and it does not feel right that I am mixing in my application.ini both application and user configuration.
What I mean with this is the following. For example, my application needs some library classes in the namespace MyApp_ . So in application.ini I put autoloaderNamespaces[] = "MyApp_". This is pure application configuration, no-one except a programmer would change these. On the other hand I put there a database configuration, something that a SysAdmin would change.
My idea is that I would split options between an application.ini and an user.ini, where the options in user.ini take preference (so I can define standard values in application.ini).
Is this a good idea? How can I best implement this? The idea's I have are
Extending Zend_Application to take multiple config files
Making an init function in my Bootstrap loading the user.ini
Parsing the config files in my index.php and pass these to Zend_Application (sounds ugly)
What shall I do? I would like to have the 'cleanest' solution, which is prepared for the future (newer ZF versions, and other developers working on the same app)
I found a solution to this issue that may be new to framework version 1.10. When creating the Zend Application object, you can pass in 2 configuration file paths in the options array that get merged together:
$application = new Zend_Application(
APPLICATION_ENV,
array(
'config' => array(
APPLICATION_PATH . '/configs/application.ini',
APPLICATION_PATH . '/configs/user.ini'
),
)
);
you know this will merge as much inis as you want?
in application.ini
[production]
config[] = APPLICATION_PATH "/configs/dsn.ini"
config[] = APPLICATION_PATH "/configs/error.ini"
...
There is nothing wrong with that, I do something similar. I suggest using your second choice. I just have an _initConfig() method that takes care of loading the user config using Zend_Config_Ini. I wouldn't extend Zend_App, that seems a bit much.
Edit:
In response to your comment, you would simply do:
$this->bootstrap('config');
Thus, to ensure config is loaded before DB, you'd have something like:
protected function _initConfig()
{
$config = new Zend_Config_Ini('/path/to/user.ini');
return $config;
}
protected function _initDb()
{
$this->bootstrap('config');
$config = $this->getResource('Config');
/* ... */
}
There is no need to use Zend_Registry as anything returned by a Bootstrap _init method is accessible using getResource()
An configuration file can have the item 'config' which refers to another config file. Zend_Application will include this config file. The included config-file will have preference, and overwrite the keys already defined in the standard config-file.
Yesterday there was also started a thread on the Zend Framework mailing list
Examples
application.ini:
[production]
config = APPLICATION_PATH "/configs/config.ini"
resources.db.adapter = "Mysqli"
resources.db.host = "localhost"
config.ini:
[production]
resources.db.host = "mysql.server.com"
resources.db.username = "myuser"
public/index.php:
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
In a similar scenario, I saw that the application specific parameters can be provided programmatically when instantiating the application. This helped to place configuration related parameters within the config.ini
I did it actually this way:
inside the index.php to bootstap the application
$application = new Zend_Application(APPLICATION_ENV, array(
'resources' => array(
'FrontController' => array(
'controllerDirectory' => APPLICATION_PATH . '/main/controllers',
),
'layout' => array(
'layoutpath' => APPLICATION_PATH . "/layouts/scripts"
),
),
));
and then inside the bootstrap parse the config.ini inidependently
protected function _initConfigFile() {
try {
$configuration = new Zend_Config_Ini(
APPLICATION_PATH . '/config/app.ini',
APPLICATION_ENV );
$registry->configuration = $configuration;
} catch (Zend_Exception $zExp) {
echo "Could not read application ini file (app.ini). "
. " Please check that it exists and has the appropriate structure.\n";
echo("\n");
var_dump($zExp);
exit(1);
}
}
inside the bootstrap
You can ensure an _initConfig() bootstrap method is invoked before others by specifying in your other bootstrap methods (that require the config object) something like:
$this->bootstrap('config');
A more complete example (context of a Bootstrap class):
protected function _initConfig() {
$config = new Zend_Config_Ini('[filename]');
Zend_Registry::set('config',$config);
}
protected function _initSomething() {
$this->bootstrap('config');
$config = Zend_Registry::get('config');
// you can now do whatever you like with the $config object
}
Update:
As has now been mentioned in other answers, if the config is only required within the bootstrap, I would say to use the $this->getResource('Config') method. I use the registry so that config can be accessed easily in other parts of my application.