PHPackages                             pajarotin/compose - 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. pajarotin/compose

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

pajarotin/compose
=================

Compose - A tool for class/trait creation, in a 'Frankenstein way', for PHP

v0.1.1(2y ago)14MITPHPPHP &gt;=7.4.0

Since Sep 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/pajarotin/Compose)[ Packagist](https://packagist.org/packages/pajarotin/compose)[ Docs](https://github.com/pajarotin/Compose)[ RSS](/packages/pajarotin-compose/feed)WikiDiscussions main Synced 1mo ago

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

Compose – A tool for class/trait creation, in a "Frankenstein way", for PHP
===========================================================================

[](#compose--a-tool-for-classtrait-creation-in-a-frankenstein-way-for-php)

Features
--------

[](#features)

- Flag composed class as abstract
- Flag composed class as final
- Set composed class/trait namespace
- Set composed class base class
- Add/Remove interface to composed class
- Add/Remove trait to composed class/trait
- Add/Remove constant to composed class
- Add/Remove property to composed class/trait
- Add/Remove method to composed class/trait
- Add donor class properties and methods to composed class/trait
- Add donor trait properties and methods to composed class/trait
- Add donor class interfaces, traits, constants, properties and methods to composed class
- Add donor class constant to composed class
- Deferred composed class/trait compilation (evaluation of composed code), linked to php autoload system
- Deferred composed class/trait build (configuration of composed class and), linked to php autoload system
- Update constant before compilation
- Update property before compilation
- Update method before compilation
- ¡ FULLY EXPERIMENTAL CODE !

"Favor composition over inheritance"
------------------------------------

[](#favor-composition-over-inheritance)

This tool allows composing a class or a trait by code, with chunks of previous classes or traits

- constants can be added or copied from a previous class (only to a class)
- properties can be added or copied from a previous class or trait
- methods can be added or copied from a previous class or trait
- traits can be added or copied from a previous class
- interfaces can be added or copied from a previous class (only to a class)
- Before compilation any part can be removed
- Before compilation constants and properties can also be updated

These features can be used to automate changes to third parties source code, without resorting to editing it directly.

License
-------

[](#license)

This software is distributed under the \[MIT\] license. Please read [LICENSE](https://github.com/pajarotin/compose/blob/main/LICENSE) for information on the software availability and distribution.

Example
-------

[](#example)

```
