No description
Find a file
2025-10-14 18:43:18 +00:00
cache update code 2025-10-14 18:43:18 +00:00
etc update code 2025-10-14 18:43:18 +00:00
event-handler.php update code 2025-10-14 18:43:18 +00:00
index.html update code 2025-10-14 18:43:18 +00:00
LICENSE.html update code 2025-10-14 18:43:18 +00:00
LICENSE.md update code 2025-10-14 18:43:18 +00:00
README.md update code 2025-10-14 18:43:18 +00:00
script.js update code 2025-10-14 18:43:18 +00:00

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 systemevent-handler.php caches output once per day (from 12:01 AM) to reduce load.
  • Dynamic inclusion — Automatically runs all etc/*.php scripts 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 Years 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

  1. event-handler.php scans etc/*.php and executes each one.
  2. Each holiday script checks the current date using date() and echoes a message if the condition matches.
  3. The handler captures all non-empty outputs, joins them with <br>, and caches the result.
  4. 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

  1. Copy etc/template.php to a new file, e.g. etc/earthday.php.

  2. Edit the file:

    <?php
    if (date('m-d') == '04-22') {
        echo "Happy Earth Day!";
    }
    
  3. 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.