定制 edgrosvenor/adhoc 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

edgrosvenor/adhoc

Composer 安装命令:

composer require edgrosvenor/adhoc

包简介

Allow Laravel commands to accept ad hoc arguments and options

关键字:

README 文档

README

StyleCI ChipperCI Latest Version on Packagist

Allows the use of arguments in Laravel commands that are not defined in the signature. I'm not sure why you would ever want this. I know why I wanted it, but I'm reckless. So use at your own risk.

Installation

You can install the package via composer:

composer require edgrosvenor/adhoc

Usage

Create your commands as normal, but have them extend Adhoc\Command instead. Then any arguments you send to the command will set as attributes on the command object. So for instance, if you do:

php artisan do:something packages=fun

where adhoc is not in the signature of the command, in the execute method you can access it like this:

$this->packages; // fun

and you can access an array of the arguments passed like so:

$this->_adhoc; // ['packages']

Todo

I would like to find a cleaner way to extract the arguments. Without doing naughty things to the Symfony console, I can only seem to get the input as a string so I have to parse it by hand. It works, but I don't like the way it loks.

I also don't put arguments into the arguments array that Laravelians usually use to get arguments passed to their commands. So if you reach for $this->arguments('myadhocargument') it won't be there. I think mabye I should add it.

Finally, I think I might have a personal use case for ad hoc options. But until I am happier with how I'm extracting arguments I don't want to mess with options.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-16