Zend_Application

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_Application

mirian
This post has NOT been accepted by the mailing list yet.
Hi everyone,

i want to use Zend_Application for encapsulate a project that can be delivered out,
BUT-
I don't want to implement the whole MVC method- just add the code for organize paths,libraries and .ini declarations.
the projcet makes use of Zend modules like DB and Validators but not the whole MVC method.


Many thanks!
Miriam.

Reply | Threaded
Open this post in threaded view
|

Re: Zend_Application

Wil Moore III
This post has NOT been accepted by the mailing list yet.
mirian wrote
i want to use Zend_Application...I don't want to implement the whole MVC...organize paths,libraries and .ini declarations.
the projcet makes use of Zend modules like DB and Validators but not the whole MVC method.
Miriam,

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

2) bootstrap only specific resources and grab the bootstrap for later use
$bootStrap   = $application->bootstrap(array('db'))->getBootstrap();

// rest of your application here...you can retrieve resources with "$bootstrap->getResource('name-of-resource')"
--
Wil Moore III

Best Practices for Working with Open-Source Developers
http://www.faqs.org/docs/artu/ch19s02.html

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost
Reply | Threaded
Open this post in threaded view
|

RE: Zend_Application

mirian
This post has NOT been accepted by the mailing list yet.

Thank you! It works.

 

BUT-

 

I didn't find the way to retrieve the values of "dbname" for example from the object I got from the "getResource" method (it is protected).

Then, I want to have an access to the ini declaration from each file of that project.

 

The index.php is attached here and I call there to "ItemInstances" object that is written in another file and I want to have an access from there to the .ini values.

Is it possible??

 

Thank you,

Miriam

 

 

<?php

require './modules/entities/ItemsInstances.module';

 

// 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(),

)));

 

 

 

/** Zend_Application */

require_once 'Zend/Application.php';

 

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

$bootStrap   = $application->bootstrap(array('db'))->getBootstrap();

//print_r($bootStrap->getResource('db'));

 

 

$db = new DB_Adapter(array('dbname'=>'my_dbname','profiler' => true ));

Zend_Db_Table_Abstract::setDefaultAdapter($db->getConn());

 

session_start();

 

$item_instance = new ItemsInstances();

$item_instance->go();

 

?>

 

From: Wil Moore III [via Zend Framework Community] [mailto:[hidden email]]
Sent: Sunday, February 27, 2011 12:08 PM
To: mirian
Subject: Re: Zend_Application

 

mirian wrote:

i want to use Zend_Application...I don't want to implement the whole MVC...organize paths,libraries and .ini declarations.
the projcet makes use of Zend modules like DB and Validators but not the whole MVC method.

Miriam,

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

2) bootstrap only specific resources and grab the bootstrap for later use
$bootStrap   = $application->bootstrap(array('db'))->getBootstrap();

// rest of your application here...you can retrieve resources with "$bootstrap->getResource('name-of-resource')"

--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost

 


If you reply to this email, your message will be added to the discussion below:

http://zend-framework-community.634137.n4.nabble.com/Zend-Application-tp3326210p3326681.html

To unsubscribe from Zend_Application, click here.

Reply | Threaded
Open this post in threaded view
|

RE: Zend_Application

Wil Moore III
This post has NOT been accepted by the mailing list yet.
mirian wrote
The index.php is attached here and I call there to "ItemInstances" object that is written in another file and I want to have an access from there to the .ini values.
$options = $bootStrap->getOptions();
var_dump($options[...]);
--
Wil Moore III

Best Practices for Working with Open-Source Developers
http://www.faqs.org/docs/artu/ch19s02.html

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost
Reply | Threaded
Open this post in threaded view
|

RE: Zend_Application

mirian
This post has NOT been accepted by the mailing list yet.

BUT-

 

When I try to access $bootStrap from "ItemInstances" object , I got an "Undefined variable: bootStrap" error…

My question is how I can access such parameters from any file??

 

From: Wil Moore III [via Zend Framework Community] [mailto:[hidden email]]
Sent: Monday, February 28, 2011 12:36 PM
To: mirian
Subject: RE: Zend_Application

 

mirian wrote:

The index.php is attached here and I call there to "ItemInstances" object that is written in another file and I want to have an access from there to the .ini values.

$bootStrap->getOption('db');

--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost

 


If you reply to this email, your message will be added to the discussion below:

http://zend-framework-community.634137.n4.nabble.com/Zend-Application-tp3326210p3327721.html

To unsubscribe from Zend_Application, click here.

Reply | Threaded
Open this post in threaded view
|

RE: Zend_Application

Wil Moore III
This post has NOT been accepted by the mailing list yet.
mirian wrote
My question is how I can access such parameters from any file??
Depends on how you are calling these other files and how/where Zend_Application is being instantiated. Obviously we don't want to start calling global variables all over the place, so if you give me some context around how the application is setup, I can potentially give you a hint as to how to make this work.

--
Wil Moore III

Best Practices for Working with Open-Source Developers
http://www.faqs.org/docs/artu/ch19s02.html

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost