Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass arguments or params to Laravel Envoy task

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

like image 231
Ivan Vilanculo Avatar asked Mar 06 '18 18:03

Ivan Vilanculo


1 Answers

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
like image 55
Karl Hill Avatar answered Oct 05 '22 16:10

Karl Hill