PHP code example of performing / laravel-field-attributes

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

    

performing / laravel-field-attributes example snippets


class MyDto 
{
    use FieldAttributes;

    public function __construct(
        #[Field(label: 'Name', description: 'Enter your full name')]
        public string $name,
        #[Field(label: 'Email', description: 'Enter your email address')]
        public string $email,
    ) {}
}

$instance = new MyDto('John Doe', '[email protected]');

$instance->getFieldValues(); 
// ['name' => 'John Doe', 'email' => '[email protected]']

$instance->getFieldDefinitions(); 
// [
//    'name' => ['label' => 'Name', 'description' => 'Enter your full name', 'type' => 'string', '