Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/07/2009, 15:46
maue75
 
Fecha de Ingreso: noviembre-2008
Mensajes: 288
Antigüedad: 15 años, 6 meses
Puntos: 2
Zend Framework 1.8 - ¿cómo capturar valores del ini file?

Hola.
No puedo capturar los valores de un ini file, con el objeto de poder levantar desde ahí los datos para poder conectar a una base de datos.
Al intentar mostrar los valores del ini file, estos me aparecen vacíos.


Este es el public/index.php :

<?php

define('BASE_PATH', realpath(dirname(__FILE__) . '/../'));
define('APPLICATION_PATH', BASE_PATH . '/application');

// Include path
set_include_path(
BASE_PATH . '/library'
. PATH_SEPARATOR . get_include_path()
);

// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')
: 'production'));

// Zend_Application
require_once 'Zend/Application.php';

$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);

echo "<br> ESTE VALOR APARECE VACIO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!: ".
$application->resources->db->params->host;

/** Base de Datos */
/* no se si debo colocar algo aqui para asociar el INI con la BD */


$application->bootstrap();
$application->run();



Este es mi bootstrap:

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
// Initialize view
$view = new Zend_View();
$view->doctype('XHTML1_TRANSITIONAL');
$view->headTitle('Mi Proyecto ZEND');
$view->env = APPLICATION_ENV;

// Add it to the ViewRenderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelp er(
'ViewRenderer'
);
$viewRenderer->setView($view);

// Return it, so that it can be stored by the bootstrap
return $view;
}

}


Y este es el ini que lo ví en varios sitios que hablan sobre el zend:

[production]

# Debug output
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0

# Include path
includePaths.library = APPLICATION_PATH "/../library"

# Bootstrap
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

# Front Controller
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.env = APPLICATION_ENV

# Layout
resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

# Views
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views/"

# Database
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "mi_db"
resources.db.isDefaultTableAdapter = true

# Session
resources.session.save_path = APPLICATION_PATH "/../data/session"
resources.session.remember_me_seconds = 864000

[testing : production]

# Debug output
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

# Database
resources.db.params.dbname = "myproject_testing"

[development : production]

# Debug output
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

# Database
resources.db.params.dbname = "mi_db"


¿Alguien puede ayudarme con el código que me falta para poder trabajar, tomar los valores del ini, y poder trabajar con una base de datos ?
Thanks!
Mauricio.