PHPackages                             foxen/laravel-uk-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. foxen/laravel-uk-bank-holidays

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

foxen/laravel-uk-bank-holidays
==============================

Laravel package for UK bank holidays, providing easy access to official UK government bank holiday data with intelligent caching and territorial support.

v1.1.0(1mo ago)02[2 PRs](https://github.com/foxen-digital/laravel-uk-bank-holidays/pulls)MITPHPPHP ^8.4CI passing

Since Mar 3Pushed 1mo agoCompare

[ Source](https://github.com/foxen-digital/laravel-uk-bank-holidays)[ Packagist](https://packagist.org/packages/foxen/laravel-uk-bank-holidays)[ Docs](https://github.com/foxen/laravel-uk-bank-holidays)[ GitHub Sponsors](https://github.com/foxen)[ RSS](/packages/foxen-laravel-uk-bank-holidays/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (24)Versions (5)Used By (0)

Laravel UK Bank Holidays
========================

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

A Laravel package providing easy access to official UK bank holiday data from GOV.UK with intelligent caching and territorial support.

[![Latest Version on Packagist](https://camo.githubusercontent.com/32538eb169dc718e47740bba72639d5e0b8a5dc8eb6ae65c4c471fcde4da25a0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f78656e2f6c61726176656c2d756b2d62616e6b2d686f6c69646179732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/foxen/laravel-uk-bank-holidays)[![GitHub Tests Action Status](https://camo.githubusercontent.com/cdff2c4bf5976b1932d2033a66819fa2ca1adb7ad72acaf1ebf8ca0c8b9e0e1f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f666f78656e2f6c61726176656c2d756b2d62616e6b2d686f6c69646179732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/foxen/laravel-uk-bank-holidays/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/a389b1dc1a0da3900cd715796ffc6703402a3cb3ce28e16d18bb709a41b82a8d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666f78656e2f6c61726176656c2d756b2d62616e6b2d686f6c69646179732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/foxen/laravel-uk-bank-holidays)

Features
--------

[](#features)

- Fetches data directly from the official [GOV.UK bank holidays API](https://www.gov.uk/bank-holidays.json)
- Intelligent caching with configurable duration
- Support for all UK territories: England &amp; Wales, Scotland, and Northern Ireland
- Clean, Laravel-native API with Facade support
- Blade directive for conditional rendering
- Carbon integration for date handling

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

[](#installation)

Install the package via Composer:

```
composer require foxen/laravel-uk-bank-holidays
```

The package will auto-register its service provider and facade.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag="uk-bank-holidays-config"
```

This will create a `config/uk-bank-holidays.php` file with the following options:

```
return [
    // Default territory when none is specified
    'default_territory' => env('UK_BANK_HOLIDAY_TERRITORY', 'england-and-wales'),

    // Cache duration in seconds (default: 24 hours)
    'cache_duration' => env('UK_BANK_HOLIDAY_CACHE', 86400),

    // Cache key prefix
    'cache_key_prefix' => 'uk-bank-holidays',

    // GOV.UK API URL (override for testing)
    'api_url' => env('UK_BANK_HOLIDAY_API', 'https://www.gov.uk/bank-holidays.json'),
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Foxen\BankHolidays\Facades\BankHolidays;

// Check if a date is a bank holiday
if (BankHolidays::isHoliday('2026-01-01')) {
    echo "It's a bank holiday!";
}

// Check using a Carbon instance
if (BankHolidays::isHoliday(now())) {
    echo "No deliveries today!";
}
```

### Available Territories

[](#available-territories)

- `england-and-wales` (default)
- `scotland`
- `northern-ireland`

```
// Check a specific territory
BankHolidays::isHoliday('2026-11-30', 'scotland'); // St Andrew's Day - Scotland only
```

### Get All Holidays for a Year

[](#get-all-holidays-for-a-year)

```
$holidays = BankHolidays::forYear(2026);

foreach ($holidays as $holiday) {
    echo $holiday->title;   // "New Year's Day"
    echo $holiday->date;    // "2026-01-01"
    echo $holiday->notes;   // Additional notes (often empty)
    echo $holiday->bunting; // true/false (decorative flag)
}

// For a specific territory
$scottishHolidays = BankHolidays::forYear(2026, 'scotland');
```

### Get the Next Bank Holiday

[](#get-the-next-bank-holiday)

```
// Next holiday from today
$next = BankHolidays::next();
echo $next->title; // "Good Friday"

// Next holiday from a specific date
$next = BankHolidays::next('2026-12-20');
echo $next->title; // "Christmas Day"

// Returns null if no future holidays in data
$next = BankHolidays::next('2030-01-01');
```

### Get Holidays Within a Date Range

[](#get-holidays-within-a-date-range)

```
// Get all holidays in Q1 2026
$holidays = BankHolidays::between('2026-01-01', '2026-03-31');

// Returns empty collection if no holidays in range
$holidays = BankHolidays::between('2026-02-01', '2026-02-14');
```

### Get Holiday Details for a Specific Date

[](#get-holiday-details-for-a-specific-date)

```
$holiday = BankHolidays::get('2026-12-25');

if ($holiday) {
    echo $holiday->title; // "Christmas Day"
}

// Returns null if not a holiday
$holiday = BankHolidays::get('2026-01-02'); // null
```

### Clear Cache

[](#clear-cache)

```
// Clear all cached data
BankHolidays::clearCache();
```

Blade Directive
---------------

[](#blade-directive)

Use the `@bankholiday` directive in your Blade templates:

```
{{-- Check if today is a bank holiday --}}
@bankholiday
    Note: Today is a bank holiday - no deliveries!
@endbankholiday

{{-- Check a specific date --}}
@bankholiday('2026-01-01')
    New Year's Day - Offices closed
@else
    Normal working day
@endbankholiday

{{-- Check with territory --}}
@bankholiday('2026-11-30', 'scotland')
    St Andrew's Day - Scotland only
@endbankholiday
```

Holiday Object
--------------

[](#holiday-object)

The `Holiday` data transfer object has the following properties:

PropertyTypeDescription`title`stringName of the bank holiday`date`stringDate in Y-m-d format`notes`stringAdditional notes (often empty)`bunting`boolWhether decorative bunting is displayed`territory`stringThe territory this holiday belongs toMethods:

- `toCarbon()` - Returns a Carbon instance of the date
- `toArray()` - Converts the holiday to an array

Error Handling
--------------

[](#error-handling)

The package throws specific exceptions for invalid input:

```
use Foxen\BankHolidays\Exceptions\InvalidDateException;
use Foxen\BankHolidays\Exceptions\InvalidTerritoryException;
use Foxen\BankHolidays\Exceptions\ApiConnectionException;

try {
    BankHolidays::isHoliday('invalid-date');
} catch (InvalidDateException $e) {
    // Handle invalid date format
}

try {
    BankHolidays::forYear(2026, 'invalid-territory');
} catch (InvalidTerritoryException $e) {
    // Handle invalid territory
}
```

Testing
-------

[](#testing)

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [MrKareth](https://github.com/mrkareth)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance91

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.3% 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 ~21 days

Total

2

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/478d77e4c9a68f8d044e31c52eaee8b58d33ff77ed30bc8a1767ca92496d6cae?d=identicon)[mrdth](/maintainers/mrdth)

---

Top Contributors

[![MrKareth](https://avatars.githubusercontent.com/u/70467806?v=4)](https://github.com/MrKareth "MrKareth (13 commits)")[![mrdth](https://avatars.githubusercontent.com/u/781215?v=4)](https://github.com/mrdth "mrdth (3 commits)")

---

Tags

laravelfoxenlaravel-uk-bank-holidays

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/foxen-laravel-uk-bank-holidays/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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