PHPackages                             coonlink/secretroom - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. coonlink/secretroom

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

coonlink/secretroom
===================

A PHP library for handling secret Easter eggs based on user inputs.

11PHP

Since Aug 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/coonlink/SecretRoom)[ Packagist](https://packagist.org/packages/coonlink/secretroom)[ RSS](/packages/coonlink-secretroom/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (1)Used By (0)

SecretRoom
==========

[](#secretroom)

SecretRoom is a PHP library designed to manage Easter eggs based on user inputs such as dates, texts, or numbers. The library allows you to define custom responses for specific inputs and supports localization, making it a versatile tool for PHP-based projects.

[![alt text](https://camo.githubusercontent.com/cda9ac76284f04b348421ddd4ef04afeb6d832ca0a188cd024cc93e5bc0ae360/68747470733a2f2f636f6f6e6c696e6b2e66756e2f536563726574526f6f6d2f696d6167652e6a70673f31)](https://camo.githubusercontent.com/cda9ac76284f04b348421ddd4ef04afeb6d832ca0a188cd024cc93e5bc0ae360/68747470733a2f2f636f6f6e6c696e6b2e66756e2f536563726574526f6f6d2f696d6167652e6a70673f31)

Requirements
------------

[](#requirements)

- PHP version 8.0.0 or higher
- Composer

Installation
------------

[](#installation)

To install the SecretRoom library via Composer, run the following command:

```
composer require coonlink/secretroom
```

This will download and install the library and its dependencies in your project.

Usage
-----

[](#usage)

To use SecretRoom in your project, include the Composer autoload file and create an instance of the `SecretRoom` class.

Here is a basic example of how to set it up:

```
require 'vendor/autoload.php';

use PHPsecretroom\SecretRoom;

$responses = [
    'test' => 'ok',
];

$requestHandler = new SecretRoom($responses);
$requestHandler->handleRequest();
```

### Handling Requests

[](#handling-requests)

The `SecretRoom` class processes incoming POST requests in JSON format. Based on the provided input (date, text, or number), the library searches for a matching Easter egg or returns a default response.

Example JSON input:

```
{
    "date": "1980",
    "lang": "en"
}
```

#### Input Parameters:

[](#input-parameters)

- **"date"**: Instead of using a date, you can specify a string of text or a number, or leave it to handle a default case. This input is used to match against predefined Easter eggs in the `easter_eggs.json` file. If a match is found, the corresponding message is returned.

    - **Text Input**: You can send any text to the library. If it matches an Easter egg defined in `easter_eggs.json`, the corresponding message is returned.
    - **Number Input**: You can also send numbers. Similar to text, if the number matches an Easter egg in `easter_eggs.json`, the message is returned.
    - **Default Case**: If the input does not match any defined Easter eggs, a default response or an error message is returned.
- **"lang"**: This optional parameter allows you to request the response in a specific language. If the language is not provided or if the requested language is not available, the library will return the message in the default language.

Example:

```
{
    "text": "hello",
    "lang": "ru"
}
```

This would return the Easter egg response for the text "hello" in Russian, if defined, or the default message if not.

### Localization

[](#localization)

SecretRoom supports localization by allowing you to define different responses based on the provided language code. The `easter_eggs.json` file can include localized messages for specific inputs. If no localization is found for the requested language, a default message will be returned.

Example structure of `easter_eggs.json`:

```
{
    "1980": {
        "en": "Thank you for discovering the first Easter egg in the video game 'Adventure'.",
        "ru": "Спасибо за то, что обнаружили первое пасхальное яйцо в видеоигре 'Adventure'."
    },
    "hello": {
        "en": "Hello there!",
        "es": "¡Hola!"
    },
    "42": {
        "default": "The answer to life, the universe, and everything."
    }
}
```

### Autoloading Classes

[](#autoloading-classes)

The library uses a custom autoloader defined in `autoload.php`. This autoloader ensures that PHP classes are automatically loaded when they are needed, based on the PSR-4 standard.

### Error Handling

[](#error-handling)

The library performs a PHP version check at runtime. If the installed PHP version is lower than 7.4.0, an error message will be displayed, and the script will terminate.

For command-line usage, the error message will be output to `STDERR`. In a web context, the message will be displayed with a `500 Internal Server Error` response.

File Structure
--------------

[](#file-structure)

Here is an overview of the key files and directories:

```
SecretRoom/
│
├── src/
│   ├── autoload.php           # Custom autoloader
│   └── PHPsecretroom/
│       ├── SecretRoom.php     # Main class handling requests and responses
│       └── easter_eggs.json   # Easter egg definitions
│
├── tests/                     # (Optional) Unit tests
│   └── SecretRoomTest.php
│
├── composer.json              # Composer configuration
├── README.md                  # Project documentation (this file)
└── index.php                  # Example usage of the library

```

Testing
-------

[](#testing)

If you wish to run unit tests, you can install PHPUnit as a development dependency and create test cases for your classes. To install PHPUnit, run:

```
composer require --dev phpunit/phpunit
```

Then, you can create test files in the `tests/` directory and run them with the following command:

```
vendor/bin/phpunit tests
```

Contributing
------------

[](#contributing)

If you would like to contribute to this project, feel free to fork the repository and submit a pull request. All contributions are welcome!

License
-------

[](#license)

This project is licensed under the MIT License. See the `LICENSE` file for more details.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/28f92808f4fb8277ff7803d66563b4e8a8330e44c3d00367c4d7113c9da7407d?d=identicon)[coonlink](/maintainers/coonlink)

---

Top Contributors

[![crc137](https://avatars.githubusercontent.com/u/165967398?v=4)](https://github.com/crc137 "crc137 (57 commits)")

### Embed Badge

![Health badge](/badges/coonlink-secretroom/health.svg)

```
[![Health](https://phpackages.com/badges/coonlink-secretroom/health.svg)](https://phpackages.com/packages/coonlink-secretroom)
```

###  Alternatives

[mad-web/laravel-robots

Robots.txt generator service.

33126.9k](/packages/mad-web-laravel-robots)[sgh/comparable

Provides Comparable and Comparator interfaces and methods to sort and compare objects based on these.

1473.7k2](/packages/sgh-comparable)[elgentos/magento2-structured-data

Implement structured data for Magento 2 webshops.

1444.7k](/packages/elgentos-magento2-structured-data)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
