PHP code example of louzet / composer-lock-file-parser

1. Go to this page and download the library: Download louzet/composer-lock-file-parser 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/ */

    

louzet / composer-lock-file-parser example snippets



declare(strict_types=1);

FileParser;

$parser = FileParser::parse('resources/composer.lock');

if ($parser->nameExists('bower-asset/bootstrap')) {
    // do some stuff
    print_r($parser->getByName('bower-asset/bootstrap'));
}

 php


declare(strict_types=1);

arser;

$parser = FileParser::parse('path/to/composer.lock');

markdown


print_r($parser->getPackages());

array (size=10)
  'bower-asset/bootstrap' => 
    object(ComposerLockParser\Package\Package)[2]
      private 'name' => string 'bower-asset/bootstrap' (length=21)
      private 'version' => string 'v3.2.0' (length=6)
      private 'source' => 
        array (size=3)
          'type' => string 'git' (length=3)
          'url' => string 'https://github.com/twbs/bootstrap.git' (length=37)
          'reference' => string 'c068162161154a4b85110ea1e7dd3d7897ce2b72' (length=40)
      private 'dist' => 
        array (size=4)
          'type' => string 'zip' (length=3)
          'url' => string 'https://api.github.com/repos/twbs/bootstrap/zipball/c068162161154a4b85110ea1e7dd3d7897ce2b72' (length=92)
          'reference' => string 'c068162161154a4b85110ea1e7dd3d7897ce2b72' (length=40)
          'shasum' => string '' (length=0)
      private 'gth=97)
      private 'homepage' => string '' (length=0)
      private 'keywords' => 
        array (size=8)
          0 => string 'css' (length=3)
          1 => string 'framework' (length=9)
          2 => string 'front-end' (length=9)
          3 => string 'js' (length=2)
          4 => string 'less' (length=4)
          5 => string 'mobile-first' (length=12)
          6 => string 'responsive' (length=10)
          7 => string 'web' (length=3)
      private 'time' => null
  'bower-asset/jquery' => 
    object(ComposerLockParser\Package\Package)[4] ...