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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
ぼくの開発環境2026
yuzneri
0
240
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
180
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
170
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
380
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
120
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
250
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.4k
Fluid Templating in TYPO3 14
s2b
0
130
Raku Raku Notion 20260128
hareyakayuruyaka
0
330
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
7.4k
Oxlintはいいぞ
yug1224
5
1.3k
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
180
Docker and Python
trallard
47
3.7k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
240
Technical Leadership for Architectural Decision Making
baasie
2
250
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
The untapped power of vector embeddings
frankvandijk
1
1.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
170
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
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 やりましょう!!
ご静聴ありがとうございました