1

After a basic install of PHP deployer v4.2.1 I find that it does not work (see below) with the officially endorsed 3rd party recipes out of the box. I am fairly new to Deployer. Here is what I did.

I installed PHP deployer v4.2.1 with:

composer require --dev deployer/deployer
composer require --dev deployer/recipes

And of course I ran dep init to get set up with a basic deploy.php file.

In my deploy.php I added the following at the top:

namespace Deployer;

require 'recipe/laravel.php';
require 'vendor/deployer/recipes/local.php';
require 'vendor/deployer/recipes/rsync.php';
require 'vendor/deployer/recipes/npm.php';
require 'vendor/deployer/recipes/cachetool.php';

Then I set my git repository, server info, etc. My final deploy task runs the local:prepare command and this is where it chokes with an odd error:

PHP Fatal error:  Uncaught Error: Call to undefined function Deployer\desc() in /home/vagrant/Code/MyProject/vendor/deployer/recipes/local.php:76

Obviously there is some namespacing issue going on.

Somehow I figured out that I can get around the issue if I make a local copy (outside vendor dir) of the 3rd party recipe files, and then modify them so the calls to desc(...) follow task(...) like task(...)->desc(...). This works, but now I am running into other issues and I feel like I'm headed down the wrong path. I feel like this is an unacceptable work around for what is basically a fresh installation. The laravel.php recipe that comes bundled with Deployer calls desc(...) all by itself and not after task(...)->desc(...), so it seems to me that the 3rd party recipes should be able to handle it, but they throw an error. (Even with namespace Deployer; declared at the top, or perhaps because of it.)

Anybody else encounter this issue? Is there something simple I forgot to add to deploy.php so I don't have to modify vendor files?

fronzee
  • 1,668
  • 2
  • 21
  • 32
  • everything in vendor directory is not meant be changed manually, try deleting vendor directory contents and run composer install so it can start installing everything again also it will execute commands if any in composer.json if problem persists try posting composer.json content and PHP versions – Gntem Feb 13 '17 at 20:28
  • I didn't edit the vendor files directly. I made a local copy of the vendor files outside of the vendor directory and included those. Whatever the case, I just tried another experiment on a fresh project and it still errored out: (a) mkdir myEmptyDir (b) cd myEmptyDir (c) composer require --dev deployer/deployer (and also deployer/recipes) (d) dep init [choose laravel], (e) edit deploy.php and after laravel recipe is included, add "require('vendor/deployer/recipes/local.php');" (f) add a dummy 'test' task that does nothing (exit after). Even with this basic setup, running "dep test" errors out. – fronzee Feb 13 '17 at 21:44
  • @Mr.Phoenix Nevermind I found the answer. Posted separately here. – fronzee Feb 13 '17 at 21:56

1 Answers1

2

(Going to answer my own question here...)

I had a globally installed dep that was version 3.3.0 (installed manually without composer), and this was the file that was running everytime I typed dep instead of the newer, locally installed project version of dep. So it was trying to run 4.2.1 recipes with 3.3.0 deployer.

Solution:

Run this from the command line:

php vendor/bin/dep deploy [server]

instead of:

dep deploy [server]
fronzee
  • 1,668
  • 2
  • 21
  • 32