Swoft is a PHP high performance microservice co-routine framework. It has been published for many years and has become the best choice for php. It can be like Go, built-in co-routine web server and common co-routine client and is resident in memory, independent of traditional PHP-FPM. There are similar Go language operations, similar to the Spring Cloud framework flexible annotations. Github https://github.com/swoft-cloud/swoft Feature Full Co-routine Framework Swoft is first PHP resident in memory annotation framework, with Spring Boot conventions larger than the configuration design concept, with a set of development specifications. AOP AOP is an object oriented programming that makes it easier to decouple business code, improve code quality, and increase code reusability. { $start; { ->start = microtime( ); } { $method = $joinPoint->getMethod(); $after = microtime( ); $runtime = ($after - ->start) * ; ; } } /** * (order=1) * (include={"App\Http\Controller\TestExecTimeController"}) */ @Aspect @PointBean class CalcExecTimeAspect protected /** * () */ @Before public function before () $this true /** * () */ @After public function after (JoinPoint $joinPoint) true $this 1000 echo "{$method} cost: {$runtime}ms\n" Http Service Http service is simple and flexible, only to use @Controller() and @RequestMapping(route="index") annotations to define service. { { ; } } /** * () */ @Controller class IndexController /** * (route="index") */ @RequestMapping public : function index () string return "test" WebSocket service Swoft provides a complete Websocket for developers to quickly build service { { server()->push($request->getFd(), ); } } /** * ( * "/chat", * messageParser=TokenTextParser::class, * controllers={HomeController::class} * ) */ @WsModule class ChatModule /** * () * Request $request * int $fd */ @OnOpen @param @param public : function onOpen (Request $request, int $fd) void "Opened, welcome!(FD: $fd)" RPC Service Swoft RPC can be called like a native function as Dubbo. { $userService; { $result = ->userService->getList( , ); [$result]; } } /** * () */ @Controller class RpcController /** * (pool="user.pool", version="1.0") * * UserInterface */ @Reference @var private /** * ("getList") * * array */ @RequestMapping @return public : function getList () array $this 12 'type' return TCP Service Swoft also provides feature-rich TCP service support. (strict_types= ); \ \ ; \ \ \ \ \ ; \ \ \ \ \ ; \ \ \ ; \ \ \ ; { { $str = $request->getPackage()->getDataString(); $response->setData( . $str); } } <?php declare 1 namespace App Tcp Controller use Swoft Tcp Server Annotation Mapping TcpController use Swoft Tcp Server Annotation Mapping TcpMapping use Swoft Tcp Server Request use Swoft Tcp Server Response /** * Class DemoController * * () */ @TcpController class DemoController /** * ("echo", root=true) * Request $request * Response $response */ @TcpMapping @param @param public : function echo (Request $request, Response $response) void // $str = $request->getRawData(); '[echo]hi, we received your message: ' Connection pool Swoft is simple to define a high-performance connection pool with like this: [ => [ => \Swoft\xxx\Pool::class, => , => , => , => , => , ] ]; return 'xxx.pool' 'class' 'minActive' 10 'maxActive' 20 'maxWait' 0 'maxWaitTime' 0 'maxIdleTime' 60 Compatible with Laravel ORM Swoft database is highly compatible with Laravel ORM, It’s easy for PHP developer to use in Swoft. $user = User::new(); $user->setName( ); $user->setSex( ); $user->setDesc( ); $user->setAge(mt_rand( , )); $user->save(); $id = $user->getId(); $users = DB::table( )->get(); ($users $user) { $user->name; } DB::beginTransaction(); $user = User::find($id); $user->update([ => $id]); DB::beginTransaction(); User::find($id)->update([ => ]); DB::rollBack(); DB::commit(); // Model 'name' 1 'this my desc' 1 100 // Query 'user' foreach as echo // Transaction 'name' 'name' 'sakuraovq' Microservice Swoft provides a set of quick build microservice governance components, it’s easy for developers to use. Service Registration and DiscoveryService BrokerCentralized ConfigurationService Throttling ability { { ( ); } { $uri = $request->getUriPath(); [ , $uri]; } } /** * () */ @Bean class Test /** * (fallback="funcFallback") * * string * Exception */ @Breaker @return @throws public : function func () string // Do something throw new Exception 'Breaker exception' /** * () * (key="request.getUriPath()") * * Request $request * * array */ @RequestMapping @RateLimiter @param @return public : function requestLimiter (Request $request) array return 'requestLimiter' Github https://github.com/swoft-cloud/swoft