search
HomeBackend DevelopmentPHP TutorialHow to develop seata-php? Brief analysis of development guide

How to develop seata-php? This article will talk about the seata-php development guide and explain some pre-requisite knowledge. I hope it will be helpful to you!

How to develop seata-php? Brief analysis of development guide

This article mainly hopes to help everyone participate in the development of seata/seata-php, and provide some explanations of pre-requisite knowledge .

seata/seata-php is currently a distributed transaction component package developed based on the hyperf framework and is compatible with swoole and swow Two coroutine extensions, I hope that subsequent developers can also consider compatibility with these two coroutine extensions

Pre-requisite knowledge

I hope that everyone must understand the following things before participating in seata/seata-php development

  • seata

  • ##hyperf development documentation

  • ##swoole documentation
  • swow
##How to start the project

First We need to find a file directory to download the code
# 根据自己实际情况来创建目录
mkdir ./seata-dev
Next enter our directory

# 根据自己实际情况来创建目录
cd ./seata-dev

We will clone seata/seata-php

# 根据自己实际情况来创建目录
git clone git@github.com:seata/seata-php.git

Next Depending on whether you are using swoole or swow, execute the following commands to create a framework project, along with a hyperf project creation document hyperf

# swoole
composer create-project hyperf/hyperf-skeleton 

# swow
composer create-project hyperf/swow-skeleton

# 使用 swow 扩展建议使用 hyperf3.0 版本
composer create-project hyperf/swow-skeleton:dev-master

The next step is to enter the project and download the

clone

The

seata/seata-php

is loaded into the projectFirst we need to modify the composer.json file in the project and add the following content

{
    "require": {
        "hyperf/seata": "dev-master"
    },
    "repositories": {
        "seata": {
            "type": "path",
            "url": "../seata-php"
        }
    }
}

Finally, execute composer update -o in the directory and project directory.

And use the command php bin/hyperf.php vendor:publis hyperf/seata Publish the seata configuration file

Finally use php bin/hyperf.php start Start the project

Finally, interested friends can also learn more about hyperf Documents related to component package development

Component Development Guide
  • ConfigProvider Mechanism
seata -When was php started?

Finally, let me explain to you how the seata/seata-php

project was started

We can take a look at the code link of Hyperf\Seata\Listener\InitListener

in the
seata/seata-php

project:InitListener<pre class="brush:php;toolbar:false">&lt;?php declare(strict_types=1); /** * This file is part of Hyperf. * * @link https://www.hyperf.io * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LIC */ namespace Hyperf\Seata\Listener; use Hyperf\DbConnection\Db; use Hyperf\Event\Contract\ListenerInterface; use Hyperf\Framework\Event\MainWorkerStart; use Hyperf\Seata\Annotation\GlobalTransactionScanner; use Hyperf\Seata\Rm\DataSource\DataSourceProxy; use Hyperf\Server\Event\MainCoroutineServerStart; class InitListener implements ListenerInterface { protected GlobalTransactionScanner $globalTransactionScanner; protected DataSourceProxy $dataSourceProxy; public function __construct(GlobalTransactionScanner $globalTransactionScanner, DataSourceProxy $dataSourceProxy) { $this-&gt;globalTransactionScanner = $globalTransactionScanner;         $this-&gt;dataSourceProxy = $dataSourceProxy;     }     public function listen(): array     {         // 我们这里监听了下面两个事件,在 server 启动时候,则开始执行该监听器         return [             MainCoroutineServerStart::class,             MainWorkerStart::class,         ];     }     public function process(object $event)     {         // Execute any sql to init the database connection         Db::select('select 1');         // Init TM and RM clients         // 这里则是开始初始化 TM 和 RM 的客户端         $this-&gt;globalTransactionScanner-&gt;initClients();     } }</pre>At the end Let’s take a look at the life cycle document of hyperf

hyperf-life cycle event

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to develop seata-php? Brief analysis of development guide. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:learnku. If there is any infringement, please contact admin@php.cn delete
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools