topaz / holidays
获取谷歌日历的公共假期
v1.01
2021-08-16 23:32 UTC
Requires
- ext-json: *
- symfony/dotenv: ^5.3
Requires (Dev)
- phpunit/phpunit: ^9
- roave/security-advisories: dev-latest
README
此包使用谷歌日历API来获取公共假期。数据总是包含三年的数据;去年、今年和明年。
如何使用
composer require topaz/holidays- 在谷歌控制台注册API密钥 https://phpcoder.tech/get-list-of-holidays-using-google-calendar-api/
- 将您的密钥 [GOOGLE_CALENDAR_API_KEY] 添加到您的
.env文件中 - 导入
LazHoliday\PublicHoliday
示例用法
<?php require_once 'vendor/autoload.php'; use LazHoliday\PublicHoliday; try { $holiday = new PublicHoliday(); var_dump($holiday->fetch('usa')->getDataForYear(2021)); } catch (Exception $e) { var_dump($e->getMessage()); }
可用方法
- fetch(string $country): PublicHoliday - 当传入国家时获取所有日历数据
- getData(): array - 返回三年日历数据的一些信息
- getItems(): array - 返回三年的日历数据
- getDataForYear(int $year): array - 通过年份过滤假日数据
- getSummary(): array - 获取假日的总结和日期
国家代码
https://gist.github.com/seanblanchfield/4df78d73c85b149133615c7953894076
许可证
本项目使用MIT许可证,欢迎贡献。