PHP code example of bulton-fr / annotation

1. Go to this page and download the library: Download bulton-fr/annotation 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/ */

    

bulton-fr / annotation example snippets


$annotations = new \BultonFr\Annotation\Reader(myClass::class);
$annotations->parse();

/**
 * @Table(name="writing_list")
 * @Security(role="admin", fct="mySecurityCheck")
 * @AddEntity(ns="\BultonFr\Annotation\Test\Functional\Ref\Account")
 * @AddEntity(
 *  ns="\BultonFr\Annotation\Test\Functional\Ref\Category",
 *  alias="Ref\Category"
 * )
 */

/**
 * Add a new imported namespace (obtain by AddNS or manually)
 *
 * @param string $name The class path (with ns) of the class which will be
 *  instancied when the annotation defined by $alias will be found.
 * @param string $alias The annotation key
 *
 * @return void
 */
public function addImportedNS(string $name, string $alias)

$annotations = new \BultonFr\Annotation\Reader(myClass::class);
$annotations->getParserManager()->addImportedNS(
    \myApp\myCustomAnnotation::class
    'CustomAnnot'
);
$annotations->parse();

/**
 * My class description
 *
 * @AddNS(ns="\myApp\myCustomAnnotation", alias="CustomAnnot")
 * @CustomAnnot(...)
 */
class myClass

$annotReader = new \BultonFr\Annotation\Reader(
    \BultonFr\Annotation\Test\Functional\Ref\Account
);

$annotReader
    ->getParserManager()
        ->addImportedNS('\BultonFr\Annotation\Test\Functional\Annotations\Column')
        ->addImportedNS('\BultonFr\Annotation\Test\Functional\Annotations\Route')
;

$annotReader->parse();

//string "int"
var_dump($annotReader->obtainPropertyAnnotList('id')['Column'][0]->getType());

/**
 * Add a new annotation to ignore
 *
 * @param string $annotationName The annotation's name to ignore
 *  It's the part after the @.
 *
 * @return void
 */
public static function addIgnoredAnnotation(string $annotationName)