PHP code example of atomatis / ofm

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

    

atomatis / ofm example snippets

 


declare(strict_types=1);

namespace App\Entity;

use Atomatis\OFM as OFM;

#[OFM\Entity(OFM\Entity::TYPE_YAML)]
final class Configuration
{
    #[OFM\Parameter]
    private ?string $foo;

    #[OFM\Parameter]
    private ?array $bar;
    
    ...
    
    // getter/setter
    
    ...
 
// init registry with Entity file path.
$registry = new Registry();
$registry->addFile(Configuration::class, (new RegistryConfiguration())->setPath('my/file/path/configuration.yaml'));
$entityManager = new EntityManager($registry);
 
$configuration = $entityManager->load(Configuration::class);

$configuration->getFoo(); // return 'hello here'
$configuration->getBar(); // return null
 
$configuration = $entityManager->load(Configuration::class);
$configuration->setFoo('see you later');
$entityManager->flush($configuration);