Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PHP Internals わいわい #1 の資料
Search
てきめん tekimen
PRO
June 03, 2024
Programming
1.6k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHP Internals わいわい #1 の資料
event:
https://phpinternals-waiwai.connpass.com/event/320134/
今日やる範囲を資料にしました
てきめん tekimen
PRO
June 03, 2024
More Decks by てきめん tekimen
See All by てきめん tekimen
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
700
ChatGPTを使ってRaspberry Pi Picoの処理系を書いた
youkidearitai
PRO
0
88
PHP Internals わいわい #3 PIEを使ってみよう
youkidearitai
PRO
0
61
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
320
Limit of code point for grapheme cluster in programming language side.
youkidearitai
PRO
0
84
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
2
3.5k
PHP 8.5の裏話
youkidearitai
PRO
0
150
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
330
PHP Internals わいわい #3 mb_*関数を作ってみよう
youkidearitai
PRO
0
160
Other Decks in Programming
See All in Programming
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
350
さぁV100、メモリをお食べ・・・
nilpe
0
140
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
190
Inside Stream API
skrb
1
730
A2UI という光を覗いてみる
satohjohn
1
140
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
140
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
270
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
The NotImplementedError Problem in Ruby
koic
1
810
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.4k
ふつうのFeature Flag実践入門
irof
7
4k
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
A designer walks into a library…
pauljervisheath
211
24k
How to train your dragon (web standard)
notwaldorf
97
6.7k
Making Projects Easy
brettharned
120
6.7k
HDC tutorial
michielstock
2
720
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
190
Discover your Explorer Soul
emna__ayadi
2
1.1k
WENDY [Excerpt]
tessaabrams
11
38k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Code Review Best Practice
trishagee
74
20k
The Invisible Side of Design
smashingmag
302
52k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Transcript
PHP Internals わいわい
自己紹介 てきめん • https://tekitoh-memdhoi.info • X: @youkidearitai • https://github.com/youkidearit ai
• PHP 8.4で複数の関数を作りました – mb_trim, mb_ltrim, mb_rtrim – mb_ucfirst, mb_lcfirst – grapheme_str_split オレ
趣旨 • PHP Internals Bookを元に、PHPのソースコード、php-srcを取得、コンパ イルしたりソースコードを読みます – https://www.phpinternalsbook.com/ – あわよくばバグを見つけたら報告したり
– あわよくばテストコードを修正したり – 更に行けば関数・機能を追加するとか • PHP Internalに向かって新機能を追加する提案をしたりできないかと思っ ています
コンパイルの前段階 • Linuxを用意します • 今回はDockerを使います – WSLやmultipass、limaなどを使ってもらっても構いま せん
PHPのコンパイルの準備 > docker pull ubuntu:22.04 > docker run -it ubuntu:22.04
bash # apt update && apt install -y pkg-config build-essential autoconf bison re2c libxml2-dev libsqlite3-dev gdb git libonig- dev # cd ~ # /root # git clone https://github.com/php/php-src
PHPのコンパイルの準備 # cd php-src # ./buildconf -f # ./configure --enable-debug
--enable-mbstring # make # make test # make install # --prefix を指定していないので/usr/local/に入る # php -v #これで実行できる!
この状態を保存します • Command + p + qで抜けるか、もしくは別のコン ソールを開いてください • >
docker ps で開いているContainer IDを調べます • > docker commit [container id] ubuntu:php84 – このようにすればubuntu:php84で今までの作業した内 容を保存して、コンパイルできた状態で入れます
このようにコンテナを作れました > docker run -it ubuntu:php84 root@ea6b72b5f128:/# php -v PHP
8.4.0-dev (cli) (built: May 31 2024 00:57:46) (NTS DEBUG) Copyright (c) The PHP Group Zend Engine v4.4.0-dev, Copyright (c) Zend Technologies
tips • 今回はDockerを使いましたが、LinuxやmacOS内 部で複数のPHPを持ちたいときは --prefix オプ ションが便利です。 – --prefix=$HOME/php84 とかしてあげると、ホームディ
レクトリ配下にバージョンごとにコンパイル・インストー ルができるわけです。
デバッグ手法 • Linuxではgdbとかlldbなどが使えますが、今回はgdbを使い ます • コンテナ内部でvimとctagsなどを利用してソースコードを読み ます – 手元でコンパイルできるとVisual Studio
Codeがつかえたりするよ うですね • https://php.github.io/php-src/introduction/ides/visual-studio-code.h tml – このあたり知ってる人は共有してくれると嬉しい
開発環境を揃える # apt install exuberant-ctags vim # cd ~/php-src #
ctags -R . # カレントディレクトリが/root/php-src
コンパイルオプションあれこれ 変数 CC をつけるとコンパイラを指定できます 変数 CFLAGS でコンパイルオプションを指定できま す 例: CC=clang
CFLAGS=”-g” ./configure –enable- debug # clangでコンパイルし、-gオプションを加え られます
テストについて https://www.phpinternalsbook.com/tests/runn ing_the_test_suite.html # sapi/cli/php run-tests.php # すべてのテストを行 う #
sapi/cli/php run-tests.php -P ext/mbstring # mbstring拡張のみテストする
テストファイルについて https://www.phpinternalsbook.com/tests/phpt _file_structure.html .phptファイルを使ってテストを行います
あとはPHP Internals Bookに従いましょう • レッツコントリビュート! • これだけじゃ厳しいのはわかってるのであとはよし なに