1. Go to this page and download the library: Download scriptfusion/porter 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/ */
foreach ($records as $record) {
var_dump($record);
}
use function Amp\async;
async(
$this->porter->import(...),
new Import(new MyResource())
);
// -OR-
async(fn () => $this->porter->import(new Import(new MyResource()));
(new Import)->setThrottle(new DualThrottle)
public function transform(RecordCollection $records, mixed $context): RecordCollection;
public function transformAsync(AsyncRecordCollection $records, mixed $context): AsyncRecordCollection;
$records = $porter->import(
(new Import(new MyResource))
->addTransformer(
new FilterTransformer(static function (array $record) {
return array_key_exists('id', $record);
})
)
);
$records = $porter->import(
(new Import(new MyResource))
->enableCache()
);
public function getConnector() : Connector;
final class MyProvider implements Provider
{
private $connector;
public function __construct(Connector $connector = null)
{
$this->connector = $connector ?: new HttpConnector;
}
public function getConnector(): Connector
{
return $this->connector;
}
}
public function getProviderClassName(): string;
public function fetch(ImportConnector $connector): \Iterator;
public function fetch(ImportConnector $connector): \Iterator
{
return new ArrayIterator(range(1, 3)); // Invalid return type.
}
public function fetch(ImportConnector $connector): \Iterator
{
foreach (range(1, 3) as $number) {
yield [$number];
}
}
public function fetch(ImportConnector $connector): \Iterator
{
$series = function ($limit) {
foreach (range(1, $limit) as $number) {
yield [$number];
}
};
return new CountableProviderRecords($series($count = 3), $count, $this);
}
class MyResource implements ProviderResource, SingleRecordResource
{
private const URL = 'https://example.com';
public function getProviderClassName(): string
{
return MyProvider::class;
}
public function fetch(ImportConnector $connector): \Iterator
{
$data = $connector->fetch(self::URL);
yield json_decode($data, true);
}
}
public function fetch(ImportConnector $connector): \Iterator
{
$data = $connector->fetch(self::URL);
foreach (json_decode($data, true) as $datum) {
yield $datum;
}
}
public function fetch(DataSource $source): mixed;
public function computeHash(): string;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.