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
1.4k
PHP Internals わいわい #1 の資料
event:
https://phpinternals-waiwai.connpass.com/event/320134/
今日やる範囲を資料にしました
てきめん tekimen
PRO
June 03, 2024
Tweet
Share
More Decks by てきめん tekimen
See All by てきめん tekimen
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
200
PHP Internals わいわい #3 mb_*関数を作ってみよう
youkidearitai
PRO
0
110
Windows版php-srcデバッグ方法
youkidearitai
PRO
1
85
mb_trim関数を作りました
youkidearitai
PRO
1
1.1k
PHPの次期バージョンはこの時期どうなっているのか - Internalsの開発体制について - PHPカンファレンス小田原
youkidearitai
PRO
1
920
文字とはなにか - PHPの文字コード処理について - PHP Lovers Meetup #5
youkidearitai
PRO
1
320
はじめてのOSSコントリビュート
youkidearitai
PRO
11
4.7k
文字とはなにか - PHPの文字コード処理について -
youkidearitai
PRO
0
1.5k
現在のmbstringの立ち位置 これからどうなっていくのか
youkidearitai
PRO
0
500
Other Decks in Programming
See All in Programming
AI駆動開発ライフサイクル(AI-DLC)のホワイトペーパーを解説
swxhariu5
0
1.4k
複数チーム並行開発下でのコード移行アプローチ ~手動 Codemod から「生成AI 活用」への進化
andpad
0
180
レイトレZ世代に捧ぐ、今からレイトレを始めるための小径
ichi_raven
0
460
AIエージェントでのJava開発がはかどるMCPをAIを使って開発してみた / java mcp for jjug
kishida
4
770
Web エンジニアが JavaScript で AI Agent を作る / JSConf JP 2025 sponsor session
izumin5210
4
2k
Honoを技術選定したAI要件定義プラットフォームAcsimでの意思決定
codenote
0
260
知られているようで知られていない JavaScriptの仕様 4選
syumai
0
630
Level up your Gemini CLI - D&D Style!
palladius
1
110
AIを駆使して新しい技術を効率的に理解する方法
nogu66
1
660
Building AI with AI
inesmontani
PRO
1
260
TypeScriptで設計する 堅牢さとUXを両立した非同期ワークフローの実現
moeka__c
5
2.2k
Evolving NEWT’s TypeScript Backend for the AI-Driven Era
xpromx
0
180
Featured
See All Featured
Building Applications with DynamoDB
mza
96
6.8k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Six Lessons from altMBA
skipperchong
29
4.1k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Music & Morning Musume
bryan
46
7k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
Faster Mobile Websites
deanohume
310
31k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
680
Building Adaptive Systems
keathley
44
2.8k
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に従いましょう • レッツコントリビュート! • これだけじゃ厳しいのはわかってるのであとはよし なに