PHP code example of fatcode / annotations

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

    

fatcode / annotations example snippets


 declare(strict_types=1);

use FatCode\Annotation\Target;
/**
 * @Annotation
 * @Target(Target::TARGET_CLASS)
 */
class MyAnnotation
{
    /**
     * @Required
     * @var string 
     */
    public $name;
}

 declare(strict_types=1);

/**
 * @MyAnnotation(name="Hello World")
 */
class AnnotatedClass
{
}

 declare(strict_types=1);
use FatCode\Annotation\AnnotationReader;

$reader = new AnnotationReader();
$annotations = $reader->readClassAnnotations(AnnotatedClass::class);
var_dump($annotations);
/* will output:
array(1) {
     [0] =>
     class MyAnnotation#19 (1) {
       public $name =>
       string(11) "Hello World"
     }
   }
*/