atomatis / ofm
There is no license information available for the latest version (1.0.2) of this package.
Object file mapper
1.0.2
2022-05-12 09:53 UTC
Requires
- php: 8.*
- php-school/cli-menu: ^4.2
- symfony/property-access: ^6.0
- symfony/serializer: ^6.0
- symfony/yaml: ^6.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^6.0
This package is not auto-updated.
Last update: 2025-03-27 23:59:54 UTC
README
Object file manipulator inspired by doctrine/ORM package
Warning. I write this for personal use. Documentation is really poor. If you are interested for use this package, contact me at alexandre.tomatis@gmail.com for get better documentation.
Installation
composer req atomatis/OFM
Usage
Create entity
Example with yaml file
<?php 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 ...
Configuration
// 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);
Load file
# my/file/path/configuration.yaml foo: 'hello here'
$configuration = $entityManager->load(Configuration::class); $configuration->getFoo(); // return 'hello here' $configuration->getBar(); // return null
Flush file
# my/file/path/configuration.yaml foo: 'hello here'
$configuration = $entityManager->load(Configuration::class); $configuration->setFoo('see you later'); $entityManager->flush($configuration);
# my/file/path/configuration.yaml foo: 'see you later'