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
XHPをはじめよう
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
shirotter
April 20, 2018
Programming
0
270
XHPをはじめよう
Getting started with XHP
HHVM/Hack勉強会 vol.1 LT@2018/4/20
shirotter
April 20, 2018
Tweet
Share
Other Decks in Programming
See All in Programming
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
CSC307 Lecture 10
javiergs
PRO
1
660
Oxlintはいいぞ
yug1224
5
1.3k
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
並行開発のためのコードレビュー
miyukiw
0
280
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
190
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
110
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
310
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
290
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
650
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
21
7.3k
Grafana:建立系統全知視角的捷徑
blueswen
0
330
Featured
See All Featured
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
130
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Statistics for Hackers
jakevdp
799
230k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
Building AI with AI
inesmontani
PRO
1
700
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
So, you think you're a good person
axbom
PRO
2
1.9k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
150
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
55
Transcript
XHP をはじめよう HHVM/Hack 勉強会 vol.1 LT 枠@2018-4-20
自己紹介 Masaru Shiraishi istyle.inc 昔は海上自衛隊で船乗ってました
みなさんHack やってますか?
一緒にXHP も使ってますか?
XHP Facebook で開発されたPHP/Hack 拡張のHTML テンプレー トエンジンの ようなもの。 (XML ベー スの)HTML
構文がPHP/Hack の式として評価されるため、 HTML そのものをオブジェクトとして扱うことが出来たり、 再利用が可 能になります。 Hack の利点であるTypechecker での厳密なチェックが有効になるのも特 徴の一つです。 JavaScript ライブラリのReact のベー スにもなっています。
とりあえず見た方が早い!!
XHP を使わない実装 <?hh $href = urlencode("http://...."); echo "<a href='${href}'>Hello World</a>";
XHP を使った実装 <?hh $href = "http://...."; $xhp = <a href={$href}>Hello World<a>; echo $xhp;
XHP を使わない実装 <?hh $href = urlencode("http://...."); echo "<a href='${href}'>Hello World</a>";
XHP を使った実装 <?hh $href = "http://...."; $xhp = <a href={$href}>Hello World<a>; echo $xhp; ※ HTML が文字列ではないことに注目!!
XHP の特徴 HTML 要素を文字列ではなく、 オブジェクトとして扱える HTML やその属性のエスケー プ処理(XSS 対策) が自動
XML がベー スなので仕様が厳格 閉じタグ必須 HTML 要素のネストの誤りはエラー Hack ではTypechecker でのエラー 検出が可能
もっと知りたい方はドキュメントを見てください!! https://docs.hhvm.com/hack/XHP/introduction
今日はXHP をやってみたら見えてきた壁を さらっと紹介します
ひと手間が必要になる壁
そのままではCustome Elements が使えない XHP にはHTML の一般的なタグしか実装されていません。 そのため、Custom Elements を使うとコンパイルエラー になります。
<!-- "-" を含めなくてはならない命名規則がある --> <link rel="import" href="../custom-elements.html"> <custom-tag active></custom-tag> Custom Elements とは HTML の新しい型を定義できるWeb Components の機能。 “ “
解決するには 自分でXHP クラスを実装する必要があります。 <?hh // strict class :custom-tag extends :xhp:html-element
{ children empty; category %flow; attribute bool active; protected string $tagName = 'custom-tag'; } ※ 正確にはchildren empty; の要素は:xhp:html-singleton をextends するのが正しい
これからぶつかるかもしれない壁
デザイナー との協業が難しそう Hack のコー ドと混ざってしまう。 public function render(string $name): \XHPRoot
{ return ( <div class="hello-name"> <p>Hello {$name}</p> </div> ); } 社内ツー ルの実装なので今はまだデザイナー 不在でやってますが....
コンクリー トよりも堅い壁
何よりもXHP の情報が少ない!!
ほぼこの情報だけで頑張ってます... HHVM/Hack リファレンス https://docs.hhvm.com/hack/XHP/introduction XHP のソー スコー ド https://github.com/hhvm/xhp-lib XHP
Bootstrap のソー スコー ド https://github.com/fbsamples/xhp-bootstrap
ということで...
みなさん一緒にXHP やりましょう!!
ご静聴ありがとうございました