6

I'm working on a laravel project where we use docker-compose for local development environment and we are trying to shorten the commands that we use for install composer dependencies and artisan with laravel/envoy. Here is an example of what we have done so far:

@task('composer-require')
   docker-compose exec -u 1000 web composer require {{ $package }}
@endtask

And use as follow envoy run composer-install --package=xxx/yyy

And now our Envoy.blade.php file is getting to big because we have to put each usage as a task and we have to remember all those names.

I want to know if it is possible, how can we take a command like this envoy run composer install xxx/yyy and define only a task named composer and then pass the install xxx/yyy part?

Sory about my english

Ivan Vilanculo
  • 648
  • 1
  • 11
  • 25

1 Answers1

7

You can pass the arguments like this envoy run deploy --command=require --package=laracasts/flash. You can also set defaults for --package and --command if you'd like. Where possible, use a deploy "story" rather than running one task at a time.

@servers(['web' => '127.0.0.1'])

@setup
    $package = isset($package) ? $package : "laravel/envoy";
    $command = isset($command) ? $command : "require";
@endsetup

@story('deploy')
    composer
@endstory

@task('composer')
    echo "Running: composer {{ $command }} {{ $package }}.";
    composer {{ $command }} {{ $package }}
@endtask

@finished
    echo "Envoy deployment complete.\r\n";
@endfinished
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
  • 1
    This is what I'm actually doing! I talked with Taylor Otwel and i found that is better to use something like bash to achieve my goals – Ivan Vilanculo Mar 19 '18 at 11:57
  • @karl-hill Is there a way to pass a parameter to the @ task function? I am trying to centralize some code instead of duplicating functions, and passing params to the command line isn't what I really need here. – kp123 Aug 11 '19 at 23:55