PHP code example of xaerobiont / transfer-container
1. Go to this page and download the library: Download xaerobiont/transfer-container 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/ */
xaerobiont / transfer-container example snippets
use Xaerobiont\TransferContainer\Transferable;
use Xaerobiont\TransferContainer\TransferContainer;
class MyDTO implements Transferable {}
class YourDTO implements Transferable {}
class ThemDTO implements Transferable {}
$package = [];
for ($i = 1; $i <= 100; $i++) {
$package[] = new MyDTO();
$package[] = new YourDTO();
$package[] = new ThemDTO();
}
$container = new TransferContainer();
$container->put($package);
$transfer = $container->pack();
$container->clear();
// receiver side
$map = [
YourDTO::class => OtherDTO::class
];
foreach (TransferContainer::unpack($transfer, $map) as $item) {
// $item is MyDTO/OtherDTO/ThemDTO object
}