$30 off During Our Annual Pro Sale. View Details »

PHP8版!Swooleのフレームワークを比べてみた

 PHP8版!Swooleのフレームワークを比べてみた

PHPerKaigi2021の発表資料です

PHPerKaigi2019でお話しした内容( https://fortee.jp/phperkaigi-2019/proposal/61b5c154-7b53-4d78-820a-cf328f6d3360 )を
PHP8の環境で、再度検証してみた話をお伝えします
さらに、Swooleを用いたフレームワークでもっともGitHubの更新頻度が高い
Hyperfを加えて、4種類のフレームワークをくらべてみます
そもそも、PHP8のJITはどれだけSwooleに有利に働くのでしょうか?
PHP8の環境における、No.1 Swooleフレームワークはどれだ!

CyberAgent SGE Engineer

March 27, 2021
Tweet

More Decks by CyberAgent SGE Engineer

Other Decks in Programming

Transcript

  1. • גࣜձࣾαΠόʔΤʔδΣϯτ • 4(&౷ׅຊ෦ٕज़౷ׅࣨࣨ௕ • ࢠձࣾࣾ$50 • גࣜձࣾ$SBGU&HH • גࣜձࣾαϜβοϓ

    • നҪɹӳ • ΤϯδχΞ • #MPH IUUQBNFCMPKQHPPEPP ͓લɺ୭Α • 5XJUUFS !HPPEPP • %2 ͙ͪ͢Ή '#  
 ϓΫϦϙ ཱྀܳਓ
  2. )ZQFSGͷϑΥϧμߏ੒ ࠷খݶ Projec t ! appɹɹɹɹɹɹɹɹ "ɹ! Controller s "ɹ"ɹ!

    AbstractController.ph p "ɹ"ɹ# BooksController.ph p "ɹ! Model s "ɹ"ɹ# Books.ph p "ɹ! Exceptio n "ɹ# Listene r ! confi g "ɹ! config.ph p "ɹ# routes.ph p ! publi c ! runtim e "ɹ! log s "ɹ! containe r "ɹ# sessio n ! storag e "ɹ# view s "ɹɹɹ# index.twi g # bi n ɹɹ# hyperf.ph p  )ZQFSG
  3. • Built-in high performance network server(Http/Websocket/RPC/TCP ) • Flexible componentizatio

    n • Flexible annotation functio n • Diversi fi ed command terminal(Console ) • Powerful Aspect Oriented ProgrammingʢAOPʣ • Perfect Container management, Dependency Injection (DI ) • Flexible event mechanis m • Implementation of HTTP message based on PSR- 7 • Event Manager Based on PSR-1 4 • Middleware based on PSR-1 5 • Internationalization(i18n) suppor t • Simple and ef fi cient parameter validato r •High performance connection pool(Mysql/Redis/RPC)ɼAutomatic reconnectio n •Database is highly compatible Larave l •Cache Redis highly compatible Larave l •Ef fi cient task processin g •Ef fi cient seconds cronta b •Process poo l •Flexible exception handlin g •Powerful log syste m •Service registration & discover y •Service breake r •Service restriction s •Service fallbac k •Con fi guration Cente r •Apoll o •Consul https://github.com/swoft-cloud/swoft ͷREADME Ҿ༻ɿ  4XPGU
  4. •Built-in high performance network serve r •Flexible annotation functio n

    •Powerful Aspect Oriented ProgrammingʢAOPʣ •Perfect Container management, Dependency Injection (DI ) •Implementation of HTTP message based on PSR- 7 •Middleware based on PSR-1 5 •High performance connection pool(Mysql/Redis/RPC)ɼ Automatic reconnectio n •Database is highly compatible Larave l •Cache Redis highly compatible Larave l ಛ௃  4XPGU
  5. 4XPGUͷϑΥϧμߏ੒ ࠷খݶ Projec t ! appɹɹɹɹɹɹɹɹ "ɹ! Controller s "ɹ"ɹ#

    BooksController.ph p "ɹ! Model s "ɹ"ɹ# Entit y "ɹ"ɹ # Books.php "ɹ# bean.ph p ! publi c ! runtim e "ɹ! log s "ɹ! cache s "ɹ# session s ! resource s "ɹ# view s "ɹɹɹ# book s "ɹɹɹɹɹ# view.ph p # bi n ɹɹ! bootstrap.ph p ɹɹ# swoft  4XPGU
  6. w "OOPUBUJPOͷॻ͕ࣜҰ෦มΘͬͨ 
 3FRVFTU.BQQJOHͷNFUIPEͷࢦఆ  w %#Ϋϥεͷվળ 
 4XPGUa%Ca%# 

    w 4FTTJPOΫϥεͷվળ 
 4XPGUa)UUQa4FTTJPOa)UUQ4FTTJPO  4XPGU Wͷؾ͍ͮͨมߋ఺
  7. ಛ௃  &BTZ4XPPMF •Built-in HTTP, TCP, WebSocket,Udp Coroutine Serve r

    •Global dependency injection containe r •PSR-7 based HTTP message implementatio n •RESTful supporte d •HTTP,TCP, WebSocket, Udp middleware suppor t •Mysql, Redis, RPC, HTTP Coroutine Client s •High performance route r •Universal connection pool s •Remote Console support W
  8. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Projec t ! Appɹɹɹɹɹɹɹɹ "ɹ! HttpControlle r "ɹ"ɹ!

    BooksController.ph p "ɹ"ɹ# Router.ph p "ɹ! Mode l "ɹ"ɹ# BookModel.ph p "ɹ# Utilit y "ɹɹɹ# Poo l "ɹɹɹɹɹ# MysqlObject.ph p ! EasySwooleEvent.ph p ! View s "ɹ# index.twi g ! Lo g ! Tem p ! vendo r ! Stati c "ɹ! cs s "ɹ# j s ! easyswool e ! produce.ph p # dev.php  &BTZ4XPPMF
  9.  4XPPMF༻ͷDPO fi Hੜ੒  -BSBWFM4XPPMF $ php artisan vendor:publish

    --tag=laravel-swoole  DPO fi HTXPPMF@IUUQQIQΛઃఆ
  10.  ىಈ  -BSBWFM4XPPMF $ php artisan swoole:http start ॳظઃఆͩͱ൪ϙʔτͰ଴ͪड͚·͢

     OHJOYͷઃఆ proxy_pass http://127.0.0.1:1215 QSPYZ@QBTTͰઃఆ͠·͢ https://github.com/swooletw/laravel-swoole/wiki
  11. %FGBVMU 4MJN )ZQFSG W 4XPGU W &BTZ4XPPMF W -BSBWFM W

    -BSBWFM 4XPPMF ճ໨       ̎ճ໨       ճ໨       ճ໨       ̑ճ໨       ճ໨       ճ໨       ճͷฏۉ        1)14XPPMF
  12. %FGBVMU 4MJN )ZQFSG W 4XPGU W &BTZ4XPPMF W -BSBWFM W

    -BSBWFM 4XPPMF ճ໨       ̎ճ໨       ճ໨       ճ໨       ̑ճ໨       ճ໨       ճ໨       ճͷฏۉ        1)1 +*5PGG 4XPPMF
  13. %FGBVMU 4MJN )ZQFSG W 4XPGU W &BTZ4XPPMF W -BSBWFM W

    -BSBWFM 4XPPMF ճ໨       ̎ճ໨       ճ໨       ճ໨       ̑ճ໨       ճ໨       ճ໨       ճͷฏۉ        1)1 +*5PO 4XPPMF
  14. %FGBVMU 4MJN )ZQFSG W 4XPGU W &BTZ4XPPMF W -BSBWFM W

    -BSBWFM 4XPPMF 1)1       1)1 +*5PGG       1)1 +*5PO       ؀ڥ͝ͱͷൺֱ
  15. %FGBVMU 4MJN )ZQFSG W 4XPGU W &BTZ4XPPMF W -BSBWFM W

    -BSBWFM 4XPPMF 1)1       1)1 +*5PGG       1)1 +*5PO       ؀ڥ͝ͱͷൺֱ ≒ ≒ ≒ ≒ ≒ ≒ ≒ ≒ 61 61