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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
てきめん tekimen
PRO
June 03, 2024
Programming
1.6k
1
Share
PHP Internals わいわい #1 の資料
event:
https://phpinternals-waiwai.connpass.com/event/320134/
今日やる範囲を資料にしました
てきめん tekimen
PRO
June 03, 2024
More Decks by てきめん tekimen
See All by てきめん tekimen
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
260
Limit of code point for grapheme cluster in programming language side.
youkidearitai
PRO
0
64
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
2
3.2k
PHP 8.5の裏話
youkidearitai
PRO
0
130
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
290
PHP Internals わいわい #3 mb_*関数を作ってみよう
youkidearitai
PRO
0
150
Windows版php-srcデバッグ方法
youkidearitai
PRO
1
120
mb_trim関数を作りました
youkidearitai
PRO
1
1.4k
PHPの次期バージョンはこの時期どうなっているのか - Internalsの開発体制について - PHPカンファレンス小田原
youkidearitai
PRO
1
1.1k
Other Decks in Programming
See All in Programming
Back to the roots of date
jinroq
0
100
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
2
180
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
340
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
140
iOS機能開発のAI環境と起きた変化
ryunakayama
0
180
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
340
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
3
160
ドメインイベントでビジネスロジックを解きほぐす #phpcon_odawara
kajitack
3
780
事業会社でのセキュリティ長期インターンについて
masachikaura
0
250
Don't Prompt Harder, Structure Better
kitasuke
0
770
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
970
tRPCの概要と少しだけパフォーマンス
misoton665
2
210
Featured
See All Featured
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Why Our Code Smells
bkeepers
PRO
340
58k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
The Limits of Empathy - UXLibs8
cassininazir
1
300
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
350
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.4k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
480
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
180
A Soul's Torment
seathinner
6
2.7k
Code Reviewing Like a Champion
maltzj
528
40k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
180
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に従いましょう • レッツコントリビュート! • これだけじゃ厳しいのはわかってるのであとはよし なに