PHP code example of gplanchat / durable-magento

1. Go to this page and download the library: Download gplanchat/durable-magento 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/ */

    

gplanchat / durable-magento example snippets


'db' => ['connection' => ['durable' => [/* host, dbname, username, password... */]]],
'resource' => ['durable' => ['connection' => 'durable']],

'durable' => [
    'temporal' => ['dsn' => 'temporal://temporal:7233?namespace=default&tls=0'],
],

#[AsNexusServiceHandler(contract: BillingContract::class)]
final class BillingHandler implements BillingServed
{
    public function verify(string $order, int $amount, string $currency): array { /* … */ }
}

use Gplanchat\Durable\ExecutionId;

$this->runtimeFactory->workflowClient()->startAsync(
    PlaceOrder::class,
    ['orderId' => $order->getIncrementId()],
    ExecutionId::fromString('order-' . $order->getIncrementId()),
);
xml
<sequence>
    <module name="Gplanchat_DurableModule"/>
</sequence>
xml
<type name="Gplanchat\DurableModule\Runtime\RuntimeFactory">
    <arguments>
        <argument name="workflowClasses" xsi:type="array">
            <item name="place_order" xsi:type="string">Acme\Shop\Workflow\PlaceOrder</item>
        </argument>
        <argument name="activityHandlers" xsi:type="array">
            <item name="order" xsi:type="object">Acme\Shop\Activity\OrderActivities</item>
        </argument>
    </arguments>
</type>