PHPackages                             midnite81/bank-holidays - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. midnite81/bank-holidays

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

midnite81/bank-holidays
=======================

A library to get UK bank holidays

v3.0.0(4y ago)312.9k↓26.4%MITPHPPHP &gt;=7.1

Since Apr 18Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/midnite81/bank-holidays)[ Packagist](https://packagist.org/packages/midnite81/bank-holidays)[ RSS](/packages/midnite81-bank-holidays/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (13)Versions (10)Used By (0)

UK Bank Holidays [![Latest Stable Version](https://camo.githubusercontent.com/6ea003014002fd283ccf8458f5a51b57691a6e0af235ed21fb45098caad8127f/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f62616e6b2d686f6c69646179732f76657273696f6e)](https://packagist.org/packages/midnite81/bank-holidays) [![Total Downloads](https://camo.githubusercontent.com/bd1ee39e6efbab887aabfd27cea6224cd5ea83b63376050b1c52b14e4247c9c0/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f62616e6b2d686f6c69646179732f646f776e6c6f616473)](https://packagist.org/packages/midnite81/bank-holidays) [![Latest Unstable Version](https://camo.githubusercontent.com/cb64d28a8b72a4f37c03dbf7679468da49a07743fb27443640e9de1c33fc65b9/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f62616e6b2d686f6c69646179732f762f756e737461626c65)](https://packagist.org/packages/midnite81/bank-holidays) [![License](https://camo.githubusercontent.com/6a149a94ac381d017eb81ac6601a5153337e05f7110d23f895a08c8fdc449efa/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f62616e6b2d686f6c69646179732f6c6963656e73652e737667)](https://packagist.org/packages/midnite81/bank-holidays) [![Build](https://camo.githubusercontent.com/0d7f2ecbe5207a96fe69c4f0eec6509d229c4777a9a8f6945891dbd04cafd60c/68747470733a2f2f7472617669732d63692e6f72672f6d69646e69746538312f62616e6b2d686f6c69646179732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/midnite81/bank-holidays) [![Coverage Status](https://camo.githubusercontent.com/34d789b0fcd217d1cd50c603814927f657949ed690ebe9d30df716166e3dea83/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d69646e69746538312f62616e6b2d686f6c69646179732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/midnite81/bank-holidays?branch=master)
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#uk-bank-holidays------)

This package integrates with the UK Government's Bank Holiday Json response. It has been principally been designed for use with laravel, but is framework agnostic under the hood. **This package requires PHP 7.1 or greater.**

Installation
------------

[](#installation)

```
composer require midnite81/bank-holidays

```

If you are using laravel 5.4 or less, you will need to register the Bank Holiday service provider. If you are using 5.5 or greater than the package should be auto discovered.

```
 'providers' => [
      ...
      \Midnite81\BankHolidays\BankHolidayServiceProvider::class,
      ...
  ];

```

You will need to publish the configuration file. To do this, please run

```
php artisan vendor:publish provider="Midnite81\BankHolidays\BankHolidayServiceProvider"

```

Limitation
----------

[](#limitation)

The UK Government provides the bank holiday json feed, this at the time of writing only includes the years between 2015 and 2021.

Versions
--------

[](#versions)

VersionDescriptionv2.0 ✅Php 7.1+v1.0Php 5.5.9+ DepreciatedView [changelog](CHANGELOG.md) for changes.

Http standards
--------------

[](#http-standards)

To adhere to better standards, this package uses the popular and powerful PHP-HTTP library to make HTTP requests. This allows you, should you wish, to use your own HTTP Client instead of the default provided with this package. For more information on PHP-HTTP, please visit [php-http.org](http://docs.php-http.org/en/latest/).

Laravel usage example
---------------------

[](#laravel-usage-example)

**Checking a date to see if it's a bank holiday**

```
use Midnite81\BankHolidays\Contracts\IBankHoliday;

public function myFunction(IBankHoliday $bankHoliday)
{
    $bankHolidayEntity = $bankHoliday->bankHolidayDetail(
        \Carbon\Carbon::create(2020, 01, 01),
        \Midnite81\BankHolidays\Enums\Territory::ENGLAND_AND_WALES
    );

    // if the date provided is a bank holiday a BankHolidayEntity is returned
    // otherwise it returns null. If the entity is returned you can access the entity properties below.
```

[See entity properties](#bank-holiday-entity)

```

    if ($bankHoliday->isBankHoliday(
        \Carbon\Carbon::create(2020, 01, 01),
        \Midnite81\BankHolidays\Enums\Territory::ENGLAND_AND_WALES
        )) {
        // if it is a bank holiday do this ...
    }
}
```

**Get all bank holiday dates**

```
use Midnite81\BankHolidays\Contracts\IBankHoliday;

public function myFunction(IBankHoliday $bankHoliday)
{
    $bankHolidays = $bankHoliday->getAll(\Midnite81\BankHolidays\Enums\Territory::ENGLAND_AND_WALES);

    foreach($bankHolidays as $bankHoliday) {
        echo $bankHoliday->title . "\n";
    }
}
```

**Check data range**

The UK government supplies the data which is used in this package and is subject to date range limitations. Due to these limitations, this package provides two methods for you to ascertain the minimum and maximum dates in the data are available for you to check against.

```
use Midnite81\BankHolidays\Contracts\IBankHoliday;

public function myFunction(IBankHoliday $bankHoliday)
{
    $minimumDate = $bankHoliday->getMinDate(\Midnite81\BankHolidays\Enums\Territory::ENGLAND_AND_WALES);
    $maximumDate = $bankHoliday->getMaxDate(\Midnite81\BankHolidays\Enums\Territory::ENGLAND_AND_WALES);
}
```

Usage without laravel
---------------------

[](#usage-without-laravel)

```
public function someFunction()
{
    $config = [
       'cache-duration' => 60 * 60 * 24,
       'bank-holiday-url' => 'https://www.gov.uk/bank-holidays.json',
       'cache-key' => 'midnite81-bank-holidays',
       'cache-class' => YourCacheClass::class, // you will need to create a cache class
       'filesystem-class' => \Midnite81\BankHolidays\Drivers\PhpFileSystem::class,
       'http-client' => null,
       'failure-backup' => true,
       'request-factory' => null
    ];

    $cache = new YourCacheClass(); // this must implement \Midnite81\BankHolidays\Contracts\Drivers\ICache
    $client = new \Midnite81\BankHolidays\Services\Client(null, null, $config);
    $bankHoliday = new \Midnite81\BankHolidays\BankHoliday($client, $cache, $config);

    // Once you have $bankHoliday instantiated you can use the following methods

    $bankHoliday->getAll(int $territory);
    $bankHoliday->bankHolidayDetail(Carbon $date, int $territory);

    // for territory please use the constants in `Midnite81\BankHolidays\Enums\Territory`
}
```

Bank Holiday Entity
-------------------

[](#bank-holiday-entity)

The bank holiday entity has the following properties.

**title** - the title of the holiday - e.g. New Year's Day
**date** - a carbon instance of the bank holiday date
**notes** - any notes about the bank holiday
**bunting** - presumably whether bunting is displayed
**territory** - the territory the bank holiday applies to

Territories
-----------

[](#territories)

The following territories are available

```
Midnite81\BankHolidays\Enums\Territory::ENGLAND_AND_WALES; // England and Wales
Midnite81\BankHolidays\Enums\Territory::SCOTLAND; // Scotland
Midnite81\BankHolidays\Enums\Territory::NORTHERN_IRELAND; // Northern Ireland
Midnite81\BankHolidays\Enums\Territory::ALL; // All territories (e.g. England, Wales, Scotland and Northern Ireland)
```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance56

Moderate activity, may be stable

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~129 days

Recently: every ~193 days

Total

7

Last Release

1491d ago

Major Versions

v1.0.0 → v2.0.02020-04-21

v2.0.2 → v3.0.02022-06-04

PHP version history (2 changes)v1.x-devPHP &gt;=5.5.9

v2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/254850?v=4)[Simon Rogers](/maintainers/midnite81)[@midnite81](https://github.com/midnite81)

---

Top Contributors

[![midnite81](https://avatars.githubusercontent.com/u/254850?v=4)](https://github.com/midnite81 "midnite81 (43 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/midnite81-bank-holidays/health.svg)

```
[![Health](https://phpackages.com/badges/midnite81-bank-holidays/health.svg)](https://phpackages.com/packages/midnite81-bank-holidays)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[toin0u/geocoder-laravel

Geocoder Service Provider for Laravel

7615.4M17](/packages/toin0u-geocoder-laravel)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[illuminate/support

The Illuminate Support package.

630113.0M41.4k](/packages/illuminate-support)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
