ixnode / php-public-holiday
This PHP package automatically generates holidays for a given year, considering both federal states and the country. It provides an easy-to-use interface to retrieve public holidays based on specific regions, ensuring accurate and up-to-date holiday information for all supported areas.
Requires
- php: ^8.2
- ext-calendar: *
- adhocore/cli: ^v1.0.0
- ixnode/php-timezone: ^0.1.25
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- ixnode/bash-version-manager: ^0.1.3
- jetbrains/phpstorm-attributes: ^1.0
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
- povils/phpmnd: ^3.0
- rector/rector: ^0.15.1
README
This PHP package automatically generates holidays for a given year, considering both federal states and the country. It provides an easy-to-use interface to retrieve public holidays based on specific regions, ensuring accurate and up-to-date holiday information for all supported areas. Movable public holidays such as Easter Monday are calculated automatically using the PHP function
easter_date()
. Static public holidays are permanently stored.
1. Usage
use Ixnode\PhpPublicHoliday\PublicHoliday;
1.1 Get the public holidays of Germany from the state of Saxony
$year = 2024; $country = 'DE'; $state = 'SN'; $locale = 'de'; $holiday = new PublicHoliday(year: $year, countryCode: $country, stateCode: $state, localeCode: $locale); print_r($holiday->getHolidays()); // (array) [Ixnode\PhpPublicHoliday\PublicHolidayItem Object, ...] // - (DateTimeImmutable) ->getDate() // - (string) ->getName()
2. Supported countries
3. Supported languages
4. Installation
composer require ixnode/php-public-holiday
vendor/bin/php-public-holiday -V
php-public-holiday 1.0.0 (2024-11-23 15:08:05) - Björn Hempel <bjoern@hempel.li>
5. Command line tool
Used to quickly check the public holidays.
development mode:
bin/console ph DE SN --year=2024
or within your composer project:
vendor/bin/php-public-holiday ph DE SN --year=2024
Year: 2024 Country: DE (Deutschland) State: SN (Sachsen) Locale: de (Deutsch) - 2024-01-01: Neujahr - 2024-03-29: Karfreitag - 2024-03-31: Ostersonntag - 2024-04-01: Ostermontag - 2024-05-01: Tag der Arbeit - 2024-05-09: Christi Himmelfahrt - 2024-05-19: Pfingstsonntag - 2024-05-20: Pfingstmontag - 2024-05-30: Fronleichnam - 2024-10-03: Tag der deutschen Einheit - 2024-10-31: Reformationstag - 2024-11-20: Buß- und Bettag - 2024-12-25: Erster Weihnachtsfeiertag - 2024-12-26: Zweiter Weihnachtsfeiertag
Output locales (--locale
)
Available options:
cz
de
(default)en
es
fr
hr
it
pl
sv
vendor/bin/php-public-holiday ph DE SN --year=2025 --locale=en --format=text
Year: 2025 Country: DE (Germany) State: SN (Saxony) Locale: en (English) - 2025-01-01: New Year - 2025-04-18: Good Friday - 2025-04-20: Easter Sunday - 2025-04-21: Easter Monday - 2025-05-01: Labour Day - 2025-05-29: Feast of the Ascension - 2025-06-08: Whit Sunday - 2025-06-09: Whit Monday - 2025-06-19: Feast of Corpus Christi - 2025-10-03: German Unity Day - 2025-10-31: Reformation Day - 2025-11-19: Buß- und Bettag - 2025-12-25: Christmas Day - 2025-12-26: Boxing Day
vendor/bin/php-public-holiday ph AT K --year=2025 --locale=sv --format=text
Year: 2025 Country: AT (Österrike) State: K (Kärnten) Locale: sv (Svenska) - 2025-01-01: Nyår (39 days) - 2025-01-06: Tre vise männen (44 days) - 2025-04-20: Påskdagen (147 days) - 2025-04-21: Annandag påsk (148 days) - 2025-05-01: Bankdagar (159 days) - 2025-05-29: Kristi himmelsfärdsdag (186 days) - 2025-06-08: Pingst (196 days) - 2025-06-09: Annandag pingst (197 days) - 2025-06-19: Corpus Christi (207 days) - 2025-08-15: Jungfru Marie himmelsfärd (265 days) - 2025-10-26: Nationaldag (337 days) - 2025-11-01: Alla helgons dag (343 days) - 2025-12-08: Obefläckade avlelsen (380 days) - 2025-12-25: Jul (397 days) - 2025-12-26: Stefani dag (398 days)
Output formats (--format
)
Available options:
text
(default)json
csv
JSON
vendor/bin/php-public-holiday ph DE SN --year=2025 --format=json
{ "country": "DE", "state": "SN", "year": 2025, "locale": "de", "holidays": [ { "date": "2025-01-01", "name": "Neujahr" }, ... ] }
CSV
vendor/bin/php-public-holiday ph DE SN --year=2025 --format=csv
date;"public holiday"
2025-01-01;Neujahr
2025-04-18;Karfreitag
...
6. Library development
git clone git@github.com:ixnode/php-public-holiday.git && cd php-public-holiday
composer install
composer test
7. License
This library is licensed under the MIT License - see the LICENSE file for details.
8. Author
- Björn Hempel bjoern@hempel.li
- https://www.hempel.li/