News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso:
How to use environ variables to create different environments with PHP
August 27, 2012 @ 07:49:29

Gonzalo Ayuso has a new post to his site showing how you can set up and use environment variables to make different environments for your applications.

If you use a framework such as Symfony2 this problem is solved for you, but if you aren't using any framework you probably need to solve it in one way or another. [...] The solution that I like for this kind of problem [with having different environments] is to use apache's environ variables. We inject the environ variables in the virtual host configuration.

He shows how to add a variable to the VirtualHost section of your Apache config, how to use the getenv function to retrieve its value and how to use it to select a configuration set. This method can also be applied to other kinds of information including settings you may not want to hard-code directly in you app (like possible database credentials).

0 comments voice your opinion now!
environment variable apache configuration tutorial


blog comments powered by Disqus

Similar Posts

SitePoint PHP Blog: Handle Incoming Email with SendGrid

WorkingSoftware.com.au: Configuring PHP4 and PHP5 to run concurrently on FreeBSD

SitePoint PHP Blog: Asset Access Restriction Methods Block Unwanted Visitors

Felix Geisendörfer's Blog: How to Plugin'ize Your App

DashExamples.com: Capture Content Security Policy (CSP) Violations in PHP


Community Events





Don't see your event here?
Let us know!


release series list api community code threedevsandamaybe framework deployment tips conference symfony bugfix voicesoftheelephpant zendserver podcast language interview laravel introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework