-- Cristian Bichis <[email protected]> wrote
(on Wednesday, 08 June 2011, 05:05 PM +0300):
> Thanks,
> 
> That was too easy :) Exactly what i missed and i needed...

Another easy way:

    prompt> APPLICATION_ENV=cli ; php cli-endpoint.php

In your script, grab from $_SERVER:

    defined('APPLICATION_ENV') || define('APPLICATION_ENV',
        (isset($_SERVER['APPLICATION_ENV']) 
            ? $_SERVER['APPLICATION_ENV']
            : 'production'));

Unlike running under apache or IIS, environment variables are passed to
$_SERVER under the CLI SAPI.


> >I usually wrap my cronjobs within bash scripts, which allows me to
> >set enviroment directly in the script...
> >That allows me to centralize and pipe the execution of multiple
> >CLI PHP commands :)
> >Marco Pivetta
> >http://twitter.com/Ocramius
> >http://marco-pivetta.com
> >
> >
> >
> >On 8 June 2011 15:27, Markizano Draconus <[email protected]
> ><mailto:[email protected]>> wrote:
> >
> >    Hi Christian,
> >
> >    https://github.com/markizano/markizano/blob/master/application/setup.php
> >    https://github.com/markizano/markizano/blob/master/htdocs/.htaccess
> >
> >    I use a combination of .htaccess and $_ENV for setting up the
> >    application
> >    environment.
> >    You can create a bash wrapper (ENVIRONMENT="staging"), or create
> >    something
> >    like cli.php in the webroot, (checking to make sure PHP_SAPI ==
> >    'cli' before
> >    doing anything). The wrapper could setup the application
> >    environment for CLI
> >    scripts and .htaccess would assign an environment variable that
> >    can be used
> >    for the web.
> >
> >    For a more centralized approach, you can set the $_ENV var in the
> >    apache
> >    config for that virtualhost (or any vhosts to which this may
> >    apply) and it
> >    will be effective on a server level instead of maintaining the
> >    environment
> >    in a .htaccess.
> >    The same can be done for /etc/environment (linux) or sysdm.cpl
> >    (windows).
> >
> >    Hope this helps,
> >    //-----
> >    Mark Harris
> >    Information Security
> >    [email protected] <mailto:[email protected]>
> >    http://markizano.net/
> >
> >    On Wed, Jun 8, 2011 at 9:12 AM, Cristian Bichis <[email protected]
> >    <mailto:[email protected]>> wrote:
> >
> >    > Hello,
> >    >
> >    > I am interested how you guys are setting the APPLICATION_ENV for
> >    staging.
> >    >
> >    > For httpd is easy to set APPLICATION_ENV in vhost. For CLI can
> >    be used OS
> >    > environment variable.
> >    >
> >    > But for cli scripts is much harder, especially if the same
> >    machine is going
> >    > to be used for multiple projects, some running production and
> >    running
> >    > staging at same time... How you guys are setting APPLICATION_ENV
> >    for this
> >    > cases ?
> >    >
> >    > Cristian
> >    >
> >    > --
> >    > List: [email protected] <mailto:[email protected]>
> >    > Info: http://framework.zend.com/archives
> >    > Unsubscribe: [email protected]
> >    <mailto:[email protected]>
> >    >
> >    >
> >    >
> >
> >
> 

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to