定制 hgraca/composer-system-requirements-plugin 二次开发

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

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

hgraca/composer-system-requirements-plugin

最新稳定版本:v1.0.0

Composer 安装命令:

composer require hgraca/composer-system-requirements-plugin

包简介

A composer plugin to manage system dependencies.

README 文档

README

build status coverage report

This is a composer plugin that will check for requirements at the OS level itself, for example checking if Bash is installed and at a version above 5.0.

How to use

Install and allow the plugin

composer require "hgraca/composer-system-requirements-plugin"
{
  "name": "hgraca/some-project",
  "type": "project",
  "require": {
    "hgraca/composer-system-requirements-plugin": "^1.0"
  },
  "config": {
    "allow-plugins": {
      "hgraca/composer-system-requirements-plugin": true
    }
  }
}

Configure the requirements

At the moment of this writing, there is only one built in requirement, bash, which is validated by the class in src/Package/RequirementValidator/BashRequirementValidator.php.

If/when more requirements validators are added, you can find them in the same location.

The system requirements can be configured as:

{
  "name": "hgraca/dummy-shell-project-1",
  "type": "project",
  "extra": {
    "hgraca/composer-system-requirements-plugin": {
      "require": {
        "bash": "^5.1"
      }
    }
  }
}

Create your own validators

Your validators need to implement the interface \Hgraca\ComposerSystemRequirementsPlugin\Package\RequirementValidator\RequirementValidatorInterface.

For an example, see src/Package/RequirementValidator/BashRequirementValidator.php.

Add your custom requirements validators

{
  "name": "hgraca/dummy-shell-project-1",
  "type": "project",
  "extra": {
    "hgraca/composer-system-requirements-plugin": {
      "require": {
        "bash": "^5.1"
      },
      "validators": [
        "MyVendor\\MyProject\\MyValidatorClass"
      ]
    }
  }
}

A working example

For a working example, please check tests/PluginTestPlayground.

Feel free to run any of the following:

export COMPOSER="composer_with_successful_root_requirement-run_on_shell.json" && composer -d tests/PluginTestPlayground/TestProject install
export COMPOSER="composer_with_failed_root_requirement-run_on_shell.json" && composer -d tests/PluginTestPlayground/TestProject install

How to run

Using local PHP (8.2):

  • Install the dependencies with composer install;
  • The tests can be run with composer test;
  • To list all custom scripts run composer run-script --list.

Using Docker:

  • Change PHP and xdebug configs in ./build;
  • Install the dependencies with docker compose -f ./build/docker-compose.yaml run app composer install;
  • The tests can be run with composer docker-test;
  • To list all custom scripts run docker compose -f ./build/docker-compose.yaml run app composer run-script --list.

Other commands

  • composer git-bundle: create a git bundle
  • git clone -b main composer-system-requirements-plugin.gitbundle composer-system-requirements-plugin: recreate the repository from the git bundle

Author

Herberto Graca

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-06