PHP code example of vdhicts / keepachangelog-parser

1. Go to this page and download the library: Download vdhicts/keepachangelog-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/ */

    

vdhicts / keepachangelog-parser example snippets


$content = file_get_contents('CHANGELOG.md');

$parser = new \Vdhicts\KeepAChangelog\Parser();
$changelog = $parser->parse($content);

$content = file_get_contents('CHANGELOG.md');

$parser = new \Vdhicts\KeepAChangelog\Parser();
$changelog = $parser
    ->setDateFormat('Y-m-d H:i:s')
    ->parse($content);

// Get the description of the changelog, which returns an array of lines
$descriptionHtml = implode('<br>', $changelog->getDescription());

// Determine if the changelog has any releases
$changelog->hasReleases();

// Get the unreleased section
$unreleased = $changelog->getUnreleased();

// Get the latest release
$latestRelease = $changelog->getLatestRelease();

// Determine if the current one is the unreleased section
$isUnreleased = $release->isUnreleased();

// Get the version for the release
$version = $release->getVersion();

// Get the release date, will be null when not released or a date isn't provided
$data = $release->getReleasedAt();

// Get the tag reference, usually something like https://github.com/vdhicts/keepachangelog-parser/compare/v0.0.1...v1.0.0
$tagReference = $release->getTagReference();

// Get a specific section of the release
$added = $release->getSection(Section::ADDED);

// Get the collection of sections for the release
$sections = $release->getSections();

$type = $section->getType();
$entries = $section->getEntries();

$entriesHtml = implode('<br>', $entries);