
Swoft هو إطار PHOTO microservice عالي الأداء. تم نشره لسنوات عديدة وأصبح الخيار الأفضل لـ php. يمكن أن يكون مثل Go ، خادم الويب coroutine المدمج والعميل coroutine المشترك ويقيم في الذاكرة ، مستقلة عن PHP-FPM التقليدية. هناك عمليات مماثلة للغة Go ، مشابهة للشروح المرنة لإطار Spring Cloud.
جيثب
https://github.com/swoft-cloud/swoft
ميزة
إطار coroutine الكامل
Swoft هو أول مقيم في PHP في إطار التعليق التوضيحي للذاكرة ، مع اصطلاحات Spring Boot أكبر من مفهوم تصميم التهيئة ، مع مجموعة من مواصفات التطوير.
اوب
AOP عبارة عن برمجة موجهة للكائنات تسهل فك شفرة العمل ، وتحسين جودة الشفرة ، وزيادة إمكانية إعادة استخدام الشفرة.
class CalcExecTimeAspect { protected $start; public function before() { $this->start = microtime(true); } public function after(JoinPoint $joinPoint) { $method = $joinPoint->getMethod(); $after = microtime(true); $runtime = ($after - $this->start) * 1000; echo "{$method} cost: {$runtime}ms\n"; } }
خدمة المتشعب
خدمة Http بسيطة ومرنة ، فقط لاستخدام @Controller()
و @RequestMapping(route="index")
لتحديد الخدمة。
class IndexController { public function index(): string { return "test"; } }
خدمة websocket
يوفر Swoft Websocket كاملة للمطورين لبناء الخدمة بسرعة
class ChatModule { public function onOpen(Request $request, int $fd): void { server()->push($request->getFd(), "Opened, welcome!(FD: $fd)"); } }
خدمة RPC
يمكن استدعاء Swoft RPC مثل وظيفة أصلية مثل Dubbo.
class RpcController { private $userService; public function getList(): array { $result = $this->userService->getList(12, 'type'); return [$result]; } }
خدمة TCP
يوفر Swoft أيضًا خدمة دعم TCP غنية بالميزات.
<?php declare(strict_types=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 { public function echo(Request $request, Response $response): void {
تجمع اتصال
Swoft بسيط لتعريف تجمع اتصال عالي الأداء بمثل هذا:
return [ 'xxx.pool' => [ 'class' => \Swoft\xxx\Pool::class, 'minActive' => 10, 'maxActive' => 20, 'maxWait' => 0, 'maxWaitTime' => 0, 'maxIdleTime' => 60, ] ];
متوافق مع Laravel ORM
قاعدة بيانات Swoft متوافقة للغاية مع Laravel ORM ، من السهل على مطور PHP استخدامها في Swoft.
Microservice
يوفر Swoft مجموعة من مكونات حوكمة الخدمات المصغرة سريعة الإنشاء ، ومن السهل على المطورين استخدامها.
- تسجيل الخدمة واكتشافها
- وسيط الخدمة
- التكوين المركزي
- خدمة اختناق القدرة
class Test { public function func(): string {
جيثب
https://github.com/swoft-cloud/swoft
المعيار
