PHPackages                             arunagirinathar/php-design-patterns - 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. arunagirinathar/php-design-patterns

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

arunagirinathar/php-design-patterns
===================================

A lightweight PHP package implementing common design patterns like Singleton and Factory. Useful for clean and efficient object management in PHP projects.

v1.3.1(1y ago)022GPL-3.0-onlyPHP

Since Mar 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/arunagirinathar/DesignPatterns)[ Packagist](https://packagist.org/packages/arunagirinathar/php-design-patterns)[ RSS](/packages/arunagirinathar-php-design-patterns/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (15)Used By (0)

DesignPatterns
==============

[](#designpatterns)

A lightweight PHP package implementing common design patterns like Singleton and Factory. Useful for clean and efficient object management in PHP projects.

Design Patterns (PHP)
=====================

[](#design-patterns-php)

[![License: GPL v3](https://camo.githubusercontent.com/48bf9b56d44f38db53ce21294cf0b9487d0a3734ab3ba1fe4c69858ae20db2c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c76332d626c75652e737667)](https://www.gnu.org/licenses/gpl-3.0)

A lightweight PHP package implementing common design patterns like **Singleton** and **Factory**. Useful for clean and efficient object management in PHP projects.

---

📌 Features
----------

[](#-features)

✅ **Singleton** – Ensures only one instance of a class exists.
✅ **Factory** – Creates objects without specifying the exact class type.

Polyfills (Extra Feature)
-------------------------

[](#polyfills-extra-feature)

Older versions of PHP may not have certain function available. For example `json_validate()` is not available in PHP versions older than 8.3.0. This class transparently implements all this functionality as a shim / polyfill without disturbing environments where such functions are available.

Functions currently implemented in the polyfills

✅ **`json_validate`**

---

📥 Installation
--------------

[](#-installation)

Using [Composer](https://getcomposer.org/):

```
composer require arunagirinathar/design-patterns
```

---

🛠 Usage
-------

[](#-usage)

### Singleton Example

[](#singleton-example)

```
use Arunagirinathar\DesignPatterns\Singleton;

class MySingleton extends Singleton
{
    private string $data = "Hello, Singleton!";

    public function getData(): string
    {
        return $this->data;
    }
}

$instance1 = MySingleton::getInstance();
$instance2 = MySingleton::getInstance();

echo $instance1->getData(); // Hello, Singleton!
var_dump($instance1 === $instance2); // true (Both refer to the same instance)
```

---

📝 License
---------

[](#-license)

This project is licensed under the **GNU GPLv3**. See the [LICENSE](LICENSE) file for details.

---

📬 Contact
---------

[](#-contact)

Maintainer: **Arunagirinathar**
📧 Email:
🔗 GitHub: [Arunagirinathar/DesignPatterns](https://github.com/arunagirinathar/DesignPatterns)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance48

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~3 days

Total

14

Last Release

389d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a6fe05145d95d171553ba5963681d228f9ba930eaee92b056ff7fa30ef61399?d=identicon)[arunagirinathar](/maintainers/arunagirinathar)

---

Top Contributors

[![arunagirinathar](https://avatars.githubusercontent.com/u/6995292?v=4)](https://github.com/arunagirinathar "arunagirinathar (17 commits)")

### Embed Badge

![Health badge](/badges/arunagirinathar-php-design-patterns/health.svg)

```
[![Health](https://phpackages.com/badges/arunagirinathar-php-design-patterns/health.svg)](https://phpackages.com/packages/arunagirinathar-php-design-patterns)
```

PHPackages © 2026

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