PHP code example of neontsun / read-attribute
1. Go to this page and download the library: Download neontsun/read-attribute 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/ */
neontsun / read-attribute example snippets
#[\Attribute(\Attribute::TARGET_CLASS)]
final class CustomAttribute {}
#[CustomAttribute]
final class Foo
{
}
use Neontsun\ReadAttribute\ReadAttribute;
final class Controller
{
use ReadAttribute;
public function __invoke()
{
$attribute = $this->readClassAttribute(Foo::class, CustomAttribute::class);
if ($attribute instanceof CustomAttribute) {
// true
}
}
}