Skip to content
> Elliot J. Reed

Packages and Libraries

Some packages and libraries I maintain, more information can be found on my GitHub profile.

Have I Been Pwned PHP

A PHP package for accessing the HIBP API, to check for leaked email addresses and passwords in a secure manner. It can be installed via Composer by running composer require elliotjreed/haveibeenpwned.

Documentation can be found in the GitHub repository, but it's as simple as providing your HIBP API key and a Guzzle client and using as follows:

$guzzle = new \GuzzleHttp\Client();
$apiKey = 'HIBP-API-KEY';

/**
   Return a count of all breaches for a specified email address (int)
*/
$count = (new \ElliotJReed\HaveIBeenPwned\BreachedAccount($guzzle, $apiKey))->count('[email protected]');

/**
   Return details of all breaches for a specified email address
   (ElliotJReed\HaveIBeenPwned\Entity\Breach[])
*/
$breaches = (new \ElliotJReed\HaveIBeenPwned\BreachedAccount($guzzle, $apiKey))->breaches('[email protected]');

/**
   Return the names of the breaches for a specified email address (string[])
*/
$breachNames = (new \ElliotJReed\HaveIBeenPwned\BreachedAccount($guzzle, $apiKey))->breachNames('[email protected]');

/**
   Return a count of exposed passwords for a specified password (int).
   This API call DOES NOT send the actual password to the Have I Been Pwned API.
*/
$passwordCount = (new \ElliotJReed\HaveIBeenPwned\Password($guzzle, $apiKey))->count('password123');

Disposable Email Filter / Checker

A PHP package for checking whether a provided email address is likely to be a temporary / disposable one. It gets automatically updated frequently too, so that's nice. It can be installed via Composer by running composer require elliotjreed/disposable-emails-filter.

Documentation can be found in the GitHub repository, but basically you just provide an email address and it will return true if it is likely to be a temporary one:

$guzzle = new \GuzzleHttp\Client();
use ElliotJReed\DisposableEmail\Email;

if ((new Email())->isDisposable('[email protected]')) {
    echo 'This is a disposable / temporary email address';
}

Database Anonymiser

A PHP package for anonymising database (MySQL, MariaDB, Postgres, SQLite) data. It can be used as part of an automated process to have an up-to-date development database with fake data.

Documentation can be found in the GitHub repository.

Cloudflare Cache Purge PHP

A PHP package for checking whether a provided email address is likely to be a temporary / disposable one. It gets automatically updated frequently too, so that's nice. It can be installed via Composer by running composer require elliotjreed/cloudflare-cache-purge.

Documentation can be found in the GitHub repository, but essentially you just provide yur Cloudflare API token and a Zone ID (i.e. a domain) and it will purge the cache for the files / URLs provided:

use ElliotJReed\Cache;
use ElliotJReed\Exception\Cloudflare;
use GuzzleHttp\Client;

$urls = [
    'https://www.example.com.com/image1.png',
    'https://www.example.com.com/image2.png'
];

try {
    $cacheResponse = (new Cache(new Client(), 'SECRET CLOUDFLARE API TOKEN'))
        ->purgeFiles('zone-id-from-api-or-dashboard', $urls);

    foreach ($cacheResponse->getResults() as $result) {
        echo 'Cache Purge Response ID: ' . $result->getId() . \PHP_EOL;
    }
} catch (Cloudflare $exception) {
    echo $exception->getMessage() . \PHP_EOL;
    echo $exception->getPrevious()->getMessage() . \PHP_EOL;
}