Add ability to customize & overwrite deployer stock commands #3802
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've reworked the
init()
function ofDeployer.php
to include amaybeAddCustomCommands()
function, which checks for aDeployerCommands
dir in the project root and, if any exist, integrate them with Deployer accordingly. Custom commands can either override stock Deployer commands or create new commands. These changes are 100% backwards-compatible, in that if noDeployerCommands
dir is present, there are no changes to the current functionality.One of the primary advantages of this restructure is the ability to customize the
deployer.php
templates being used, to include additional information or additional formats.Here is a gist demonstrating an example implementation of a customized
InitCommand.php
file, which would be placed insideDeployerCommands/
at the project root. In this example file, I've customizedconfigure()
-- customized theinit
command descriptionsetDomain()
-- new functionality to set project domain on initializationguessHost()
-- an example of a customized host-guessing procedure where our site includes ahost.php
file serving the hostname; this hostname can later be used in thedeployer.php
scriptAn alternative implementation of
guessHost()
could also integrate with a registrar's API, implementnslookup
, just for a few examples.For developers or engineering teams, the ability to override Deployer's stock commands and templates would make a huge improvement in standardizing implementation across projects, and allow them to script out many of the initial configuration steps for
deployer.php
which aren't quite covered by custom recipes.