Skip to content

Composer plugin for writing the composer hash to a file on install/update.

Notifications You must be signed in to change notification settings

aaemnnosttv/composer-hash-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Composer Hash Plugin

Tests

A Composer plugin for writing the Composer hash to a file on install/update to verify parity with VCS.

Overview

This package aims to solve the problem of your installed dependencies getting out of sync with those defined by your lock file. As such, it is intended to be used in projects where the composer.lock file is under version control.

Once installed, the plugin will write the current content-hash from your composer.lock file to a new composer.hash file after each composer install or update. This is the only thing it will do automatically.

This new file is intended to be excluded from version control. The hashes can then be verified, but that has to be done (semi) manually. See below.

API

Since the hash file is written automatically, the API exposes methods for verifying the hashes.

CLI

$ composer hash-verify

If hash verification fails, the command provides additional feedback and exits with a non-zero exit code.

PHP

The plugin exposes a ComposerHash\Hash::verify($path) method where $path is the absolute path to the project's root directory containing composer.json. This function checks that the composer.hash matches the corresponding hash in the composer.lock file (if it doesn't, a HashMismatchException is thrown. Other exceptions are thrown if called with an invalid path or if Composer files are unreadable.

Installation

$ composer require aaemnnosttv/composer-hash-plugin

Note: the generated composer.hash file is intended to be ignored by source control so be sure to update your .gitignore or other VCS equivalent accordingly.

About

Composer plugin for writing the composer hash to a file on install/update.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published