This trait can help with writing facades where you want some methods to forward on to a target object or to create a proxy class, for example if you don't want to reference vendor code from within your domain.
- PHP 5.4+
Install composer in your project:
curl -s http://getcomposer.org/installer | php
Create a composer.json
file in your project root:
{
"require": {
"brightmachine/rapper": "*"
}
}
Install via composer:
php composer.phar install
Rapper is open-sourced software licensed under the MIT License - see the LICENSE file for details
Currently this trait allows you to do the following:
- set the target object for proxying to
- define a map of different function names to use
Example:
<?php namespace Example;
use Monolog\Logger;
use BrightMachine\ObjectWrapper;
/**
* Class Logger
*
* Proxy requests to Monolog/Logger
*
* @method mixed logMessage($msg) add a debug message
* @package Example\Logger
*/
class Logger
{
use ObjectWrapper;
public function __construct ()
{
$target = new Logger('dev', $this->app['events']);
$this->setTargetObject($target)
->setProxyFunctionMap([
'logMessage' => 'addDebug'
]);
}
}
Checkout master source code from github:
hub clone brightmachine/rapper
Install development components via composer:
# If you don't have composer.phar
./scripts/bundle-devtools.sh .
# If you have composer.phar
composer.phar install --dev
We follows coding standard PSR-2.
Check if your codes follows PSR-2 by phpcs:
./vendor/bin/phpcs --standard=PSR2 src/
Git repo skeleton by "Goodby Setup".