1. Go to this page and download the library: Download apie/storage-metadata 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/ */
apie / storage-metadata example snippets
use Apie\Core\FileStorage\FileStorageFactory;
use Apie\StorageMetadata\DomainToStorageConverter;
DomainToStorageConverter::create(FileStorageFactory::create());
use Apie\StorageMetadata\Attributes\ParentAttribute;
use Apie\StorageMetadata\Attributes\PropertyAttribute;
use Apie\StorageMetadata\Interfaces\StorageDtoInterface;
use ReflectionClass;
class AddressStorage implements StorageDtoInterface
{
public static function getClassReference(): ReflectionClass
{
return new ReflectionClass(Address::class);
}
#[ParentAttribute]
public User $parent;
public function __construct(
#[PropertyAttribute('street')]
public ?string $apieStreet,
#[PropertyAttribute('streetNumber')]
public ?string $apieStreetNumber,
#[PropertyAttribute('zipcode')]
public ?string $apieZipcode,
#[PropertyAttribute('city')]
public ?string $apieCity,
#[PropertyAttribute('manual')]
public ?bool $apieManual,
) {
}
}
use Apie\Core\FileStorage\FileStorageFactory;
use Apie\StorageMetadata\DomainToStorageConverter;
$converter = DomainToStorageConverter::create(FileStorageFactory::create());
$domainObject = $converter->createDomainObject(
new AddressStorage(
'Evergreen Terrace',
'742',
'11111',
'Springfield',
false
)
);
use Apie\Core\Utils\EntityUtils;
use Apie\StorageMetadata\Attributes\DiscriminatorMappingAttribute;
use Apie\StorageMetadata\Attributes\GetMethodAttribute;
use Apie\StorageMetadata\Attributes\PropertyAttribute;
use Apie\StorageMetadata\Interfaces\StorageClassInstantiatorInterface;
class AnimalStorage implements StorageClassInstantiatorInterface
{
public function __construct(
#[DiscriminatorMappingAttribute]
private array $discriminatorMapping,
#[GetMethodAttribute('getId')]
private string $id,
#[PropertyAttribute('id')]
private ?string $apieId,
#[PropertyAttribute('hasMilk', Cow::class)]
private ?bool $apieHasMilk = null,
#[PropertyAttribute('starving', Elephant::class)]
private ?bool $apieStarving = null,
#[PropertyAttribute('poisonous', Fish::class)]
private ?bool $apiePoisonous = null
) {
}
public static function getClassReference(): ReflectionClass
{
return new ReflectionClass(Animal::class);
}
public function createDomainObject(ReflectionClass $class): object
{
$class = EntityUtils::findClass($this->discriminatorMapping, $class);
assert(null !== $class);
return $class->newInstanceWithoutConstructor();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.