1. Go to this page and download the library: Download spiral/marshaller-bridge 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/ */
declare(strict_types=1);
use Spiral\Core\Container\Autowire;
use Spiral\Marshaller\Mapper\AttributeMapperFactory;
use Spiral\Marshaller\Type\ArrayType;
use Spiral\Marshaller\Type\DateTimeType;
use Spiral\Marshaller\Type\DateIntervalType;
use Spiral\Marshaller\Type\EnumType;
use Spiral\Marshaller\Type\ObjectType;
return [
'mapperFactory' => AttributeMapperFactory::class,
'matchers' => [
EnumType::class,
DateTimeType::class,
DateIntervalType::class,
ArrayType::class,
ObjectType::class,
],
];
use Spiral\Marshaller\MarshallerInterface;
$marshaller = $this->container->get(MarshallerInterface::class);
$result = $marshaller->marshal($from); // from object to array
$result = $marshaller->unmarshal($from, new Post()); // from array to object
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.