1. Go to this page and download the library: Download webiny/annotations 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/ */
webiny / annotations example snippets
/**
* This is a class description with some annotations.
*
* @prop SomeProperty that has a string value.
* @author.name AuthorName
* @author.email [email protected]
* @author.website.url http://www.webiny.com
* @author.website.desc My website
*
*/
class TestClass
{
/**
* @var SomeVarAnnotation
* @public
*/
var $someVar;
/**
* @access.role ADMIN
* @access.level 3
* @name SomeName
*/
private $_anotherVar;
/**
* @post @get
* @cache.ttl 10
* @cache.store true @cache.key cacheKey
* @accept ["json", "xml"]
*/
function someMethod()
{
}
}
class MyClass
{
use AnnotationsTrait;
function getClassAnnotations()
{
$classAnnotations = $this->annotationsFromClass('TestClass');
$classAnnotations->prop; // SomeProperty that has a string value.
$classAnnotations->author->website->url; // http://www.webiny.com
}
function getPropertyAnnotations()
{
$someVarPropertyAnnotations = $this->annotationsFromProperty('TestClass', 'someVar');
$someVarPropertyAnnotations->public; // returns "true"
}
function getMethodAnnotations()
{
$methodAnnotations = $this->annotationsFromMethod('TestClass', 'someMethod');
$methodAnnotations->cache->key; // cacheKey
$methodAnnotations->accept; // [0 => "json", 1 => "xml"]
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.