rugaard/pollen
Composer 安装命令:
composer require rugaard/pollen
包简介
Fetch latest Pollen measurements from Astma-Allergi Denmark.
关键字:
README 文档
README
🇩🇰🤧 Pollen measurements from Astma-Allergi Denmark
Astma-Allergi Denmark does unfortunately not offer an official API for the latest pollen measurements in Denmark.
This package is (in some form) a workaround for that. It fetches the latest measurements and short-term predictions directly from Astma-Allergi Denmark's data feed and turns it into structured, typed data objects.
The returned data shows the measured pollen between 13:00 (UTC +1) (1:00 PM) yesterday and 13:00 (UTC +1) (1:00 PM) present day. Every day at 16:30 (UTC +1) (4:30 PM), at the latest, the new measurements are being published.
⚠️ Disclaimer
Since Astma-Allergi Denmark is an independent union, with a very little government funding, this package is made available under a very strict license, which prohibits any use other than personal.
If you wish to use the pollen measurements commercially, you should contact Astma-Allergi Denmark directly and support them by buying the data instead. The payment goes directly to the maintenance and further development of their Pollen measurement service.
For more info about a commercial license, visit their official website.
📖 Table of contents
- Requirements
- Installation
- Usage
- Pollen stations
- Allergens
- Level classification
- Frequently Asked Questions (FAQ)
- Donating to Astma-Allergi Denmark
- License
🖥 Requirements
- PHP 8.3 or higher
- GuzzleHTTP 7.0 or higher
📦 Installation
You can install the package via Composer, by using the following command:
composer require rugaard/pollen
Laravel
This package comes with an out-of-the-box Service Provider for the Laravel framework, which is loaded automatically via package discovery.
⚙️ Usage
First thing you need to do, is to instantiate the Pollen client:
use Rugaard\Pollen\Pollen; $pollen = new Pollen;
Once you've done that, you're ready to fetch the latest measurements.
Pollen client
The Pollen client which handles the requests to Astma-Allergi Denmark.
new Pollen(?GuzzleClientInterface $client = null);
| Parameter | Type | Default | Description |
|---|---|---|---|
$client |
\GuzzleHttp\ClientInterface |
null |
Replace the default underlying HTTP client |
Methods
Get measurements
Get the latest pollen measurements and predictions. Optionally filter by station and/or exclude allergens that are currently out of season.
get(?Station $station = null, bool $onlyInSeason = false): Collection
| Parameter | Type | Default | Description |
|---|---|---|---|
$station |
Station|null |
null |
Filter by a specific pollen station. Returns all stations when null. |
$onlyInSeason |
bool |
false |
When true, allergens that are currently out of season are excluded from the result. |
Note: The returned data shows the measured pollen between 13:00 (1:00 PM) yesterday and 13:00 (1:00 PM) present day. The measurements are updated everyday at 16:00 (4:00 PM).
Examples:
use Rugaard\Pollen\Enums\Station; use Rugaard\Pollen\Pollen; $pollen = new Pollen; # All stations. $measurements = $pollen->get(); # A specific station. $measurements = $pollen->get(station: Station::East); # A specific station, in-season allergens only. $measurements = $pollen->get(station: Station::East, onlyInSeason: true);
Return data structure
Single station
When a $station is provided, get() returns a Collection keyed by allergen code. Each value is either a Collection with measurement data, or null if the allergen is currently out of season.
$measurements = $pollen->get(station: Station::East); // Access a specific allergen. $birch = $measurements->get('birch'); // $birch is a Collection: // [ // 'date' => '2024-04-01', // measurement date // 'value' => 200, // raw grain count // 'level' => Level::High, // classified level enum // 'predictions' => Collection [ // null for spore allergens // ['date' => '2024-04-02', 'level' => Level::Moderate], // ['date' => '2024-04-03', 'level' => Level::Low], // ], // ] // Out-of-season allergens are null. $mugwort = $measurements->get('mugwort'); // null
All stations
When no $station is provided, get() returns a Collection keyed by station value ('east', 'west'), where each entry contains the station's allergen measurements as described above.
$measurements = $pollen->get(); $east = $measurements->get('east'); // Collection of allergens for Station::East $west = $measurements->get('west'); // Collection of allergens for Station::West
🏛 Pollen stations
Currently there only exist two pollen stations in Denmark.
| Enum | ID | Name | Code | Region |
|---|---|---|---|---|
Station::East |
48 | København | east |
East |
Station::West |
49 | Viborg | west |
West |
🌿 Allergens
The following allergens are supported. Spore allergens do not have predictions.
| Enum | Code | Danish name | Type |
|---|---|---|---|
Allergen::Alder |
alder |
El | Pollen |
Allergen::Hazel |
hazel |
Hassel | Pollen |
Allergen::Elm |
elm |
Elm | Pollen |
Allergen::Birch |
birch |
Birk | Pollen |
Allergen::Grass |
grass |
Græs | Pollen |
Allergen::Mugwort |
mugwort |
Bynke | Pollen |
Allergen::Alternaria |
alternaria |
Alternaria | Spore |
Allergen::Cladosporium |
cladosporium |
Cladosporium | Spore |
🖼 Icons
The assets/ folder contains a PNG icon for each allergen, named after its code.
| Icon | Allergen |
|---|---|
alder |
|
hazel |
|
elm |
|
birch |
|
grass |
|
mugwort |
|
alternaria |
|
cladosporium |
📊 Level classification
Each allergen measurement is classified into one of five levels, represented by the Level enum. Thresholds vary per allergen.
| Enum | Code | Danish name | Description |
|---|---|---|---|
Level::Unknown |
unknown |
ukendt | No measurable pollen (count = 0) |
Level::Low |
low |
lavt | Below the low threshold |
Level::Moderate |
moderate |
moderat | Below the moderate threshold |
Level::High |
high |
højt | Below the high threshold |
Level::VeryHigh |
very-high |
meget højt | At or above the high threshold |
use Rugaard\Pollen\Enums\Level; $birch = $measurements->get('birch'); // Compare against a level. if ($birch->get('level') === Level::VeryHigh) { // 🤧 } // Get a machine-readable code. $birch->get('level')->code(); // e.g. 'very-high' // Get the Danish name. $birch->get('level')->danishName(); // e.g. 'meget højt'
🗣 Frequently Asked Questions (FAQ)
What is this Illuminate\Support\Collection class and how does it work?
All data is returned within an Illuminate\Support\Collection. This is the same Collection class used by the Laravel framework, available as a standalone package — so no Laravel installation is required.
Please refer to Laravel's detailed documentation to learn more about how you work with a Collection:
https://laravel.com/docs/collections
💰 Donating to Astma-Allergi Denmark
To help Astma-Allergi Denmark maintain and further develop the Pollen measurement service.
Please consider sending them a donation.
🚓 License
This package is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 (CC BY-NC-ND 4.0).
rugaard/pollen 适用场景与选型建议
rugaard/pollen 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 7, 最近一次更新时间为 2019 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「measurements」 「rugaard」 「morten」 「morten rugaard」 「pollen」 「pollen measurements」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rugaard/pollen 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rugaard/pollen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rugaard/pollen 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PHP library for converting between standard units of measure.
Measure your scripts (forked and improved from the Symofny's one)
A PHP library for converting between standard units of measure.
Laravel Unit Conversion
Trustpilot OAuth 2.0 Client Provider for The PHP League OAuth2-Client
A PHP library for converting between standard units of measure.
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-27

