Created
March 12, 2015 01:19
-
-
Save mloberg/5e721a401506d96faea5 to your computer and use it in GitHub Desktop.
Boxen PHP Project Module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# modules/common/templates/nginx.conf.erb %> | |
# Example template for PHP-FPM based projects | |
# | |
# The template which nginx uses within a boxen::project can be overridden | |
# to a specific template such as this one. | |
# | |
# You will likely need to change both the root and SCRIPT_FILENAME parameters below | |
# to match your setup | |
# | |
server { | |
access_log <%= scope.lookupvar "nginx::config::logdir" %>/<%= @name %>.access.log main; | |
listen 80; | |
root <%= @dir %>/<%= @public_dir %>; | |
index index.php; | |
server_name <%= @server_name %>; | |
client_max_body_size 50M; | |
error_page 500 502 503 504 /50x.html; | |
try_files $uri $uri/ $uri/index.php?$query_string /index.php?$query_string; | |
location ~ \.php$ { | |
include <%= scope.lookupvar "nginx::config::configdir" %>/fastcgi_params; | |
keepalive_timeout 0; | |
fastcgi_pass unix:<%= scope.lookupvar "boxen::config::socketdir" %>/<%= @name %>; | |
fastcgi_param SCRIPT_FILENAME <%= @dir %>/<%= @public_dir %>/$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_script_name; | |
fastcgi_param APPLICATION_ENV dev; | |
fastcgi_read_timeout 3600s; | |
client_body_timeout 3600s; | |
send_timeout 3600s; | |
fastcgi_buffers 8 16k; | |
fastcgi_buffer_size 32k; | |
fastcgi_connect_timeout 3600s; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# modules/commin/templates/php.ini.erb %> | |
short_open_tag = Off | |
memory_limit = <%= @memory_limit %> | |
date.timezone = "<%= @timezone %>" | |
session.gc_maxlifetime = 86400 | |
; xdebug | |
debug.remote_host = 127.0.0.1 | |
xdebug.remote_port = 9000 | |
xdebug.remote_enable = 1 | |
xdebug.idekey = "PHPSTORM" | |
xdebug.remote_autostart = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modules/common/manifests/php.pp | |
define common::php ( | |
$version = $name, | |
$global = false, | |
$memory_limit = "1024M", | |
$timezone = "America/Chicago", | |
$apc = true, | |
$mcrypt = true, | |
$mongo = false, | |
$xdebug = true, | |
$intl = false, | |
$template = 'common/php.ini.erb', | |
) { | |
$version_class_name = regsubst($version, '\.', '_', 'G') | |
include "php::${version_class_name}" | |
if $global { | |
class { 'php::global': | |
version => $version, | |
} | |
} | |
if $apc { | |
php::extension::apc { "apc for ${version}": | |
php => $version, | |
} | |
} | |
if $mcrypt { | |
php::extension::mcrypt { "mcrypt for ${version}": | |
php => $version, | |
} | |
} | |
if $mongo { | |
php::extension::mongo { "mongo for ${version}": | |
php => $version, | |
} | |
} | |
if $xdebug { | |
php::extension::xdebug { "xdebug for ${version}": | |
php => $version, | |
version => '2.2.6', | |
} | |
} | |
if $intl { | |
php::extension::intl { "intl for ${version}": | |
php => $version, | |
} | |
} | |
file { "${php::config::configdir}/${version}/conf.d/php.ini": | |
content => template($template), | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modules/common/manifests/project.pp | |
# A Boxen-focused PHP project setup helper | |
# | |
# Options: | |
# | |
# dir => | |
# The directory to clone the project to. | |
# Defaults to "${boxen::config::srcdir}/${name}". | |
# | |
# dotenv => | |
# If true, creates "${dir}/.env" from | |
# "puppet:///modules/projects/${name}/dotenv". | |
# | |
# elasticsearch => | |
# If true, ensures elasticsearch is installed. | |
# | |
# memcached => | |
# If true, ensures memcached is installed. | |
# | |
# mongodb => | |
# If true, ensures mongodb is installed. | |
# | |
# cassandra => | |
# If true, ensures cassandra is installed. | |
# | |
# zookeeper => | |
# If true, ensures zookeeper is installed. | |
# | |
# beanstalk => | |
# If true, ensures beanstalk is installed. | |
# | |
# nsq => | |
# If true, ensures nsq is installed. | |
# | |
# zeromq => | |
# If true, ensures zeromq is installed. | |
# | |
# mysql => | |
# If set to true, ensures mysql is installed and creates databases named | |
# "${name}_development" and "${name}_test". | |
# If set to any string or array value, creates those databases instead. | |
# | |
# nginx => | |
# If true, ensures nginx is installed and uses standard template at | |
# modules/projects/templates/shared/nginx.conf.erb. | |
# If given a string, uses that template instead. | |
# | |
# postgresql => | |
# If set to true, ensures postgresql is installed and creates databases | |
# named "${name}_development" and "${name}_test". | |
# If set to any string or array value, creates those databases instead. | |
# | |
# redis => | |
# If true, ensures redis is installed. | |
# | |
# ruby => | |
# If given a string, ensures that ruby version is installed. | |
# Also creates "${dir}/.ruby-version" with content being this value. | |
# | |
# php => | |
# If given a string, ensures that php version is installed. | |
# Also creates "${dir}/.php-version" with content being this value. | |
# | |
# source => | |
# Repo to clone project from. REQUIRED. Supports shorthand <user>/<repo>. | |
# | |
# server_name => | |
# The hostname to use when accessing the application. | |
# | |
# fpm_pool => | |
# Location of custom FPM pool configuration file template. | |
# | |
define common::project( | |
$dir, | |
$dotenv = undef, | |
$elasticsearch = undef, | |
$memcached = undef, | |
$mongodb = undef, | |
$cassandra = undef, | |
$zookeeper = undef, | |
$beanstalk = undef, | |
$nsq = undef, | |
$zeromq = undef, | |
$mysql = undef, | |
$nginx = undef, | |
$nodejs = undef, | |
$postgresql = undef, | |
$redis = undef, | |
$ruby = undef, | |
$php = undef, | |
$fpm_pool = undef, | |
$server_name = "${name}.localhost", | |
$public_dir = 'web', | |
) { | |
include boxen::config | |
if $dotenv { | |
file { "${dir}/.env": | |
source => "puppet:///modules/projects/${name}/dotenv", | |
} | |
} | |
if $elasticsearch { | |
include elasticsearch | |
} | |
if $memcached { | |
include memcached | |
} | |
if $mongodb { | |
include mongodb | |
} | |
if $cassandra { | |
include cassandra | |
} | |
if $beanstalk { | |
include beanstalk | |
} | |
if $zookeeper { | |
include zookeeper | |
} | |
if $zeromq { | |
include zeromq | |
} | |
if $nsq { | |
include nsq | |
} | |
if $mysql { | |
$mysql_dbs = $mysql ? { | |
true => ["${name}_development", "${name}_testing"], | |
default => $mysql, | |
} | |
mysql::db { $mysql_dbs: } | |
} | |
if $nginx { | |
include nginx::config | |
include nginx | |
$nginx_templ = $nginx ? { | |
true => 'projects/shared/nginx.conf.erb', | |
default => $nginx, | |
} | |
file { "${nginx::config::sitesdir}/${name}.conf": | |
content => template($nginx_templ), | |
require => File[$nginx::config::sitesdir], | |
notify => Service['dev.nginx'], | |
} | |
} | |
if $nodejs { | |
nodejs::local { $dir: | |
version => $nodejs, | |
} | |
} | |
if $postgresql { | |
$psql_dbs = $postgresql ? { | |
true => ["${name}_development"], | |
default => $postgresql, | |
} | |
postgresql::db { $psql_dbs: } | |
} | |
if $redis { | |
include redis | |
} | |
if $ruby { | |
ruby::local { $dir: | |
version => $ruby, | |
} | |
} | |
if $php { | |
# Set the local version of PHP | |
php::local { $dir: | |
version => $php, | |
} | |
# Spin up a PHP-FPM pool for this project, listening on an Nginx socket | |
php::fpm::pool { "${name}-${php}": | |
version => $php, | |
socket_path => "${boxen::config::socketdir}/${name}", | |
require => File["${nginx::config::sitesdir}/${name}.conf"], | |
max_children => 10, | |
} | |
if $fpm_pool { | |
Php::Fpm::Pool["${name}-${php}"] { | |
fpm_pool => $fpm_pool | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment