-
Notifications
You must be signed in to change notification settings - Fork 363
Using .phpbrewrc files
During development of multiple projects which require different PHP versions and/or configurations, it's convenient to have the configuration automatically switched when current directory is changed. This may be achieved by means of using .phpbrewrc
files.
For instance, I have a project which only works with PHP 5.3, and I want PHP 5.3.29 to be automatically used for it. In order to make this happen, I need to create a .phpbrewrc
file in the project's root directory:
$ echo 'phpbrew use 5.3.29' > ~/Projects/my-legacy-project/.phpbrewrc
Then, I make sure PHPBREW_RC_ENABLE
is set. I usually add it to my ~/.bashrc
just before sourcing ~/.phpbrew/bashrc
:
export PHPBREW_RC_ENABLE=1
source ~/.phpbrew/bashrc
Given that the required version of PHP is already installed, when I enter the project's directory, the PHP version is automatically switched:
$ cd ~/Projects/my-legacy-project
$ php -v
PHP 5.3.29 (cli) (built: Aug 14 2014 19:35:35)
When the project's directory is left, and there's no .phpbrewrc
file in current directory or any of its parent directories, the default configuration of PHPBrew is loaded:
$ cd ~
$ php -v
PHP 5.6.2 (cli) (built: Oct 31 2014 19:51:53)
In fact, .phpbrewrc
is a regular text file which may contain any shell commands.