Skip to content

tomsseisums/prototype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Prototype

Prototype is a runtime extension library built for plugin development. Initially inspired by JavaScript's .prototype, but extended to allow for instance extensions.

Requirements

  • PHP5.4

Contents

You have three abstract classes at your disposal:

  • Prototype — the main runtime extension component, used to extend classes with public properties and methods.
  • Extendable (extends Prototype) — the main instance level runtime extension component, used to register class based extensions that will be auto-applied to every instance.
  • Extension — not exactly for extensions, acts as an interface. Used in conjuction with Extendable.

Usage

Prototype:

<?php

use Prototype\Prototype as Proto;

// Simply extend with Prototype.
class A extends Proto
{}

// Create instance.
$a = new A;

// Add property.
$a->dummyProperty = 'x';

// Add method.
$a->dummyMethod = function()
{
    // Yes, $this actually refers to the classes instance.
    echo $this->dummyProperty;

    // Chaining is also possible.
    return $this;
};

// Test it.
$a->dummyMethod()->dummyMethod(); // xx

TODO

  • Finish Usage:
  • Extendable & Extension.

About

JavaScript like prototype for PHP through magic methods.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages