anexia/composer-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

anexia/composer-tools

Composer 安装命令:

composer require anexia/composer-tools

包简介

fetch version and licence information of installed composer packages from packagist

README 文档

README

A composer package used to fetch version numbers and licence information from all installed composer packages (included in composer.json) and their latest version number registered on packagist.

Installation and configuration

Install the module via composer, therefore adapt the require part of your composer.json:

"require": {
    "anexia/composer-tools": "~1.4"
}

Now run

composer update [-o]

to add the packages source code to your /vendor directory.

Usage

The package adds the ComposerPackagistTrait to your application. It can be added to a class (e.g. a controller) as any trait and then its methods can be accessed directly.

The trait provides the two methods

  • getLatestFrameworkVersion($package) returns the latest registered packagist version of a given package
  • getComposerPackageData() returns an array of all installed composer packages (found via composer.json) including their currently installed version and their latest registered packagist version

A VersionMonitoringController for a Laravel application might look like this example:

// inside VersionMonitoringController.php

use Anexia\ComposerTools\Traits\ComposerPackagistTrait

class VersionMonitoringController
{
    use ComposerPackagistTrait;
    
    public function index()
    {
        $runtime = [
            'platform' => 'php',
            'platform_version' => phpversion(),
            'framework' => 'laravel',
            'framework_installed_version' => $this->getCurrentFrameworkVersion(),
            'framework_newest_version' => $this->getLatestPackageVersion('laravel/framework')
        ];
        
        $modules = $this->getComposerPackageData();
        
        $response = response()->json([
            'runtime' => $runtime,
            'modules' => $modules
        ]);
    }
    
    /**
     * Get version number of the currently installed framework package
     *
     * @return string
     */    
    public function getCurrentFrameworkVersion()
    {
        // do something to return the currently used framework version,
        // depending on the framwork used within the application
    }
}

A possible response of the example controller action might look like this:

200 OK

{
   "runtime":{
      "platform":"php",
      "platform_version":"7.0.19",
      "framework":"laravel",
      "framework_installed_version":"5.4.28",
      "framework_newest_version":"5.4.28"
   },
   "modules":[
      {
         "name":"package-1",
         "installed_version":"3.1.10",
         "installed_version_licences":[
            "BSD-2-Clause"
         ],
         "newest_version":"3.3.2",
         "newest_version_licences":[
            "BSD-3-Clause"
         ]
      },
      {
         "name":"package-2",
         "installed_version":"1.4",
         "installed_version_licences":[
            "MIT"
         ],
         "newest_version":"1.4",
         "newest_version_licences":[
            "MIT"
         ]
      },
      ...
   ]
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固