2017 © Pedro Peláez
 

library composer-tools

fetch version and licence information of installed composer packages from packagist

image

anexia/composer-tools

fetch version and licence information of installed composer packages from packagist

  • Wednesday, September 27, 2017
  • by anx-abruckner
  • Repository
  • 0 Watchers
  • 1 Stars
  • 683 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 39 % Grown

The README.md

Anexia Composer Tools

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., (*1)

Installation and configuration

Install the module via composer, therefore adapt the require part of your composer.json:, (*2)

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

Now run, (*3)

composer update [-o]

to add the packages source code to your /vendor directory., (*4)

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., (*5)

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, (*6)

A VersionMonitoringController for a Laravel application might look like this example:, (*7)

// 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:, (*8)

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"
         ]
      },
      ...
   ]
}

The Versions

27/09 2017

1.2.0

1.2.0.0

fetch version and licence information of installed composer packages from packagist

  Sources   Download

MIT

The Requires

 

27/09 2017

dev-master

9999999-dev

fetch version and licence information of installed composer packages from packagist

  Sources   Download

MIT

The Requires

 

08/09 2017

1.1.0

1.1.0.0

fetch version and license information of installed composer packages from packagist

  Sources   Download

MIT

The Requires

 

29/08 2017

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires