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で tarballを実装してみる
Search
higaki
August 22, 2026
42
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHPで tarballを実装してみる
https://phpstudy.connpass.com/event/401438/
https://github.com/higaki-takanori/php-tar
higaki
August 22, 2026
More Decks by higaki
See All by higaki
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
420
PHPで TLSのプロトコルを実装してみる
higaki_program
0
940
PHPでResult型を なるべく使いやすい形で実装する
higaki_program
2
450
PHPでResult型やってみよう
higaki_program
1
800
aspidaで型安全にREST APIのバックエンドを呼び出したい
higaki_program
0
830
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
6.1k
Balancing Empowerment & Direction
lara
6
1.3k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
320
Facilitating Awesome Meetings
lara
57
7.2k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
The Pragmatic Product Professional
lauravandoore
37
7.5k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
550
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
4 Signs Your Business is Dying
shpigford
187
23k
Paper Plane
katiecoart
PRO
5
54k
Transcript
PHPで tarballを実装してみる 第190回 PHP勉強会@東京 ひがき いいことあるかも〜
なぜ? https://zenn.dev/levtech/articles/docker-build
なぜ?
なぜ? 急にアーカイブファイルって使ったけどなんも知らんかも、、、 ずっと胸にあった「もやもや 」を解消するため あと ファイルを複数まとめるって何??よくわからんですな👣
話すこと ①tarballについて ②PHP実装 ③何が嬉しいの?
tarballとは Tarball may refer to: Tarball (computing), a tar archive
file 引用:Wikipedia[https://en.wikipedia.org/wiki/Tarball] tar(ター、tape archives)はファイルアーカイブのファイルフォーマットの一種である。 このファイルフォーマットを処理する同名の UNIXコマンドtarも指す。 UNIXでは圧縮した tar形式のファイルを "tarball"(ターボール)と呼ぶこともある。 引用:Wikipedia[https://ja.wikipedia.org/wiki/Tar]
アーカイブファイルとは アーカイブ(英: archive)とはコンピュータにおいてデータ群を纏めて一体で保 存することを指す[1][2]。データと、ファイル作成日時や作成者などの付随するメ タデータを関連づけ長期間保存する目的で用いられる。 引用 :Wikipedia[https://ja.wikipedia.org/wiki/%E3%82%A2%E3%83%BC%E3%82%AB%E3%82%A4%E3%83%96_(% E3%82%B3%E3%83%B3%E3%83%94%E3%83%A5%E3%83%BC%E3%82%BF)]
つまり、tarballって 複数ファイルをいい感じにまとめて保存されたものってことね まとめる形式は色々あるけど、その一種ってことか〜 圧縮後もtarballって言ったりするのね〜 $ tar xvf sample.tar // tarball
→ 複数ファイル 展開 $ tar cvf sample.tar files // 複数ファイル → tarball 作成
こんな認識になった なんか、いい感じに複数ファイルをまとめてくれている 圧縮するときに使ったりしてるっぽいな こんな感じー?? 複数のファイル → ファイルアーカイブ → 圧縮後ファイル
こんな認識になった なんか、いい感じに複数ファイルをまとめてくれている 圧縮するときに使ったりしてるっぽいな こんな感じー?? 複数のファイル → ファイルアーカイブ → 圧縮後ファイル ☝本発表のスコープ
☝スコープ外
tarって100色あんねん
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
tarballの種類 • • • • • • • • v7(Old-Style
Archive Format) Pre-POSIX Archives POSIX ustar Archives Pax Interchange Format GNU Tar Archives GNU tar pax archives Mac OS X Tar …
ヘッダーの作り方など 様々ある 引用:techplus [https://ja.wikipedia.org/wiki/Tar]
アーカイブする 「ヘッダー・ブロック」の作り 方など様々ある 引用:techplus [https://ja.wikipedia.org/wiki/Tar]
どのtarball作ったの? 基本はv7をベースにしつつ、tar コマンドで動くもの 完璧じゃなくてまずは動くものを実装した アーカイブファイル → 複数ファイル に展開するのは作っていない
ソースコード見ていきますか〜 の前に
工夫点 • 空白・ゼロ埋めが多いので、共通機構を作った • 各プロパティごとにクラスを実装した • タプルがいい感じに使えないのでクラスでいい感じにした Link の部分
個人的にふむふむと思った部分 • チェックサムの部分の計算が大変だった ヘッダーの中にチェックサムがあり、ゴニョゴニョ計算して導く • 10進数 → 8進数に変換してtarにしているのがいまだに疑問 mode(ファイルの所有権、755とかのやつ)が8進数になるからそれに 合わせているのかなー
ではでは ソースコード見ていきますか〜
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:techplus [https://ja.wikipedia.org/wiki/Tar]
引用:Docker-docs-ja [https://docs.docker.jp/engine/reference/commandline/save.html]
自己紹介
自己紹介 ひがき 株式会社リンケージ 🍊PHPConference愛媛2026 実行委員長🐘 PHPConference愛媛2026開催!! • 2026年10月3日 • 愛媛大学
城北キャンパス
ご静聴ありがとうございました
Appendinx
https://github.com/higaki-takanori/php-tar