1. Go to this page and download the library: Download vanta/temporal-doctrine 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/ */
vanta / temporal-doctrine example snippets
declare(strict_types=1);
use Sentry\SentrySdk;
use Temporal\Interceptor\SimplePipelineProvider;
use Temporal\WorkerFactory;
use Vanta\Integration\Temporal\Doctrine\Interceptor\SentryDoctrineOpenTransactionInterceptor;
use function Sentry\init;
= $factory->newWorker(
interceptorProvider: new SimplePipelineProvider([
new SentryDoctrineOpenTransactionInterceptor($hub, $client->getStacktraceBuilder()),
])
);
declare(strict_types=1);
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\ORMSetup;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Logger;
use Temporal\Interceptor\SimplePipelineProvider;
use Temporal\WorkerFactory;
use Vanta\Integration\Temporal\Doctrine\Interceptor\PsrLoggingDoctrineOpenTransactionInterceptor;
l::Debug));
$factory = WorkerFactory::create();
$worker = $factory->newWorker(
interceptorProvider: new SimplePipelineProvider([
new PsrLoggingDoctrineOpenTransactionInterceptor($logger, $connection),
])
);
declare(strict_types=1);
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMSetup;
use Doctrine\Persistence\AbstractManagerRegistry as ManagerRegistry;
use Temporal\Interceptor\SimplePipelineProvider;
use Temporal\WorkerFactory;
use Vanta\Integration\Temporal\Doctrine\Finalizer\DoctrineClearEntityManagerFinalizer;
use Vanta\Integration\Temporal\Doctrine\Finalizer\DoctrinePingConnectionFinalizer;
use Vanta\Integration\Temporal\Doctrine\Interceptor\DoctrineHandlerThrowsActivityInboundInterceptor;
$connection, 'default-manager' => $entityManager],
) extends ManagerRegistry {
/**
* @param array<string, string> $connections
* @param array<string, string> $managers
* @phpstan-param class-string $proxyInterfaceName
* @param array<non-empty-string, object> $services
*/
public function __construct(
string $name,
array $connections,
array $managers,
string $defaultConnection,
string $defaultManager,
string $proxyInterfaceName,
private readonly array $services
) {
parent::__construct(
$name,
$connections,
$managers,
$defaultConnection,
$defaultManager,
$proxyInterfaceName
);
}
protected function getService(string $name): object
{
return $this->services[$name] ?? throw new RuntimeException(sprintf('Service "%s" not found', $name));
}
protected function resetService(string $name): void
{
// TODO: Implement resetService() method.
}
};
$doctrinePingConnectionFinalizer = new DoctrinePingConnectionFinalizer($managerRegistry, 'default-manager');
$doctrineClearEntityManagerFinalizer = new DoctrineClearEntityManagerFinalizer($managerRegistry);
$finalizers = [
$doctrinePingConnectionFinalizer,
$doctrineClearEntityManagerFinalizer,
];
$factory = WorkerFactory::create();
$worker = $factory->newWorker(
interceptorProvider: new SimplePipelineProvider([
new DoctrineHandlerThrowsActivityInboundInterceptor($doctrinePingConnectionFinalizer),
])
);
$worker->registerActivityFinalizer(function () use ($finalizers): void {
foreach ($finalizers as $finalizer) {
try {
$finalizer->finalize();
} catch (\Throwable) {
continue;
}
}
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.