The PHP Deployer docs on this page are wrong.
In the section labeled "Reconfigure" it says:
You can reconfigure tasks, e.g. provided by 3rd part recipes by retrieving them by name:
task('notify')->onlyOn([
'firstserver',
'thirdserver',
]);
This simply does not work with the current version. I get an error:
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to
function Deployer\task(), 1 passed in /home/vagrant/Code/MyProject
/deploy.php on line 78 and exactly 2 expected in /home/vagrant
/Code/MyProject/vendor/deployer/deployer/src/functions.php:143
Looking at the vendor src file, the task()
function does indeed require two arguments. It does not act as a getter when passing only one argument.
Is there any (existing) way to get a task and reconfigure it as intended in the docs? What is the correct version? I tried using get
instead of task
:
get($taskName)->onlyOn([...])
But that does not work either.
Are you sure you have the latest version? The optional argument body
was introduced in this commit #c37237. Before that the argument was required.
That commit is only one day old, so it may seem like you need to use the dev-master
version in your Composer file.
composer require deployer/deployer:dev-master
Edit: Also the related documentation was updated yesterday. Unless you have a version newer than that, you are looking at docs that does not fit your environment.