PHP code example of anexia / composer-tools
1. Go to this page and download the library: Download anexia/composer-tools library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
anexia / composer-tools example snippets
// 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
}
}