PHP code example of tebru / dynamo
1. Go to this page and download the library: Download tebru/dynamo library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tebru / dynamo example snippets
$generator = \Tebru\Dynamo\Generator::builder()
->namespacePrefix('My\Custom\Library')
->setCacheDir('path/to/cache/vendor-name')
->build();
$generator->createAndWrite(MyInterface::class);
$eventDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
$eventDispatcher->addListener(new MethodListener());
$generator = \Tebru\Dynamo\Generator::builder()
->namespacePrefix('My\Custom\Library')
->setCacheDir('path/to/cache/vendor-name')
->setEventDispatcher($eventDispatcher)
->build();
namespace Foo;
use Tebru\Dynamo\Event\MethodEvent;
class MethodListener
{
public function __invoke(MethodEvent $event)
{
$methodModel = $event->getMethodModel();
$annotationCollection = $event->getAnnotationCollection();
$body = [];
if ($annotation->collection->exists(MyAnnotation::class)) {
$body[] = '$var = "annotation exists";';
} else {
$body[] = '$var = "annotation not exists";';
}
$methodModel->setBody(implode($body));
}
}