PHPackages                             tasso/prototype - 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. tasso/prototype

Abandoned → [tassoevan/prototype](/?search=tassoevan%2Fprototype)Library[Utility &amp; Helpers](/categories/utility)

tasso/prototype
===============

Simple prototype-based programming for PHP

2.0.0(9y ago)4191MITPHPPHP &gt;=5.6

Since Jan 29Pushed 9y ago2 watchersCompare

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

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

Prototype [![Build Status](https://camo.githubusercontent.com/aac43ba46454edcfa3602a1a1d8f8dde4a51eba576010f7f63a345bb3d9466b2/68747470733a2f2f7472617669732d63692e6f72672f746173736f6576616e2f70726f746f747970652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/tassoevan/prototype)
==================================================================================================================================================================================================================================================================================================

[](#prototype-)

*Simple prototype-based programming in PHP*

Prototype programming is a flavor of object-oriented programming that deals with objects without categorization provided by classes or interfaces. All objects can be identified and differentiated by [duck typing](http://en.wikipedia.org/wiki/Duck_typing). Basically, properties and methods are put in objects on runtime, instead of previously declared in classes; inheritance is obtained by object cloning and dynamic insertion of properties. Thus parent objects act as *prototypes* for their children.

This allow you to quickly code, once you do structural changes in your source code *while* you're programming. However, although good for small projects, it can generate unmaintainable applications. It's recommmended that you use prototyping to prototype application modules first and implement an equivalent traditional class-based structure after.

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

[](#installation)

The recommended way to install this package is through [Composer](https://getcomposer.org/). Create a common `composer.json` file and run:

```
$ composer require tassoevan/prototype
```

Documentation
-------------

[](#documentation)

### Basic usage

[](#basic-usage)

All prototypes are instances of `TassoEvan\Prototype\Prototype` class. Properties can be added and removed exactly like the native `stdClass`. The key difference between `Prototype` and `stdClass` is that the last one doesn't handle callable arguments and closures well. You can call closures in a `Prototype` instance exactly as they are methods.

```
