PHP code example of flexic / attribute-reader

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

    

flexic / attribute-reader example snippets


$reflectionClass = new \ReflectionClass(MyClass::class);

$attributeReader = new Flexic\Attributes\Reader();

$attributeReader->getAttributes($reflectionClass); // Returns list of given attributes
$attributeReader->getAttribute($reflectionClass, MyAttribute::class); // Returns first attribute of given type
$attributeReader->hasAttribute($reflectionClass, MyAttribute::class); // Checks if attribute is defined on class.
$attributeReader->findClassesWithAttribute(MyAttribute::class); // Get all classes where Attribute is defined.