承接 publishpress/version-loader-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

publishpress/version-loader-generator

最新稳定版本:1.2.4

Composer 安装命令:

composer require publishpress/version-loader-generator

包简介

Composer script to generate the version loader files for libraries on PubilshPress

README 文档

README

Script to auto generate scripts and test for libraries on PublishPress.

The script will generate three files in the library:

  • lib/Versions.php
  • lib/include.php
  • tests/wpunit/VersionsCest.php

How to use

This library should be included in the target library as dev requirement:

composer require --dev publishpress/version-loader-generator

Once installed it will be available in the vendor/bin folder.

Its requires a few settings in the composer.json file to correctly generate the files:

{
  "extra": {
    "generator": {
      "lib-class-test": "interface_exists('PublishPress\\Psr\\Container\\ContainerInterface')",
      "action-initialize-priority": "-190",
      "action-register-priority": "-200",
      "version": "1.0.0"
    }
  }
}
  • lib-class-test: this is a fragment of PHP code that will check if the target library is loaded or not.
  • action-register-priority: a negative integer that will be used as the priority of the plugins_loaded action for registering the library. The registration should always be done before the initialization.
  • action-intialize-priority: a negative integer that will be used as the priority of the plugins_loaded action for initializing the library. The initialization should always be done before the plugin using the library is initialized.

We advise the plugins using the prefixed libraries to use the plugins_loaded action with a priority of -20 or higher to initialize the plugin instead of initializing it on run time.

Add a composer script to run the generator on every update/install. On the following example we are using Strauss also, to prefix the respective library:

{
  "scripts": {
    "strauss": [
      "vendor/bin/strauss"
    ],
    "generate-files": "vendor/bin/version-loader-generator",
    "post-install-cmd": [
      "@strauss",
      "@generate-files"
    ],
    "post-update-cmd": [
      "@strauss",
      "@generate-files"
    ]
  }
}

How to test this script

vendor/bin/codecept run unit

How to test target libraries

Make sure Codeception is properly configured in the target library, for running WPUnit tests.

Add the following composer script to the composer.json file:

{
  "scripts": {
    "test": "vendor/bin/codecept run wpunit"
  }
}

Then you can just run:

composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-04-20