Skip to content

2 Getting Started

DigiLive edited this page Dec 16, 2020 · 3 revisions

Installation

The preferred method is to install the library with Composer.

composer require digilive/git-changelog: ^1

(Choose a version constraint which suits your needs.)

Alternatively you can download the latest release from Github.

Instantiating

Using a custom renderer

Instantiating the library's generator, will provide you all necessary properties and methods to parse the commit data of your repository. However, the generator on its own, won't render anything.

Invoke method GitChangelog::fetchCommitData($force = false) to fetch an array of commit data which can be used to create your own output.

Your created output can be provided to the library by setting property GitChangelog::$baseContent.

Alternatively you can create you own renderer class by extending GitChangelog and implementing RendererInterface.
E.g. class myRenderer extends GitChangelog implements RendererInterface

This way the library can be instantiated as described at this chapter.

Using an included renderer

Instantiate the library by instantiating a renderer directly. The renderer extends the generator and therefore include all necessary properties and methods.

Additionally, the renderer provides you a method build() and several new options.
Visit the Public Methods to learn about the build() method.
Visit the Options page to learn about the additional options.

Minimal Example Use

<?php

use DigiLive\GitChangelog\Renderers\MarkDown;
 
// Use composer's auto loader.
$requiredFile = 'Path/To/vendor/autoload.php';

// Or include the library manually.
// $requiredFile = 'Path/To/MarkDown.php';

require_once $requiredFile;

// Instantiate the library's renderer.
$changelog = new MarkDown();
// Build and save the changelog with all defaults.
$changelog->build();
$changelog->save('CHANGELOG.md');
Clone this wiki locally