PHPackages                             michaelspiss/singleton - 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. michaelspiss/singleton

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

michaelspiss/singleton
======================

A trait to implement the Singleton design pattern without any dependencies.

v1.0.1(9y ago)014MITPHPPHP &gt;= 5.4

Since Apr 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/michaelspiss/singleton)[ Packagist](https://packagist.org/packages/michaelspiss/singleton)[ Docs](https://github.com/michaelspiss/singleton)[ RSS](/packages/michaelspiss-singleton/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

Singleton
=========

[](#singleton)

A trait to implement the Singleton design pattern without any dependencies.

[![Build Status](https://camo.githubusercontent.com/9f4017a7d70d4ecc30ba6da1b92901fdd4cf4c3c82916400d69cb74aceccad26/68747470733a2f2f7472617669732d63692e6f72672f6d69636861656c73706973732f73696e676c65746f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/michaelspiss/singleton)[![Coverage Status](https://camo.githubusercontent.com/15d0bacce334d89bb7557460576de8f02cc5c098b5939dd97167d49c4de56321/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d69636861656c73706973732f73696e676c65746f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/michaelspiss/singleton?branch=master)

Why?
----

[](#why)

There already are plenty other singleton packages, so why another one? Simply, because most of those packages implement a factory, rather than a singleton pattern. This and many more things bothered me about them, so here is a simple, dependency-free and fully tested singleton.

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

[](#installation)

```
$ composer require michaelspiss/singleton

```

Basic Usage
===========

[](#basic-usage)

One line is enough to turn a class into a singleton:

```
