1

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.

fronzee
  • 1,668
  • 2
  • 21
  • 32

1 Answers1

2

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.

OptimusCrime
  • 14,662
  • 13
  • 58
  • 96
  • Ah, interesting. I'm using the official composer version (latest version) but it has not been updated yet. Guess I'll have to wait. I did find a workaround for now, but since it is a bit hacky, I will not post it here unless someone replies and asks for it. Your solution would probably be better for them for now. – fronzee Feb 14 '17 at 21:50