New Supermarket Announcements!

The Chef Community Cookbooks Survey

We would love to know more about what you think about community cookbooks and are runnning a quick survey. This will help us understand the role they play in your use of Chef. As a community member, you are invited to participate. You have a unique understanding of the role community cookbooks have in your work, and we value your opinion. Most people take about 5 minutes to complete this survey. There are no right or wrong answers; we are interested in your opinions.
Chef Community Cookbooks Survey

Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the supermarket mailing list or in Gitter.

Select Supported Platforms

RSS

php (31) Versions 1.7.0

Installs and maintains php and php modules

Berkshelf
Librarian
Knife
cookbook 'php', '~> 1.7.0'
cookbook 'php', '~> 1.7.0'
knife cookbook site install php
knife cookbook site download php
README
Dependencies
Changelog
Foodcritic

php Cookbook

Join the chat at https://gitter.im/opscode-cookbooks/php Cookbook Version Build Status

Installs and configures PHP 5.3 and the PEAR package management system. Also includes LWRPs for managing PEAR (and PECL) packages, PECL channels, and PHP-FPM pools.

Requirements

Platforms

  • Debian, Ubuntu
  • CentOS, Red Hat, Fedora, Amazon Linux
  • Microsoft Windows

Cookbooks

  • build-essential
  • xml
  • mysql

These cookbooks are only used when building PHP from source.

Attributes

  • node['php']['install_method'] = method to install php with, default package.
  • node['php']['directives'] = Hash of directives and values to append to php.ini, default {}.

The file also contains the following attribute types:

  • platform specific locations and settings.
  • source installation settings

Resource/Provider

This cookbook includes LWRPs for managing:

  • PEAR channels
  • PEAR/PECL packages

php_pear_channel

PEAR Channels are alternative sources for PEAR packages. This LWRP provides and easy way to manage these channels.

Actions

  • :discover: Initialize a channel from its server.
  • :add: Add a channel to the channel list, usually only used to add private channels. Public channels are usually added using the :discover action
  • :update: Update an existing channel
  • :remove: Remove a channel from the List

Attribute Parameters

  • channel_name: name attribute. The name of the channel to discover
  • channel_xml: the channel.xml file of the channel you are adding

Examples

# discover the horde channel
php_pear_channel "pear.horde.org" do
  action :discover
end

# download xml then add the symfony channel
remote_file "#{Chef::Config[:file_cache_path]}/symfony-channel.xml" do
  source "http://pear.symfony-project.com/channel.xml"
  mode 0644
end
php_pear_channel "symfony" do
  channel_xml "#{Chef::Config[:file_cache_path]}/symfony-channel.xml"
  action :add
end

# update the main pear channel
php_pear_channel 'pear.php.net' do
  action :update
end

# update the main pecl channel
php_pear_channel 'pecl.php.net' do
  action :update
end

php_pear

PEAR is a framework and distribution system for reusable PHP components. PECL is a repository for PHP Extensions. PECL contains C extensions for compiling into PHP. As C programs, PECL extensions run more efficiently than PEAR packages. PEARs and PECLs use the same packaging and distribution system. As such this LWRP is clever enough to abstract away the small differences and can be used for managing either. This LWRP also creates the proper module .ini file for each PECL extension at the correct location for each supported platform.

Actions

  • :install: Install a pear package - if version is provided, install that specific version
  • :upgrade: Upgrade a pear package - if version is provided, upgrade to that specific version
  • :remove: Remove a pear package
  • :purge: Purge a pear package (this usually entails removing configuration files as well as the package itself). With pear packages this behaves the same as :remove

Attribute Parameters

  • package_name: name attribute. The name of the pear package to install
  • version: the version of the pear package to install/upgrade. If no version is given latest is assumed.
  • preferred_state: PEAR by default installs stable packages only, this allows you to install pear packages in a devel, alpha or beta state
  • directives: extra extension directives (settings) for a pecl. on most platforms these usually get rendered into the extension's .ini file
  • zend_extensions: extension filenames which should be loaded with zend_extension.
  • options: Add additional options to the underlying pear package command

Examples

# upgrade a pear
php_pear "XML_RPC" do
  action :upgrade
end


# install a specific version
php_pear "XML_RPC" do
  version "1.5.4"
  action :install
end


# install the mongodb pecl
php_pear "mongo" do
  action :install
end

# install the xdebug pecl
php_pear "xdebug" do
  # Specify that xdebug.so must be loaded as a zend extension
  zend_extensions ['xdebug.so']
  action :install
end


# install apc pecl with directives
php_pear "apc" do
  action :install
  directives(:shm_size => 128, :enable_cli => 1)
end


# install the beta version of Horde_Url
# from the horde channel
hc = php_pear_channel "pear.horde.org" do
  action :discover
end
php_pear "Horde_Url" do
  preferred_state "beta"
  channel hc.channel_name
  action :install
end


# install the YAML pear from the symfony project
sc = php_pear_channel "pear.symfony-project.com" do
  action :discover
end
php_pear "YAML" do
  channel sc.channel_name
  action :install
end

php_fpm_pool

Installs the php-fpm package appropriate for your distro (if using packages) and configures a FPM pool for you. Currently only supported in Debian-family operating systems and CentOS 7 (or at least tested with such, YMMV if you are using source).

Please consider FPM functionally pre-release, and test it thoroughly in your environment before using it in production

More info: http://php.net/manual/en/install.fpm.php

Actions

  • :install: Installs the FPM pool (default).
  • :uninstall: Removes the FPM pool.

Attribute Parameters

  • pool_name: name attribute. The name of the FPM pool.
  • listen: The listen address. Default: /var/run/php5-fpm.sock
  • user: The user to run the FPM under. Default should be the webserver user for your distro.
  • group: The group to run the FPM under. Default should be the webserver group for your distro.
  • process_manager: Process manager to use - see http://php.net/manual/en/install.fpm.configuration.php. Default: dynamic
  • max_children: Max children to scale to. Default: 5
  • start_servers: Number of servers to start the pool with. Default: 2
  • min_spare_servers: Minimum number of servers to have as spares. Default: 1
  • max_spare_servers: Maximum number of servers to have as spares. Default: 3
  • chdir: The startup working directory of the pool. Default: /

Examples

# Install a FPM pool named "default"
php_fpm_pool "default" do
  action :install
end

Recipes

default

Include the default recipe in a run list, to get php. By default php is installed from packages but this can be changed by using the install_method attribute.

package

This recipe installs PHP from packages.

source

This recipe installs PHP from source.

Deprecated Recipes

The following recipes are deprecated and will be removed from a future version of this cookbook.

  • module_apc
  • module_curl
  • module_fileinfo
  • module_fpdf
  • module_gd
  • module_ldap
  • module_memcache
  • module_mysql
  • module_pgsql
  • module_sqlite3

The installation of the php modules in these recipes can now be accomplished by installing from a native package or via the new php_pear LWRP. For example, the functionality of the module_memcache recipe can be enabled in the following ways:

# using apt
package "php5-memcache" do
  action :install
end

# using pear LWRP
php_pear "memcache" do
  action :install
end

Usage

Simply include the php recipe where ever you would like php installed. To install from source override the node['php']['install_method'] attribute with in a role:

name "php"
description "Install php from source"
override_attributes(
  "php" => {
    "install_method" => "source"
  }
)
run_list(
  "recipe[php]"
)

Development

This section details "quick development" steps. For a detailed explanation, see [[Contributing.md]].

  1. Clone this repository from GitHub:

    $ git clone git@github.com:opscode-cookbooks/php.git
    
  2. Create a git branch

    $ git checkout -b my_bug_fix
    
  3. Install dependencies:

    $ bundle install
    
  4. Make your changes/patches/fixes, committing appropiately

  5. Write tests

  6. Run the tests:

    • bundle exec foodcritic -f any .
    • bundle exec rspec
    • bundle exec rubocop
    • bundle exec kitchen test

In detail: - Foodcritic will catch any Chef-specific style errors - RSpec will run the unit tests - Rubocop will check for Ruby-specific style errors - Test Kitchen will run and converge the recipes

License & Authors

Copyright:: 2013-2014, Chef Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Note: This cookbook contains a modified copy of go-phar.pear for use on the Microsoft Windows platform only to correct an (upstream bug)[http://pear.php.net/bugs/bug.php?id=16644]. The original go-pear.phar is licensed under the (PHP License version 2.02)[http://www.php.net/license/2_02.txt]:

--------------------------------------------------------------------
                  The PHP License, version 2.02
Copyright (c) 1999 - 2002 The PHP Group. All rights reserved.
--------------------------------------------------------------------

Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:

  1. Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above
     copyright notice, this list of conditions and the following
     disclaimer in the documentation and/or other materials provided
     with the distribution.

  3. The name "PHP" must not be used to endorse or promote products
     derived from this software without prior permission from the
     PHP Group.  This does not apply to add-on libraries or tools
     that work in conjunction with PHP.  In such a case the PHP
     name may be used to indicate that the product supports PHP.

  4. The PHP Group may publish revised and/or new versions of the
     license from time to time. Each version will be given a
     distinguishing version number.
     Once covered code has been published under a particular version
     of the license, you may always continue to use it under the
     terms of that version. You may also choose to use such covered
     code under the terms of any subsequent version of the license
     published by the PHP Group. No one other than the PHP Group has
     the right to modify the terms applicable to covered code created
     under this License.

  5. Redistributions of any form whatsoever must retain the following
     acknowledgment:
     "This product includes PHP, freely available from
     http://www.php.net/".

  6. The software incorporates the Zend Engine, a product of Zend
     Technologies, Ltd. ("Zend"). The Zend Engine is licensed to the
     PHP Association (pursuant to a grant from Zend that can be
     found at http://www.php.net/license/ZendGrant/) for
     distribution to you under this license agreement, only as a
     part of PHP.  In the event that you separate the Zend Engine
     (or any portion thereof) from the rest of the software, or
     modify the Zend Engine, or any portion thereof, your use of the
     separated or modified Zend Engine software shall not be governed
     by this license, and instead shall be governed by the license
     set forth at http://www.zend.com/license/ZendLicense/.



THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------

This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.

The PHP Group can be contacted via Email at group@php.net.

For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.

Dependent cookbooks

iis >= 0.0.0
windows >= 0.0.0
yum-epel >= 0.0.0
mysql >= 6.0.0
xml >= 0.0.0
build-essential >= 0.0.0

Contingent cookbooks

aegir Applicable Versions
aegir2 Applicable Versions
aegir3 Applicable Versions
application Applicable Versions
application_php Applicable Versions
application_zf Applicable Versions
beanstalk-console Applicable Versions
boilerplate_php Applicable Versions
boxbilling Applicable Versions
bricks Applicable Versions
cakephp Applicable Versions
composer Applicable Versions
drupal Applicable Versions
dvwa Applicable Versions
elefant Applicable Versions
frontaccounting Applicable Versions
gallery Applicable Versions
gotcms Applicable Versions
jenkins-php Applicable Versions
lamp_role Applicable Versions
laravel Applicable Versions
logstash Applicable Versions
magento Applicable Versions
magento-toolbox Applicable Versions
magerun Applicable Versions
mediawiki Applicable Versions
myface Applicable Versions
nagios Applicable Versions
newrelic Applicable Versions
newrelic-ng Applicable Versions
oracle-instantclient Applicable Versions
owncloud Applicable Versions
pdepend Applicable Versions
phabricator Applicable Versions
phing Applicable Versions
php-box Applicable Versions
php-fpm Applicable Versions
php-ioncube Applicable Versions
php-mcrypt Applicable Versions
phpbb Applicable Versions
phpcb Applicable Versions
phpcpd Applicable Versions
phpcs Applicable Versions
phpdcd Applicable Versions
phpdoc Applicable Versions
phploc Applicable Versions
phpmd Applicable Versions
phpmyadmin Applicable Versions
phpstack Applicable Versions
phpunit Applicable Versions
pinba Applicable Versions
postfixadmin Applicable Versions
rackspace_apache_php Applicable Versions
rackspace_nginx_php Applicable Versions
roundcube Applicable Versions
stack_commons Applicable Versions
sugar_crm Applicable Versions
sugarcrm Applicable Versions
sugarcrm-ce Applicable Versions
sugarcrm_ce Applicable Versions
suhosin Applicable Versions
symfony Applicable Versions
teampass Applicable Versions
teamspeak Applicable Versions
testswarm Applicable Versions
toran Applicable Versions
vicnum Applicable Versions
wordpress Applicable Versions
xdebug Applicable Versions
ya-piwik Applicable Versions
zabbix Applicable Versions
zabbix-pkg Applicable Versions
zf2 Applicable Versions

php Cookbook CHANGELOG

This file is used to list changes made in each version of the php cookbook.

v1.7.0 (2015-7-31)

  • Allow additional PHP FPM config
  • Add recipe to recompile PHP from source
  • Move source dependencies to attributes file
  • Misc bug fixes

v1.6.0 (2015-7-6)

  • Added ChefSpec matchers
  • Added basic PHP-FPM Support (Pre-Release)
  • Added support for FreeBSD
  • Updated cookbook to use MySQL 6.0 cookbook
  • Update cookbook to use php5enmod on supported platforms
  • Allow users to override php-mysql package

v1.5.0 (2014-10-06)

  • Adding package_options attribute, utilizing in package resource

v1.4.6 (2014-03-19)

  • [COOK-4436] - Test this cookbook, not yum. Also test Fedora 20.
  • [COOK-4427] - Add oracle as supported operating system

v1.4.4 (2014-03-12)

  • [COOK-4393] - Fix convergence bug in source install

v1.4.2 (2014-02-27)

[COOK-4300] - Simplified and fixed pear/pecl logic. [Fixes #56 / #57]

v1.4.0 (2014-02-27)

[COOK-3639] - Allow users to specify php.ini source template

v1.3.14 (2014-02-21)

Bug

  • COOK-4186 - Upgrade_package concatenates an empty version string when version is not set or is empty.

v1.3.12 (2014-01-28)

Fix github issue 'Cannot find a resource for preferred_state'

v1.3.10

Fixing my stove

v1.3.8

Version bump to ensure artifact sanity

v1.3.6

Version bump for toolchain

v1.3.4

Adding platform_family check to include_recipe in source.rb

v1.3.2

Fixing style cops. Updating test harness

v1.3.0

Bug

  • COOK-3479 - Added Windows support to PHP
  • COOK-2909 - Warnings about Chef::Exceptions::ShellCommandFailed is deprecated

v1.2.6

Bug

  • COOK-3628 - Fix PHP download URL
  • COOK-3568 - Fix Test Kitchen tests
  • COOK-3402 - When the ext_dir setting is present, configure php properly for the source recipe
  • COOK-2926 - Fix pear package detection when installing specific version

v1.2.4

Improvement

  • COOK-3047 - Sort directives in php.ini
  • COOK-2928 - Abstract php.ini directives into variables

Bug

v1.2.2

Bug

  • [COOK-3050]: lib_dir declared in wrong place for redhat
  • [COOK-3102]: remove fileinfo recipe from php cookbook

Improvement

  • [COOK-3101]: use a method to abstract range of "el 5" versions in php recipes

v1.2.0

Improvement

  • [COOK-2516]: Better support for SUSE distribution for php cookbook
  • [COOK-3035]: update php::source to install 5.4.15 by default

Bug

  • [COOK-2463]: PHP PEAR Provider Installs Most Recent Version, Without Respect to Preferred State
  • [COOK-2514]: php_pear: does not handle more exotic version strings

v1.1.8

  • [COOK-1998] - Enable override of PHP packages in attributes

v1.1.6

  • [COOK-2324] - adds Oracle linux support

v1.1.4

  • [COOK-2106] - php_pear cannot find available packages

v1.1.2

  • [COOK-1803] - use better regexp to match package name
  • [COOK-1926] - support Amazon linux

v1.1.0

  • [COOK-543] - php.ini template should be configurable
  • [COOK-1067] - support for PECL zend extensions
  • [COOK-1193] - update package names for EPEL 6
  • [COOK-1348] - rescue Mixlib::ShellOut::ShellCommandFailed (chef 0.10.10)
  • [COOK-1465] - fix pear extension template

v1.0.2

  • [COOK-993] Add mhash-devel to centos php source libs
  • [COOK-989] - bump version of php to 5.3.10
  • Also download the .tar.gz instead of .tar.bz2 as bzip2 may not be in the base OS (e.g., CentOS 6 minimal)
FC002: Avoid string interpolation where not required: /tmp/cook/ec0a1697eb5421cb99259248/php/providers/pear.rb:240
FC017: LWRP does not notify when updated: /tmp/cook/ec0a1697eb5421cb99259248/php/providers/pear_channel.rb:31
FC017: LWRP does not notify when updated: /tmp/cook/ec0a1697eb5421cb99259248/php/providers/pear_channel.rb:40
FC017: LWRP does not notify when updated: /tmp/cook/ec0a1697eb5421cb99259248/php/providers/pear_channel.rb:69
FC031: Cookbook without metadata file: /tmp/cook/ec0a1697eb5421cb99259248/php/metadata.rb:1
FC034: Unused template variables: /tmp/cook/ec0a1697eb5421cb99259248/php/templates/default/fpm-pool.conf.erb:1
FC045: Consider setting cookbook name in metadata: /tmp/cook/ec0a1697eb5421cb99259248/php/metadata.rb:1