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
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.
1. Usage
use Ixnode\PhpPublicHoliday\Holiday;
1.1 Get the public holidays of Germany from the state of Saxony
$year = 2024; $country = \Ixnode\PhpPublicHoliday\Configuration\Country::DE; $state = \Ixnode\PhpPublicHoliday\Configuration\Country\CountryDe::STATE_SN; $holiday = new Holiday($year, $country, $state); print_r($holiday->getHolidays()); // (array) [Ixnode\PhpPublicHoliday\HolidayItem Object, ...] // - (DateTimeImmutable) ->getDate() // - (string) ->getName()
2. Installation
composer require ixnode/php-public-holiday
vendor/bin/php-public-holiday -V
php-public-holiday 0.1.0 (2024-07-18 20:33:58) - Björn Hempel <bjoern@hempel.li>
3. Command line tool
Used to quickly check the public holidays.
bin/console ph DE SN 2024
or within your composer project:
vendor/bin/php-public-holiday ph DE SN 2024
Country: DE State: SN Year: 2024 - 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-10-03: Tag der deutschen Einheit - 2024-12-25: Erster Weihnachtsfeiertag - 2024-12-26: Zweiter Weihnachtsfeiertag
4. Library development
git clone git@github.com:ixnode/php-public-holiday.git && cd php-public-holiday
composer install
composer test
5. License
This library is licensed under the MIT License - see the LICENSE file for details.
6. Author
- Björn Hempel bjoern@hempel.li
- https://www.hempel.li/