Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PHP Internals わいわい #1 の資料
Search
てきめん tekimen
PRO
June 03, 2024
Programming
1.7k
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
980
ChatGPTを使ってRaspberry Pi Picoの処理系を書いた
youkidearitai
PRO
0
110
PHP Internals わいわい #3 PIEを使ってみよう
youkidearitai
PRO
0
85
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
430
Limit of code point for grapheme cluster in programming language side.
youkidearitai
PRO
0
130
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
2
3.9k
PHP 8.5の裏話
youkidearitai
PRO
0
170
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
500
PHP Internals わいわい #3 mb_*関数を作ってみよう
youkidearitai
PRO
0
180
Other Decks in Programming
See All in Programming
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
330
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
330
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
19
20k
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.7k
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
180
Verilogで学ぶCPU自作入門.pdf
uyuki234
7
3.9k
Are APIs Still Relevant in the AI Era?
soyuka
0
380
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
260
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.3k
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1k
カツオ、ご期待ください
suneo3476
0
130
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.7k
Featured
See All Featured
Discover your Explorer Soul
emna__ayadi
2
1.3k
Building the Perfect Custom Keyboard
takai
2
890
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.8k
Ethics towards AI in product and experience design
skipperchong
2
400
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Building Adaptive Systems
keathley
44
3.2k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
710
Bash Introduction
62gerente
615
220k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
540
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
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に従いましょう • レッツコントリビュート! • これだけじゃ厳しいのはわかってるのであとはよし なに