how to use APPLICATION_ENV

13 messages Options
Embed this post
Permalink
huajun qi

how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
I  know zend defines a APPLICATION_ENV variable in the index.php file, but we don't see it is used explicitly. Is it used in zend source code?

Does it have some usage to help develop?

--
Location:
Abraham Block

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
It could be set in your .htaccess file, i believe.

On Wed, Oct 28, 2009 at 9:49 AM, huajun qi <[hidden email]> wrote:
I  know zend defines a APPLICATION_ENV variable in the index.php file, but we don't see it is used explicitly. Is it used in zend source code?

Does it have some usage to help develop?

--
Location:

Eugene Morgan

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
APPLICATION_ENV is used to specify what environment your application
is running in -- for example, development, production, staging,
testing.

It can be set in your virtual host configuration file or your .htaccess file.

On Wed, Oct 28, 2009 at 8:50 AM, Abraham Block <[hidden email]> wrote:

> It could be set in your .htaccess file, i believe.
>
> On Wed, Oct 28, 2009 at 9:49 AM, huajun qi <[hidden email]> wrote:
>>
>> I  know zend defines a APPLICATION_ENV variable in the index.php file, but
>> we don't see it is used explicitly. Is it used in zend source code?
>> Does it have some usage to help develop?
>>
>> --
>> Location:
>
>
Ralph Schindler-2

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
In reply to this post by huajun qi
On of the main reasons that this constant is used is b/c it map nicely
to an actual environment variable.

In my projects, I typically SetEnv this variable inside the vhost.  The
constant will have different values on different systems, but from that
point, the index.php will either use what its seen, or assume production
mode.

By setting this value in the actual environment itself (like a vhost
that is generally not transfered with the project), the project itself
can be as portable between dev, testing, qa, prod. as possible).

Hope that sheds some light on its usage.

-ralph


huajun qi wrote:
> I  know zend defines a APPLICATION_ENV variable in the index.php file,
> but we don't see it is used explicitly. Is it used in zend source code?
>
> Does it have some usage to help develop?
>
> --
> Location:
Brenton Alker-3

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
In reply to this post by huajun qi
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

huajun qi wrote:
> I  know zend defines a APPLICATION_ENV variable in the index.php file,
> but we don't see it is used explicitly. Is it used in zend source code?

It's not used internally, no. So, you could rename it (or not set it)
without problem. The only way it is used is when you instantiate
Zend_Application you tell it which section of the config
(application.ini by default) you want to load.

> Does it have some usage to help develop?

You often have different sections of the config file (application.ini)
for each environment. By default, one for testing/staging/production.
Usually, the majority of the configuration is in production and the
others inherit from that.

You can then override values in the other sections. This can be used to
do things like override the database configuration, to use SQLite for
testing, or a separate MySQL instance for staging.

Hope that helps.

- --

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/
http://twitter.com/tekerson

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrotwAACgkQ7bkAtAithuv4UwCfYTPeVj+McP94lz4OEm0NN48x
ojcAn3IE3ofwyL2s8Q4quvR+3XBe+UEC
=AGUq
-----END PGP SIGNATURE-----
Hector Virgen

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
The default error.phtml created by zf.sh tests the APPLICATION_ENV constant to determine if exception information should be displayed. If it's set to "development", then exception information is displayed. Is there a better way for it to determine this without using the constant?

--
Hector


On Wed, Oct 28, 2009 at 2:26 PM, Brenton Alker <[hidden email]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

huajun qi wrote:
> I  know zend defines a APPLICATION_ENV variable in the index.php file,
> but we don't see it is used explicitly. Is it used in zend source code?

It's not used internally, no. So, you could rename it (or not set it)
without problem. The only way it is used is when you instantiate
Zend_Application you tell it which section of the config
(application.ini by default) you want to load.

> Does it have some usage to help develop?

You often have different sections of the config file (application.ini)
for each environment. By default, one for testing/staging/production.
Usually, the majority of the configuration is in production and the
others inherit from that.

You can then override values in the other sections. This can be used to
do things like override the database configuration, to use SQLite for
testing, or a separate MySQL instance for staging.

Hope that helps.

- --

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/
http://twitter.com/tekerson

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrotwAACgkQ7bkAtAithuv4UwCfYTPeVj+McP94lz4OEm0NN48x
ojcAn3IE3ofwyL2s8Q4quvR+3XBe+UEC
=AGUq
-----END PGP SIGNATURE-----


Brenton Alker-3

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hector Virgen wrote:
> The default error.phtml created by zf.sh tests the APPLICATION_ENV
> constant to determine if exception information should be displayed. If
> it's set to "development", then exception information is displayed. Is
> there a better way for it to determine this without using the constant?

Ah, true.
Personally, I don't like checking for a specific environment, but would
rather check for a configuration directive.

eg. I would add a "debug" configuration option to the development
environment config and check for that.

That way, you could add it to other environments, or remove it from that
environment without editing the code. Basically, I try not to depend on
the constant for anything.

Having said that, this is just my opinion, and since it's used in the
error page, somebody apparently disagrees :)


- --

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/
http://twitter.com/tekerson

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkro33EACgkQ7bkAtAithuvPrwCgzk2F+EDSyZho0zlvriIh968f
hLQAn0LDjzbFBW0dS/Hwf20SrdZtDZlq
=ZY8h
-----END PGP SIGNATURE-----
kwylez

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
I, like Brenton, don't prefer to have to deal with the APPLICATION_ENV.

I usually have three different environments (dev/staging/production) where I will create a server.xml and place it in my global include_path.

In the bootstrap I grab the value for the environment and pass it to the frontcontroller:

$server       = new Zend_Config_Xml(SERVER_PROPERTIES, 'properties');

Just pass: $server->environment to boostrap

On Wed, Oct 28, 2009 at 7:19 PM, Brenton Alker <[hidden email]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hector Virgen wrote:
> The default error.phtml created by zf.sh tests the APPLICATION_ENV
> constant to determine if exception information should be displayed. If
> it's set to "development", then exception information is displayed. Is
> there a better way for it to determine this without using the constant?

Ah, true.
Personally, I don't like checking for a specific environment, but would
rather check for a configuration directive.

eg. I would add a "debug" configuration option to the development
environment config and check for that.

That way, you could add it to other environments, or remove it from that
environment without editing the code. Basically, I try not to depend on
the constant for anything.

Having said that, this is just my opinion, and since it's used in the
error page, somebody apparently disagrees :)


- --

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/
http://twitter.com/tekerson

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkro33EACgkQ7bkAtAithuvPrwCgzk2F+EDSyZho0zlvriIh968f
hLQAn0LDjzbFBW0dS/Hwf20SrdZtDZlq
=ZY8h
-----END PGP SIGNATURE-----




--
Cory Wiles
[hidden email]
www.corywiles.com | www.feedfootball.com

Pádraic Brady

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
In reply to this post by Hector Virgen
Some javascript/style in this post has been disabled (why?)
Someone could throw an issue at JIRA about it. It really shouldn't be tied to a specific constant name. That said, the whole point of the Zend tool component is to work with a predictable generated project so it could be a deliberate simplication by design.

Paddy
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative



From: Hector Virgen <[hidden email]>
To: Brenton Alker <[hidden email]>
Cc: huajun qi <[hidden email]>; [hidden email]
Sent: Wed, October 28, 2009 10:49:11 PM
Subject: Re: [fw-mvc] how to use APPLICATION_ENV

The default error.phtml created by zf.sh tests the APPLICATION_ENV constant to determine if exception information should be displayed. If it's set to "development", then exception information is displayed. Is there a better way for it to determine this without using the constant?

--
Hector


On Wed, Oct 28, 2009 at 2:26 PM, Brenton Alker <[hidden email]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

huajun qi wrote:
> I  know zend defines a APPLICATION_ENV variable in the index.php file,
> but we don't see it is used explicitly. Is it used in zend source code?

It's not used internally, no. So, you could rename it (or not set it)
without problem. The only way it is used is when you instantiate
Zend_Application you tell it which section of the config
(application.ini by default) you want to load.

> Does it have some usage to help develop?

You often have different sections of the config file (application.ini)
for each environment. By default, one for testing/staging/production.
Usually, the majority of the configuration is in production and the
others inherit from that.

You can then override values in the other sections. This can be used to
do things like override the database configuration, to use SQLite for
testing, or a separate MySQL instance for staging.

Hope that helps.

- --

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/
http://twitter.com/tekerson

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrotwAACgkQ7bkAtAithuv4UwCfYTPeVj+McP94lz4OEm0NN48x
ojcAn3IE3ofwyL2s8Q4quvR+3XBe+UEC
=AGUq
-----END PGP SIGNATURE-----


sina miandashti

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
thanks brenton alker ....

nice reply

--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin
Rob Allen-3

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
In reply to this post by Pádraic Brady

On 29 Oct 2009, at 01:41, Pádraic Brady wrote:

> Someone could throw an issue at JIRA about it. It really shouldn't  
> be tied to a specific constant name. That said, the whole point of  
> the Zend tool component is to work with a predictable generated  
> project so it could be a deliberate simplication by design.
>

I noticed in April :) It's been fixed for 1.10.

http://framework.zend.com/issues/browse/ZF-6344

Regards,

Rob...

Ralph Schindler-2

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
In reply to this post by Hector Virgen
This is being changed in 1.10.

See:

http://framework.zend.com/svn/framework/standard/incubator/library/Zend/Tool/Project/Context/Zf/ControllerFile.php

Currently this work is in the incubator, although I am rolling out alpha
packages at major milestones in the pear package format.

Hector Virgen wrote:

> The default error.phtml created by zf.sh tests the APPLICATION_ENV
> constant to determine if exception information should be displayed. If
> it's set to "development", then exception information is displayed. Is
> there a better way for it to determine this without using the constant?
>
> --
> Hector
>
>
> On Wed, Oct 28, 2009 at 2:26 PM, Brenton Alker <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     -----BEGIN PGP SIGNED MESSAGE-----
>     Hash: SHA1
>
>     huajun qi wrote:
>      > I  know zend defines a APPLICATION_ENV variable in the index.php
>     file,
>      > but we don't see it is used explicitly. Is it used in zend source
>     code?
>
>     It's not used internally, no. So, you could rename it (or not set it)
>     without problem. The only way it is used is when you instantiate
>     Zend_Application you tell it which section of the config
>     (application.ini by default) you want to load.
>
>      > Does it have some usage to help develop?
>
>     You often have different sections of the config file (application.ini)
>     for each environment. By default, one for testing/staging/production.
>     Usually, the majority of the configuration is in production and the
>     others inherit from that.
>
>     You can then override values in the other sections. This can be used to
>     do things like override the database configuration, to use SQLite for
>     testing, or a separate MySQL instance for staging.
>
>     Hope that helps.
>
>     - --
>
>     Brenton Alker
>     PHP Developer - Brisbane, Australia
>
>     http://blog.tekerson.com/
>     http://twitter.com/tekerson
>
>     -----BEGIN PGP SIGNATURE-----
>     Version: GnuPG v1.4.9 (GNU/Linux)
>     Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
>     iEYEARECAAYFAkrotwAACgkQ7bkAtAithuv4UwCfYTPeVj+McP94lz4OEm0NN48x
>     ojcAn3IE3ofwyL2s8Q4quvR+3XBe+UEC
>     =AGUq
>     -----END PGP SIGNATURE-----
>
>
Ithier

Re: how to use APPLICATION_ENV

Reply Threaded More More options
Print post
Permalink
Hi,

Unfortunately, in IIS I never find how to define an environment variable
as in apache (if someone know how to do that, I am very interested). So,
for the moment I instead use the name of the computer (variable
COMPUTERNAME), so the modification to rely on a ini variable in the
default error.phtml instead of an environment variable is great.
Thanks.

Ithier


Ralph Schindler a écrit :

> This is being changed in 1.10.
>
> See:
>
> http://framework.zend.com/svn/framework/standard/incubator/library/Zend/Tool/Project/Context/Zf/ControllerFile.php 
>
>
> Currently this work is in the incubator, although I am rolling out
> alpha packages at major milestones in the pear package format.
>
> Hector Virgen wrote:
>> The default error.phtml created by zf.sh tests the APPLICATION_ENV
>> constant to determine if exception information should be displayed.
>> If it's set to "development", then exception information is
>> displayed. Is there a better way for it to determine this without
>> using the constant?
>>
>> --
>> Hector
>>
>>
>> On Wed, Oct 28, 2009 at 2:26 PM, Brenton Alker <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     -----BEGIN PGP SIGNED MESSAGE-----
>>     Hash: SHA1
>>
>>     huajun qi wrote:
>>      > I  know zend defines a APPLICATION_ENV variable in the index.php
>>     file,
>>      > but we don't see it is used explicitly. Is it used in zend source
>>     code?
>>
>>     It's not used internally, no. So, you could rename it (or not set
>> it)
>>     without problem. The only way it is used is when you instantiate
>>     Zend_Application you tell it which section of the config
>>     (application.ini by default) you want to load.
>>
>>      > Does it have some usage to help develop?
>>
>>     You often have different sections of the config file
>> (application.ini)
>>     for each environment. By default, one for
>> testing/staging/production.
>>     Usually, the majority of the configuration is in production and the
>>     others inherit from that.
>>
>>     You can then override values in the other sections. This can be
>> used to
>>     do things like override the database configuration, to use SQLite
>> for
>>     testing, or a separate MySQL instance for staging.
>>
>>     Hope that helps.
>>
>>     - --
>>
>>     Brenton Alker
>>     PHP Developer - Brisbane, Australia
>>
>>     http://blog.tekerson.com/
>>     http://twitter.com/tekerson
>>
>>     -----BEGIN PGP SIGNATURE-----
>>     Version: GnuPG v1.4.9 (GNU/Linux)
>>     Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>>     iEYEARECAAYFAkrotwAACgkQ7bkAtAithuv4UwCfYTPeVj+McP94lz4OEm0NN48x
>>     ojcAn3IE3ofwyL2s8Q4quvR+3XBe+UEC
>>     =AGUq
>>     -----END PGP SIGNATURE-----
>>
>>
>