1. Go to this page and download the library: Download pollora/meta 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/ */
pollora / meta example snippets
use Pollora\Attributes\Meta;
use Pollora\Attributes\PostType;
#[PostType('event')]
class Event
{
#[Meta(showInRest: true, label: 'Capacity', rules: ['min:0', 'max:5000'])]
public int $capacity = 0;
#[Meta(showInRest: true)]
public bool $soldOut = false;
#[Meta]
public ?CarbonImmutable $startsAt = null;
}
$event = $meta->of(Event::class, $postId); // MetaAccessor::of(), Meta::of() in a Pollora application
$event->capacity; // int
$event->fill(['capacity' => 250, 'soldOut' => true])->save();
$event->set('capacity', 12)->save(); // set(), fill() and save() return the record
use Pollora\Discovery\Domain\Models\DiscoveryLocation;
use Pollora\Discovery\Infrastructure\Services\DiscoveryEngine;
use Pollora\Hook\Adapter\Out\WordPress\Action;
use Pollora\Meta\Application\Services\MetaAccessor;
use Pollora\Meta\Application\Services\MetaSchemaBuilder;
use Pollora\Meta\Application\Services\MetaSchemaRepository;
use Pollora\Meta\Domain\Services\MetaValueCaster;
use Pollora\Meta\Infrastructure\Adapters\WordPressMetaRegistry;
use Pollora\Meta\Infrastructure\Adapters\WordPressMetaStore;
use Pollora\Meta\Infrastructure\Services\MetaDiscovery;
$caster = new MetaValueCaster;
$builder = new MetaSchemaBuilder;
$schemas = new MetaSchemaRepository;
(new DiscoveryEngine)
->addLocation(new DiscoveryLocation('MyPlugin\\', __DIR__.'/src'))
->addDiscovery('meta', new MetaDiscovery($builder, $schemas, new WordPressMetaRegistry(new Action, $caster)))
->run();
$meta = new MetaAccessor($schemas, $builder, new WordPressMetaStore, $caster);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.