Download the PHP package icanboogie/prototype without Composer

On this page you can find all versions of the php package icanboogie/prototype. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package prototype

Prototype

Release Code Quality Code Coverage Packagist

The icanboogie/prototype package allows methods of classes using the PrototypeTrait to be defined at runtime, and since the icanboogie/accessor package is used, this also includes getters and setters.

Installation

Defining methods at runtime

Methods can be defined at runtime using the prototype of a class. They are immediately available to every instance of the class and are inherited by the sub-classes of that class.

Defining getters and setters at runtime

Because getters and setters are methods too, they are defined just like regular methods.

Dependency injection, inversion of control

Dependency injection and inversion of control can be implemented using prototype lazy getters.

The following example demonstrates how a magic image property can be defined to lazy load a record from an ActiveRecord model.

Prototype methods and parent::

Prototype methods can be overridden and work with parent:: calls just like regular methods.

In the following example the prototype method url() is added to the class Node and overridden in the class News, still parent:: can be used from News:

Defining prototypes methods

Prototype methods can be defined using a global configuration; through the prototype property of an Prototyped instance; or using the Prototype instance associated with classes using the PrototypeTrait trait.

Defining prototypes methods using a global configuration

All prototypes can be configured using a single global configuration. For each class you can define the methods that the prototype implements.

The following example demonstrate how the meow() method is defined for instances of the Cat and FierceCat classes. Although they are defined using closure in the example, methods can be defined using any callable such as "App\Hooks::cat_meow".

Defining prototypes methods through the prototype property

Prototype methods may be defined using the prototype property:

Defining prototypes methods using a prototype instance

Prototype methods may be defined using the Prototype instance of a class:

Defining prototypes methods using config fragments

If the package is bound to ICanBoogie using icanboogie/bind-prototype, prototype methods may be defined using prototype configuration fragments:

Getting an array representation of an object

An array representation of an Prototyped instance can be obtained using the to_array() method. Only public and façade properties are exported.

As mentioned before, façade properties are also exported. The to_array() method should be overrode to alter this behavior.

Additionally the to_array_recursive() method can be used to recursively convert an instance into an array, in which case all the instances of the tree implementing ToArray or ToArrayRecursive are converted into arrays.

Getting a JSON representation of an object

The to_json() method can be used to get a JSON representation of an object. The method is really straight forward, it invokes to_array_recursive() and pass the result to json_encode().

Creating an instance from an array of properties

The Prototyped::from() method creates an instance from an array of properties:

Instances are created in the same fashion PDO creates instances when fetching objects using the FETCH_CLASS mode, that is the properties of the instance are set before its constructor is invoked.

Exceptions

The following exceptions are defined:


Continuous Integration

The project is continuously tested by GitHub actions.

Tests Static Analysis Code Style

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.

Contributing

Please see CONTRIBUTING for details.

License

icanboogie/prototype is released under the BSD-3-Clause.


All versions of prototype with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.5
ext-json Version *
icanboogie/accessor Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package icanboogie/prototype contains the following files

Loading the files please wait ....