PHPackages                             doekenorg/decorate-php - 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. doekenorg/decorate-php

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

doekenorg/decorate-php
======================

Create a PHP decorator or proxy based on an interface or (abstract) class.

v0.1.0(2y ago)298[2 issues](https://github.com/doekenorg/decorate-php/issues)GPL-3.0-or-laterPHPPHP ^8.1

Since Jan 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/doekenorg/decorate-php)[ Packagist](https://packagist.org/packages/doekenorg/decorate-php)[ RSS](/packages/doekenorg-decorate-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Decorate PHP
============

[](#decorate-php)

Easily create decorators and proxies with a simple (composer) command.

[![](https://camo.githubusercontent.com/fd30cac66cb80a24ef095d832ee02f21456761cc85407dc771167807c1f30229/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646f656b656e6f72672f6465636f726174652d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/doekenorg/decorate-php)

---

Do you enjoy using decorators in PHP, but hate having to implement one with large amounts of methods? Then this is the plugin for you! You can now quickly create a (final or abstract) class from an interface with all the methods already implemented and forwarded to the next instance. This little time saver lets you get on with the things you enjoy.

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

[](#installation)

```
composer global require doekenorg/decorate-php
```

***Notice**: This is a global plugin, so don't forget `global` in the command!*

Usage
-----

[](#usage)

The plugin adds a `decorate` command to your `composer` instance. It needs a source class (the interface you want to decorate) and a target class. You can optionally provide the name of the variable it uses for the next class. Currently, the plugin only works for composer projects.

### Create a new decorator

[](#create-a-new-decorator)

```
composer decorate "Package\Namespace\SomeInterface" "My\Namespace\DestinationClass"
```

This will create, and write, a file called `DestinationClass.php` in the appropriate folder mapped in your `psr-4`autoloader configuration.

A file like this will be created:

```
