Skip to content

Numergy/phpenv-cookbook

Repository files navigation

phpenv Cookbook | Build Status

Manage installation of multiple PHP versions via phpenv and php-build. Also provides a set of lightweight resources and providers.

If you've used rbenv or pyenv, this is a port of that concept for PHP.

Requirements

  • build-essential
  • apt

Attributes

phpenv::default

Key Type Description Default
['phpenv']['user'] String Default user phpenv
['phpenv']['user_home'] String User home /home/phpenv
['phpenv']['manage_home'] Boolean Manage home true
['phpenv']['group'] String Group to used phpenv
['phpenv']['group_users'] Array User in the group []
['phpenv']['root_path'] String Path to install phpenv /opt/phpenv
['phpenv']['create_profiled'] Boolean Create file in profile.d true
['phpenv']['git_force_update'] Boolean Force update phpenv git repository true
['phpenv']['git_repository'] String Git repository for phpenv https://github.com/CHH/phpenv.git
['phpenv']['git_reference'] String Git reference for the git repository master
['phpenv']['php-build']['git_force_update'] Boolean Force update php-build git repository true
['phpenv']['php-build']['git_repository'] String Git repository for php-build https://github.com/CHH/php-build.git
['phpenv']['php-build']['git_reference'] String Git reference for the git repository master
['phpenv']['php-build']['git_sync_path'] String Git repository cache path/td> /tmp
['phpenv']['php-build']['packages'] Array Packages to install git

Resources and providers

phpenv_build

This resource installs a specified version of PHP.

Actions

Action Description Default
:install Build and install a PHP version. Yes

Attributes

Attribute Description Default Value
version Name attribute: the name of a PHP version (e.g. `5.3.28`) nil
user A users's isolated phpenv installation on which to apply an action. The default value of nil denotes a system-wide phpenv installation is being targeted. Note: if specified, the user must already exist. nil
root_path The path prefix to phpenv installation, for example: /opt/phpenv. nil
environment A hash of environment variables to set before running this command. nil

Examples

Install PHP 5.3.28
phpenv_build '5.3.28' do
  action :install
end
phpenv_build '5.3.28'

Note: the install action is default, so the second example is a more common usage.

phpenv_script

This resource is a wrapper for the script resource which wraps the code block in an phpenv-aware environment. See the Opscode script resource documentation for more details.

Actions

Action Description Default
run Run the script Yes

Attributes

Attribute Description Default Value
name Name attribute: Name of the command to execute. name
phpenv_version A version of PHP being managed by phpenv. nil
root_path The path prefix to phpenv installation, for example: /opt/phpenv. nil
code Quoted script of code to execute or simply a path to a file to execute in phpenv context. nil
creates A file this command creates - if the file exists, the command will not be run. nil
cwd Current working directory to run the command from. nil
environment A hash of environment variables to set before running this command. nil
group A group or group ID that we should change to before running this command. nil
path An array of paths to use when searching for the command. nil, uses system path
returns The return value of the command (may be an array of accepted values) this resource raises an exception if the return value(s) do not match. 0
timeout How many seconds to let the command run before timing out. nil
user A users's isolated phpenv installation on which to apply an action. The default value of nil denotes a system-wide phpenv installation is being targeted. Note: if specified, the user must already exist. nil
umask Umask for files created by the command. nil

Examples

Reload cache by running command
phpenv_script 'reload-cache' do
  phpenv_version '5.4.0'
  user           'deploy'
  group          'deploy'
  cwd            '/opt/shared'
  code           './reload-cache.php'
end

phpenv_global

This resource sets the global version of PHP to be used in all shells.

Actions

Action Description Default
create Sets the global version of PHP to be used in all shells. Yes

Attributes

Attribute Description Default Value
phpenv_version Name attribute: a version of PHP being managed by phpenv. Note: the version of PHP must already be installed but not installed it automatically. nil
user A users's isolated phpenv installation on which to apply an action. The default value of nil denotes a system-wide phpenv installation is being targeted. Note: if specified, the user must already exist. nil
root_path The path prefix to phpenv installation, for example: /opt/phpenv. nil

Examples

Set PHP 5.3.28 as global
phpenv_global "5.3.28"
Set system php version as global
phpenv_global 'system'
Set PHP 5.4.0 as global for a user
phpenv_global '5.4.0' do
  user 'bamboo'
end

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add_component_x)
  3. Write your change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request using Github

License and Authors

Authors:

About

Cookbook for installing phpenv to manage multiple PHP versions

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •