php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54390 Please remove the Singleton Pattern from the Docs
Submitted: 2011-03-26 13:18 UTC Modified: 2011-07-11 11:56 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:3 of 4 (75.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: gordon at onlinehome dot de Assigned: salathe (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gordon at onlinehome dot de
New email:
PHP Version: OS:

 

 [2011-03-26 13:18 UTC] gordon at onlinehome dot de
Description:
------------
The [chapter on Design Patterns in the Manual][1] starts with:

> Patterns are ways to describe best practices and good designs. They show a flexible solution to common programming problems.

and then goes on to show a Singleton Pattern. The problems Singletons solve do not exist in PHP. And even Erich Gamma thinks it's a Code Smell nowadays in general. Consequently, I think we should not educate people about this pattern and suggest removal.

[1]: http://www.php.net/manual/en/language.oop5.patterns.php


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-02 04:18 UTC] frozenfire@php.net
-Status: Open +Status: Bogus
 [2011-07-02 04:18 UTC] frozenfire@php.net
Singleton patterns are applicable to PHP, in a number of scenarios. The most 
common example is to maintain a single database connection for multiple instances 
of a database class.

Please do correct me if I'm wrong, but for now, I'm going to mark this bogus.
 [2011-07-11 11:56 UTC] salathe@php.net
-Status: Bogus +Status: Closed -Assigned To: +Assigned To: salathe
 [2011-07-11 11:56 UTC] salathe@php.net
Gordon improved the description of the Singleton. See http://svn.php.net/viewvc?
view=revision&revision=313136
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 18:00:02 2026 UTC