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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
てきめん 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
PHP Internals わいわい #3 PIEを使ってみよう
youkidearitai
PRO
0
45
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
290
Limit of code point for grapheme cluster in programming language side.
youkidearitai
PRO
0
70
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
2
3.3k
PHP 8.5の裏話
youkidearitai
PRO
0
140
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
300
PHP Internals わいわい #3 mb_*関数を作ってみよう
youkidearitai
PRO
0
160
Windows版php-srcデバッグ方法
youkidearitai
PRO
1
120
mb_trim関数を作りました
youkidearitai
PRO
1
1.4k
Other Decks in Programming
See All in Programming
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
3
780
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
190
Kingdom of the Machine
yui_knk
2
1.5k
Making the RBS Parser Faster
soutaro
0
680
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
170
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
680
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
150
Import assertionsが消えた日~ECMAScriptの仕様はどう決まり、なぜ覆るのか~
bicstone
2
180
サプライチェーン攻撃対策「層を重ねて落ちない壁」を10日間で組み上げた話 #TechLeadConf2026
kashewnuts
1
240
Are We Really Coding 10× Faster with AI?
kohzas
0
150
AlarmKitで明後日起きれるアラームアプリを作る
trickart
0
130
20260514_its_the_context_window_stupid.pdf
heita
0
870
Featured
See All Featured
How GitHub (no longer) Works
holman
316
150k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
440
A Modern Web Designer's Workflow
chriscoyier
698
190k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
790
Music & Morning Musume
bryan
47
7.2k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Automating Front-end Workflow
addyosmani
1370
200k
What's in a price? How to price your products and services
michaelherold
247
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
300
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に従いましょう • レッツコントリビュート! • これだけじゃ厳しいのはわかってるのであとはよし なに