No description
| cache | ||
| etc | ||
| event-handler.php | ||
| index.html | ||
| LICENSE.html | ||
| LICENSE.md | ||
| README.md | ||
| script.js | ||
PHP Holidays
A lightweight, modular PHP project that outputs holiday greetings and observances based on the current date. Each holiday is defined in its own PHP file, and all are dynamically loaded by a central event handler with daily caching for performance.
Features
- Modular design — Each holiday or observance is a standalone script in
etc/, easily editable or extendable. - Daily cache system —
event-handler.phpcaches output once per day (from 12:01 AM) to reduce load. - Dynamic inclusion — Automatically runs all
etc/*.phpscripts in sorted order. - Custom holiday support — Add your own events by copying
etc/template.php.
Directory Structure
php-holidays/
├── etc/ # Individual holiday scripts
│ ├── bday.php # Linus Torvalds' birthday
│ ├── christmas.php # Christmas Day
│ ├── columbus.php # Columbus Day (2nd Monday in October)
│ ├── earthday.php # Earth Day
│ ├── easter.php # Easter Sunday (computed dynamically)
│ ├── holiday.php # Generic December holidays
│ ├── independence.php # July 4th
│ ├── juneteenth.php # June 19th
│ ├── labor.php # Labor Day (1st Monday in September)
│ ├── memorial.php # Memorial Day (last Monday in May)
│ ├── mlk.php # Martin Luther King Jr. Day (3rd Monday in January)
│ ├── newyear.php # New Year’s Day
│ ├── presidents.php # Presidents’ Day (3rd Monday in February)
│ ├── pride.php # Pride Month (June)
│ ├── thanksgiving.php # Thanksgiving (4th Thursday in November)
│ ├── trans.php # Trans Day of Visibility (March 31)
│ ├── veterans.php # Veterans Day (November 11)
│ └── template.php # Blank template for new holidays
├── event-handler.php # Core logic and caching
├── LICENSE.md # AGPLv3 license (Markdown format)
└── LICENSE.html # AGPLv3 license (HTML format for web use)
How It Works
event-handler.phpscansetc/*.phpand executes each one.- Each holiday script checks the current date using
date()and echoes a message if the condition matches. - The handler captures all non-empty outputs, joins them with
<br>, and caches the result. - Cache resets daily at 12:01 AM, ensuring messages update once per day.
Example cache flow:
/usr/share/nginx/example/cache/file.cache
├── timestamp → UNIX timestamp for 12:01 AM
└── message → Cached HTML message
Usage
Modify script.js and event-handler.php to your cloned directory, then test with index.html
Adding a New Holiday
-
Copy
etc/template.phpto a new file, e.g.etc/earthday.php. -
Edit the file:
<?php if (date('m-d') == '04-22') { echo "Happy Earth Day!"; } -
The event handler will automatically include it.
Requirements
- PHP ≥ 7.4 (tested up to PHP 8.3)
- Web server capable of running PHP (e.g., Nginx + PHP-FPM)
- Writable cache directory at
/usr/share/nginx/example/cache/
License
This project is licensed under the GNU Affero General Public License v3.0 (AGPLv3).
You may use, modify, and distribute it freely under the same license. See:
LICENSE.md— plain text version for developers.LICENSE.html— web-ready version for in-browser distribution.