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
XHPをはじめよう
Search
shirotter
April 20, 2018
Programming
280
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
XHPをはじめよう
Getting started with XHP
HHVM/Hack勉強会 vol.1 LT@2018/4/20
shirotter
April 20, 2018
Other Decks in Programming
See All in Programming
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
650
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
360
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
120
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
480
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
490
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
260
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
330
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
270
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
210
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
250
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
630
Heart of Swift Concurrency
koher
0
920
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
My Coaching Mixtape
mlcsv
0
320
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
460
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Raft: Consensus for Rubyists
vanstee
142
7.7k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
850
Being A Developer After 40
akosma
91
590k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
First, design no harm
axbom
PRO
2
1.3k
RailsConf 2023
tenderlove
30
1.6k
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 やりましょう!!
ご静聴ありがとうございました