Composer, source code from private Gitlab and public Github for Sage 9 and Roots for WordPress Plugin & Theme Development

I want to split out my custom plugins and themes from my Roots repo so I can make it private, I just dont trust Ansible Vault enough, and there is always the chance of forgetting to encrypt with the key and committing the secrets and putting it into the git history.

I also want to manage the THEMES as well as the plugins to the git repo’s via Composer and GIT i.e. gitlab and doing this was surprisingly complicated and not well documented.

Bedrock i.e. site folder composer.json

my composer.json folder for Bedrock, the site scaffolding, looks like this


{
"name": "roots/bedrock",
"type": "project",
"license": "MIT",
"description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
"homepage": "https://roots.io/bedrock/",
"authors": [
{
"name": "Scott Walkinshaw",
"email": "[email protected]",
"homepage": "https://github.com/swalkinshaw"
},
{
"name": "Ben Word",
"email": "[email protected]",
"homepage": "https://github.com/retlehs"
}
],
"keywords": [
"bedrock", "roots", "wordpress", "stack", "composer", "vagrant", "wp"
],
"support": {
"issues": "https://github.com/roots/bedrock/issues",
"forum": "https://discourse.roots.io/category/bedrock"
},
"config": {
"preferred-install": "dist"
},
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
},
{
"type": "package",
"package": {
"name": "MWDelaney/acf-complex-titles",
"version": "1.11",
"type": "wordpress-plugin",
"source": {
"type": "git",
"url": "https://github.com/MWDelaney/acf-complex-titles.git",
"reference": "1.11"
},
"require": {
"composer/installers": "*"
}
}
},
{
"type": "package",
"package": {
"name": "openplanetculture/openplanetculture-wp",
"version": "master",
"type": "wordpress-plugin",
"source": {
"type": "git",
"url": "[email protected]:openplanetculture/openplanetculture-wp.git",
"reference": "master"
},
"require": {
"composer/installers": "*"
}
}
},
{
"type": "package",
"package": {
"name": "openplanetculture/openplanetculture-litera",
"version": "master",
"type": "wordpress-theme",
"source": {
"type": "git",
"url": "[email protected]:openplanetculture/openplanetculture-litera.git",
"reference": "master"
},
"require": {
"composer/installers": "*"
}
}
},
{
"type": "package",
"package": {
"name": "openplanetculture/openplanetculture",
"version": "master",
"type": "wordpress-theme",
"source": {
"type": "git",
"url": "[email protected]:openplanetculture/openplanetculture.git",
"reference": "master"
},
"require": {
"composer/installers": "*"
}
}
}
],
"require": {
"php": ">=5.6",
"composer/installers": "~1.0.12",
"vlucas/phpdotenv": "^2.0.1",
"johnpbloch/wordpress": "4.7.3",
"oscarotero/env": "^1.0",
"openplanetculture/openplanetculture-wp": "@dev",
"openplanetculture/openplanetculture-litera": "@dev",
"wpackagist-plugin/megamenu": "2.3.5",
"MWDelaney/acf-complex-titles": "1.11",
"wpackagist-plugin/advanced-custom-fields": "4.4.11",
"roots/wp-password-bcrypt": "1.0.0"

},
"require-dev": {
"squizlabs/php_codesniffer": "^2.5.1"
},
"extra": {
"installer-paths": {
"web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
"web/app/plugins/{$name}/": ["type:wordpress-plugin"],
"web/app/themes/{$name}/": ["type:wordpress-theme"]
},
"wordpress-install-dir": "web/wp"
},
"scripts": {
"test": [
"vendor/bin/phpcs"
]
}
}

custom theme

my custom theme is on Gitlab and public and the composer.json for the theme looks like this


{
"name": "openplanetculture/openplanetculture",
"type": "wordpress-theme",
"license": "MIT",
"description": "Open Planet Culture Bootstrap 4 for Material Design",
"homepage": "http://openplanetculture.com",
"authors": [
{
"name": "Nicholas Roberts",
"email": "[email protected]",
"homepage": "https://github.com/devekkoio"
}
],
"keywords": [
"wordpress"
],
"support": {
"issues": "https://gitlab.com/openplanetculture/openplanetculture.com-theme/issues"
},
"autoload": {
"psr-4": {
"Roots\\Sage\\": "src/lib/Sage/"
}
},
"require": {
"php": ">=5.6.4",
"composer/installers": "~1.0",
"illuminate/view": "~5.3.0",
"illuminate/config": "~5.3.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.5.1"
},
"scripts": {
"test": [
"vendor/bin/phpcs"
],
"post-create-project-cmd": [
"Roots\\Sage\\PostCreateProject::updateHeaders",
"Roots\\Sage\\PostCreateProject::selectFramework",
"Roots\\Sage\\PostCreateProject::addFontAwesome"
]
}
}

and the remotes for the theme


➜ openplanetculture-wp git:(master) ✗ git remote -v
composer [email protected]:openplanetculture/openplanetculture-wp.git (fetch)
composer [email protected]:openplanetculture/openplanetculture-wp.git (push)
origin [email protected]:openplanetculture/openplanetculture-wp.git (fetch)
origin [email protected]:openplanetculture/openplanetculture-wp.git (push)

custom plugin

the scaffolding/stub for the custom plugin composer.json looks like


{
"name": "openplanetculture/openplanetculture-wp",
"version": "1.0.1",
"description": "Open Planet Culture WordPress plugin",
"type": "wordpress-plugin",
"dependencies": {},
"devDependencies": {},
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://gitlab.com/openplanetculture/openplanetculture-wp.git"
},
"authors": [
{
"name": "Nicholas Roberts",
"email": "[email protected]"
}
],
"license": "GPL3",
"bugs": {
"url": "https://gitlab.com/openplanetculture/openplanetculture-wp/issues"
},
"homepage": "https://gitlab.com/openplanetculture/openplanetculture-wp#readme"
}

Gitignore

I added themes to the plugins in gitignore


# Application
web/app/themes/*
web/app/plugins/*
!web/app/plugins/.gitkeep
web/app/mu-plugins/*/
web/app/upgrade
web/app/uploads/*
!web/app/uploads/.gitkeep

# WordPress
web/wp
web/.htaccess

# Dotenv
.env
.env.*
!.env.example

# Composer
vendor/*
!vendor/.gitkeep
node_modules

Deploying a site

every time you update, you need to commit all the repos, themes, plugins, and the roots root folder, if there are changes in references you need to run composer update and update the locks


composer update
git commit -am "source and ref"
git push
ansible-playbook deploy.yml -e "site=openplanetculture.com env=production" -vvv --ask-vault-pass