WordPress + Composer + GIT

“I’m a strong independent developer who don’t need no team.” — No one, ever.

Git for Version Control

Composer + WPackagist

SSH and use the speed you deserve.

Overall Advantages

The Tutorial

.DS_Store
/content/
/wp/
wp-config.php
{
"name": "halles/wp-composer-site",
"description": "Basic template for creating a composer + wpackagist controlled site",
"authors": [
{
"name": "Matias Halles",
"email": "matias.halles@gmail.com"
}
],
"require": {
"wordpress": "4.5.*",
"wpackagist-plugin/w3-total-cache": "0.9.2",
"wpackagist-plugin/google-analytics-for-wordpress": "5.5.2"
},
"require-dev": {
"wpackagist-plugin/debug-bar": "0.8.2",
"wpackagist-plugin/debug-bar-console": "0.3"
},
"repositories":[
{
"type":"composer",
"url":"https://wpackagist.org"
},
{
"type" : "package",
"package" : {
"name" : "wordpress",
"type" : "webroot",
"version" : "4.5.2",
"dist" : {
"url" : "https://github.com/WordPress/WordPress/archive/4.5.2.zip",
"type" : "zip"
},
"source" : {
"url" : "https://github.com/WordPress/WordPress",
"type" : "git",
"reference" : "4.5.2"
},
"require" : {
"fancyguy/webroot-installer" : "1.0.0"
}
}
},
{
"type": "composer",
"url": "https://languages.koodimonni.fi"
}
],
"autoload": {
"psr-0": {
"Acme": "src/"
}
},
"config" : {
"vendor-dir": "content/vendor"
},
"extra" : {
"installer-paths": {
"content/plugins/{$name}/": ["type:wordpress-plugin"],
"content/themes/{$name}/": ["type:wordpress-theme"]
},
"webroot-dir" : "wp",
"webroot-package" : "wordpress",
"wordpress-install-dir": "wp",
"dropin-paths": {
"content/languages/": ["vendor:koodimonni-language"],
"content/languages/plugins/": ["vendor:koodimonni-plugin-language"],
"content/languages/themes/": ["vendor:koodimonni-theme-language"]
}
}
}
composer install
Change these lines in the require and require-dev properties (from line 10:- "wpackagist-plugin/w3-total-cache": "0.9.2",
+ "wpackagist-plugin/w3-total-cache": "*",
- "wpackagist-plugin/debug-bar": "0.8.2",
+ "wpackagist-plugin/debug-bar": "*",
- "wpackagist-plugin/debug-bar-console": "0.3"
+ wpackagist-plugin/debug-bar-console": "*"
And for wordpress, replace all three appearances of 4.5.2 by 4.5.3 under wordpress package definition (from line 25).- "version" : "4.5.2",
+ "version" : "4.5.3",
- "url" : "https://github.com/WordPress/WordPress/archive/4.5.2.zip",
+ "url" : "https://github.com/WordPress/WordPress/archive/4.5.3.zip",
- "reference" : "4.5.2"
+ "reference" : "4.5.3"
{
"name": "halles/wp-composer-theme",
"authors": [
{
"name": "Matias Halles",
"email": "matias.halles@gmail.com"
}
],
"type" : "wordpress-theme",
"require" : {
"composer/installers": "~1.0"
}
}
Into the require property add:"halles/wp-composer-theme": "dev-master",And under repositories:{
"type": "git",
"url": "git@github.com:halles/wp-composer-theme.git"
},

Now, what about deployment.

About customized paths for WordPress

<?php
define( 'WP_USE_THEMES', true );
require( './wp/wp-blog-header.php' );
<?php
/**
* Basic WP Config
*/
define('DB_NAME', 'db_name');
define('DB_USER', 'db_user');
define('DB_PASSWORD', 'db_pass');
define('DB_HOST', 'db_host');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', '');
$table_prefix = 'wp_';# Rememeber to get your salts at http://api.wordpress.org/secret-key/1.1/salt/define('AUTH_KEY', 'y%*XT).2%GS9D(DDaPmaH|dg8)BMh*>$w+(S2vWH!=avSS>Q9sdLMn<$`sv<a/!Z');
define('SECURE_AUTH_KEY', 'Bs >->v>0%`&2{^o^OP9Ta|wu9ESalMU?Y-^*Dd?Q$Fn:d{F:TmBp=r?nrW$dX<#');
define('LOGGED_IN_KEY', ';V-M%Z3M[IoJ{q_73gE25+-M@ge}B80DhkSRvx:Ax,/5gB@!2IOH4fv@kjbD()T`');
define('NONCE_KEY', 'qwsK_l*Tx)>X%bLm2+:1z%8a6|.+Yz7S=T2 +m<1jD!P2,pQ=R5(3aYl76W&{=tU');
define('AUTH_SALT', '):>bXn.2rVQ=m-mx[|^b!-e LKE`__Lp0V;zC>bB+--</Pnh3@cX7-2f=`RXM:eS');
define('SECURE_AUTH_SALT', 'Juey96K7;<KDIB>-8egHPge<+!rtt>OnK&:G$/bb[G-OWdfWx4{y9Kk?ka(GK7rb');
define('LOGGED_IN_SALT', 'Bb*on-)LpeuPEul0<GTY}*+|aQ--a;-QK/$ad)8b&oY+TkS)<]= z+(UI]jP]4pm');
define('NONCE_SALT', 'q!eu@*@_P3=!ovElTnP^?/1-`-tfvFa;Y;n%SizxtM*O2->V|%-hV*=O!Zx m!wy');
define('WPLANG', EN_us);/**
* Custom WordPress Install Path
*/
# Sets the site's admin location and the site's location, respectively
define( 'WP_SITEURL', 'https://yourhost.io/wp' );
define( 'WP_HOME', 'https://yourhost.io' );
# Sets the content location, related to what's defined on composer.json file
define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/content' );
define( 'WP_CONTENT_URL', WP_HOME . '/content');
# Sets the plugins location, related to what's defined on composer.json file
define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' );
# Disables the embebeded editor
define( 'DISALLOW_FILE_EDIT', true);
define( 'DISALLOW_FILE_MODS', true);
define( 'RELOCATE', true);
# Disables automatic update functions
define( 'AUTOMATIC_UPDATER_DISABLED', false );
define( 'WP_AUTO_UPDATE_CORE', false );
/**
* SSL
* You might want to force SSL on the admin page
*/
# define( 'FORCE_SSL_LOGIN', true );
# define( 'FORCE_SSL_ADMIN', true );
/**
* Debug Flags
* Use them under development environments
*/
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', false);
define('WP_DEBUG_DISPLAY', false);
define('SAVEQUERIES', false);
/* KEEP OUT BELOW *//** WordPress absolute path to the Wordpress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

--

--

I like computers, most people, music, the outdoors and parties. And food. Tech Director @Wikot Chile. Founder at @faqwomen, @faqmen, @zoup, @electrofilia, et al

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matías Halles

Matías Halles

I like computers, most people, music, the outdoors and parties. And food. Tech Director @Wikot Chile. Founder at @faqwomen, @faqmen, @zoup, @electrofilia, et al