delboy1978uk / proxy-generator
Use your own interfaces by generating wrapper classes.
Requires
- league/flysystem: ^1.0
- symfony/console: ^3.1
Requires (Dev)
- codeception/codeception: dev-master
- zendframework/zend-filter: ^2.7
This package is auto-updated.
Last update: 2024-11-04 22:31:39 UTC
README
A Proxy generator for getting third party libraries to implement your interface. Just tell it what Interface you wish to
replace, and it will search through, and generate your own class extending it but implementing your own interface.
##Example
Replacing Some\Symfony\Lib\SomeInterface with My\Awesome\Lib\SomeInterface will result in this before and after:
####Before
<?php namespace Some\Symfony\Lib; class UsefulClass implements SomeInterface { // etc }
####After
<?php namespace My\Awesome\Lib; use Some\Symfony\Lib\UsefulClass as ThirdPartyUsefulClass; class UsefulClass extends ThirdPartyUsefulClass implements SomeInterface { }
For each class implementing the interface, we recursively iterate over the vendor classes and generate any classes extending them. These classes will also implement our interface.
<?php namespace My\Awesome\Lib\Number; use Some\Symfony\Lib\Number\UsefulNuberClass as ThirdPartyUsefulNumberClass; use My\Awesome\Lib\SomeInterface; class UsefulClass extends ThirdPartyUsefulNumberClass implements SomeInterface { }
##Installation Install using composer
$ composer require delboy1978uk/proxy-generator
##Usage You can use Del\ProxyGenerator\Service\ProxyGeneratorService if doing it programatically, or you can use the CLI command bin/proxy-generator.
$ cd bin
$ ./proxy-generator 'VendorInterface' 'YourInterface' look/in/this/folder 'BaseVendorNamespace', 'YourBaseNamespace', 'relative/path/to/genarate', '/absolute/project/root/basedir'