SlideShare a Scribd company logo
@Hiraku
(中野 拓)
   @Hiraku (中野 拓)
    ◦ PHP歴5年ぐらい

    ◦ Zend Framework, Yaf

    ◦ http://blog.tojiru.net/
    ◦ https://github.com/hirak
URL設計の話
   http://example.com/index.php?action=hoge
    とかだとダサい

   短くてCoolなURLにしたい
    http://twitter.com/Hiraku

   しかし短すぎると
    将来の拡張性が…
   SEO対策がどうとか
仕様を読みましょう
他にもURLに関するRFC
                         があるけど、これが最新




RFC3986
http://www.ietf.org/rfc/rfc3986.txt


http://www.studyinghttp.net/rfc_ja/rfc3986
(橋本英彦氏による日本語訳)
{scheme}:{authority}{path}?{query}#{fragment}

http://example.com/a/b/c.php?q=v#foo
{scheme}:{authority}{path}?{query}#{fragment}

http://example.com/a/b/c.php?q=v#foo

固定       ドメイン                  パラメータ的な使い方
        考えるだけ




                    ???
path            =   path-abempty    ;   "/" で始まるか、空
                /   path-absolute   ;   "/" で始まるが、"//" では始まらない
                /   path-noscheme   ;   コロンの無い segment で始まる
                /   path-rootless   ;   segment で始まる
                /   path-empty      ;   文字が無い

path-abempty    =   *( "/" segment )
path-absolute   =   "/" [ segment-nz *( "/" segment ) ]
path-noscheme   =   segment-nz-nc *( "/" segment )
path-rootless   =   segment-nz *( "/" segment )
path-empty      =   0<pchar>

segment       = *pchar
segment-nz    = 1*pchar
segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
              ; non-zero-length segment without any colon ":"

pchar           = unreserved / pct-encoded / sub-delims / ":" / "@
   使ってよい文字
    ◦ 非予約文字(unreserved-character)
     [0-9A-Za-z._~-]

    ◦ %エンコードされた文字

    ◦ 予約文字のうちのsub-delims
     [!$&'()*+,;=]

    ◦ 予約文字のうちのgen-delimsの一部
     [@/:]
0 1 2 3 4 5 6 7 8 9
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
. _ ~ -
! $ & ' ( ) * + , ; =
@ / :
URLに使える文字は
英数字と / だけ
ではない!!
デモ
0 1 2 3 4 5 6 7 8 9
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
. _ ~ -
! $ & ' ( ) * + , ; =
@ / :

            四則演算
           できるよね
   http://calc.tojiru.net/1+2
   http://calc.tojiru.net/2-1
   http://calc.tojiru.net/(1+2)*10/2

   URLとして妥当

   リクエストすると計算結果がtext/plainで返って
    くる
0 1 2 3 4 5 6 7 8 9
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
. _ ~ -
! $ & ' ( ) * + , ; =
@ / :

            PHP!?
   /$a=1;$b=2;echo($a+$b);
   /$a=array(1,2,3);echo(implode(':',$a));

<?php
$code = ltrim($_SERVER['REQUEST_URI'], '/');
eval($code);

$ php -S localhost:8080 index.php

   ローカルで実験しましょうね
   スペースが書けないのでclassやfunctionが無理
   echoは()が必要になる
   []が書けないので添え字アクセスも無理
   "も書けない

   できないところも多い
実践的な話
   縛りプレイ
    ◦ 使っている文字が少なすぎる

    ◦ /と[0-9A-Za-z._-]だけでURL作るとか厳しい

    ◦ /は「階層」の意味合いを感じてしまう
   /map/lat/50/long/20/scale/32000
   こういうURL設計を強要するフレームワーク、
    よくあるよね

    ◦ lat(経度)とlong(緯度)は階層じゃない
    ◦ lat/50とlong/20を入れ替えても動作する方がいい

   /map?lat=50&long=20&scale=32000

    ◦ 入れ替え可能だし階層っぽさは消えた
   Tim Berners-Leeによる提案
    http://www.w3.org/DesignIssues/MatrixURIs.html

   /map;lat=50;long=20;scale=32000

    ◦ セミコロンによるqueryと同等の記述
    ◦ queryを使っていないところに意味がある
   /user;id=123/friends

    ◦ 後ろに階層を続けることができる
    ◦ クエリはURL中一度しか使えないので、
      Matrix URIの方が拡張性高い

    ◦ パスの途中にパラメータを仕込む構文が可能
      →覚えておくと何かと便利
まとめ
   URLの記述力はすごい

   "/" 以外のsub-delimsを使えば世界が広がる

   みんなもっとURLで遊べばいい
   別に「URL設計はこうあるべき」とか論じる気は
    ない
    ◦ そんなのサービスによって変わるし

   その前に選択肢を知るべきだ

   自分で制限して自分で苦しむなんて、バカみたい
    じゃないか

More Related Content

What's hot

低レイヤー入門
低レイヤー入門低レイヤー入門
低レイヤー入門demuyan
 
メタプログラミングって何だろう
メタプログラミングって何だろうメタプログラミングって何だろう
メタプログラミングって何だろうKota Mizushima
 
テスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるなテスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるな
Kentaro Matsui
 
my$talk=qr{((?:ir)?reg(?:ular )?exp(?:ressions?)?)}i;
my$talk=qr{((?:ir)?reg(?:ular )?exp(?:ressions?)?)}i;my$talk=qr{((?:ir)?reg(?:ular )?exp(?:ressions?)?)}i;
my$talk=qr{((?:ir)?reg(?:ular )?exp(?:ressions?)?)}i;
dankogai
 
Building the Game Server both API and Realtime via c#
Building the Game Server both API and Realtime via c#Building the Game Server both API and Realtime via c#
Building the Game Server both API and Realtime via c#
Yoshifumi Kawai
 
マイクロサービスにおける 結果整合性との戦い
マイクロサービスにおける 結果整合性との戦いマイクロサービスにおける 結果整合性との戦い
マイクロサービスにおける 結果整合性との戦い
ota42y
 
C#とILとネイティブと
C#とILとネイティブとC#とILとネイティブと
C#とILとネイティブと
信之 岩永
 
スマホ(Android・iPhone)でWebRTC
スマホ(Android・iPhone)でWebRTCスマホ(Android・iPhone)でWebRTC
スマホ(Android・iPhone)でWebRTC
Natsuki Yamanaka
 
FastAPIのテンプレートプロジェクトがいい感じだった話
FastAPIのテンプレートプロジェクトがいい感じだった話FastAPIのテンプレートプロジェクトがいい感じだった話
FastAPIのテンプレートプロジェクトがいい感じだった話
NipponAlgorithm
 
心理的安全性の構造 デブサミ2019夏 structure of psychological safety
心理的安全性の構造 デブサミ2019夏 structure of psychological safety心理的安全性の構造 デブサミ2019夏 structure of psychological safety
心理的安全性の構造 デブサミ2019夏 structure of psychological safety
Tokoroten Nakayama
 
新入社員のための大規模ゲーム開発入門 サーバサイド編
新入社員のための大規模ゲーム開発入門 サーバサイド編新入社員のための大規模ゲーム開発入門 サーバサイド編
新入社員のための大規模ゲーム開発入門 サーバサイド編
infinite_loop
 
暗号技術の実装と数学
暗号技術の実装と数学暗号技術の実装と数学
暗号技術の実装と数学
MITSUNARI Shigeo
 
組み込み関数(intrinsic)によるSIMD入門
組み込み関数(intrinsic)によるSIMD入門組み込み関数(intrinsic)によるSIMD入門
組み込み関数(intrinsic)によるSIMD入門Norishige Fukushima
 
Unicode文字列処理
Unicode文字列処理Unicode文字列処理
Unicode文字列処理
信之 岩永
 
セキュリティの都市伝説を暴く
セキュリティの都市伝説を暴くセキュリティの都市伝説を暴く
セキュリティの都市伝説を暴く
Hiroshi Tokumaru
 
ユーザーストーリーマッピングを使ってプロダクトバックログを作ろう
ユーザーストーリーマッピングを使ってプロダクトバックログを作ろうユーザーストーリーマッピングを使ってプロダクトバックログを作ろう
ユーザーストーリーマッピングを使ってプロダクトバックログを作ろう
izumi ito
 
BuildKitによる高速でセキュアなイメージビルド
BuildKitによる高速でセキュアなイメージビルドBuildKitによる高速でセキュアなイメージビルド
BuildKitによる高速でセキュアなイメージビルド
Akihiro Suda
 
何となく勉強した気分になれるパーサ入門
何となく勉強した気分になれるパーサ入門何となく勉強した気分になれるパーサ入門
何となく勉強した気分になれるパーサ入門
masayoshi takahashi
 
BoostAsioで可読性を求めるのは間違っているだろうか
BoostAsioで可読性を求めるのは間違っているだろうかBoostAsioで可読性を求めるのは間違っているだろうか
BoostAsioで可読性を求めるのは間違っているだろうか
Yuki Miyatake
 
RustによるGPUプログラミング環境
RustによるGPUプログラミング環境RustによるGPUプログラミング環境
RustによるGPUプログラミング環境
KiyotomoHiroyasu
 

What's hot (20)

低レイヤー入門
低レイヤー入門低レイヤー入門
低レイヤー入門
 
メタプログラミングって何だろう
メタプログラミングって何だろうメタプログラミングって何だろう
メタプログラミングって何だろう
 
テスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるなテスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるな
 
my$talk=qr{((?:ir)?reg(?:ular )?exp(?:ressions?)?)}i;
my$talk=qr{((?:ir)?reg(?:ular )?exp(?:ressions?)?)}i;my$talk=qr{((?:ir)?reg(?:ular )?exp(?:ressions?)?)}i;
my$talk=qr{((?:ir)?reg(?:ular )?exp(?:ressions?)?)}i;
 
Building the Game Server both API and Realtime via c#
Building the Game Server both API and Realtime via c#Building the Game Server both API and Realtime via c#
Building the Game Server both API and Realtime via c#
 
マイクロサービスにおける 結果整合性との戦い
マイクロサービスにおける 結果整合性との戦いマイクロサービスにおける 結果整合性との戦い
マイクロサービスにおける 結果整合性との戦い
 
C#とILとネイティブと
C#とILとネイティブとC#とILとネイティブと
C#とILとネイティブと
 
スマホ(Android・iPhone)でWebRTC
スマホ(Android・iPhone)でWebRTCスマホ(Android・iPhone)でWebRTC
スマホ(Android・iPhone)でWebRTC
 
FastAPIのテンプレートプロジェクトがいい感じだった話
FastAPIのテンプレートプロジェクトがいい感じだった話FastAPIのテンプレートプロジェクトがいい感じだった話
FastAPIのテンプレートプロジェクトがいい感じだった話
 
心理的安全性の構造 デブサミ2019夏 structure of psychological safety
心理的安全性の構造 デブサミ2019夏 structure of psychological safety心理的安全性の構造 デブサミ2019夏 structure of psychological safety
心理的安全性の構造 デブサミ2019夏 structure of psychological safety
 
新入社員のための大規模ゲーム開発入門 サーバサイド編
新入社員のための大規模ゲーム開発入門 サーバサイド編新入社員のための大規模ゲーム開発入門 サーバサイド編
新入社員のための大規模ゲーム開発入門 サーバサイド編
 
暗号技術の実装と数学
暗号技術の実装と数学暗号技術の実装と数学
暗号技術の実装と数学
 
組み込み関数(intrinsic)によるSIMD入門
組み込み関数(intrinsic)によるSIMD入門組み込み関数(intrinsic)によるSIMD入門
組み込み関数(intrinsic)によるSIMD入門
 
Unicode文字列処理
Unicode文字列処理Unicode文字列処理
Unicode文字列処理
 
セキュリティの都市伝説を暴く
セキュリティの都市伝説を暴くセキュリティの都市伝説を暴く
セキュリティの都市伝説を暴く
 
ユーザーストーリーマッピングを使ってプロダクトバックログを作ろう
ユーザーストーリーマッピングを使ってプロダクトバックログを作ろうユーザーストーリーマッピングを使ってプロダクトバックログを作ろう
ユーザーストーリーマッピングを使ってプロダクトバックログを作ろう
 
BuildKitによる高速でセキュアなイメージビルド
BuildKitによる高速でセキュアなイメージビルドBuildKitによる高速でセキュアなイメージビルド
BuildKitによる高速でセキュアなイメージビルド
 
何となく勉強した気分になれるパーサ入門
何となく勉強した気分になれるパーサ入門何となく勉強した気分になれるパーサ入門
何となく勉強した気分になれるパーサ入門
 
BoostAsioで可読性を求めるのは間違っているだろうか
BoostAsioで可読性を求めるのは間違っているだろうかBoostAsioで可読性を求めるのは間違っているだろうか
BoostAsioで可読性を求めるのは間違っているだろうか
 
RustによるGPUプログラミング環境
RustによるGPUプログラミング環境RustによるGPUプログラミング環境
RustによるGPUプログラミング環境
 

Viewers also liked

Notafilia moedas comunitárias de portugal
Notafilia   moedas comunitárias de portugalNotafilia   moedas comunitárias de portugal
Notafilia moedas comunitárias de portugalMiguel Yasuyuki Hirota
 
依納五穗種子-公民記者分享-中部聚會
依納五穗種子-公民記者分享-中部聚會 依納五穗種子-公民記者分享-中部聚會
依納五穗種子-公民記者分享-中部聚會 peopo
 
ellenlee-公民記者分享-中部聚會
ellenlee-公民記者分享-中部聚會 ellenlee-公民記者分享-中部聚會
ellenlee-公民記者分享-中部聚會 peopo
 
nature23-公民記者分享-中部聚會
nature23-公民記者分享-中部聚會 nature23-公民記者分享-中部聚會
nature23-公民記者分享-中部聚會 peopo
 
Hrd recruitment track report no3_book1(1)
Hrd recruitment track report no3_book1(1)Hrd recruitment track report no3_book1(1)
Hrd recruitment track report no3_book1(1)Confidential
 
盧廣《中國的污染》
盧廣《中國的污染》盧廣《中國的污染》
盧廣《中國的污染》saymynames
 
Harsh Climate for Human Rights Defenders in China:2014 in Photos 中国大陆人权捍卫者面临严...
Harsh Climate for Human Rights Defenders in China:2014 in Photos 中国大陆人权捍卫者面临严...Harsh Climate for Human Rights Defenders in China:2014 in Photos 中国大陆人权捍卫者面临严...
Harsh Climate for Human Rights Defenders in China:2014 in Photos 中国大陆人权捍卫者面临严...
CHRDnet
 
what it means for PKP to offer Article Level Metrics
what it means for PKP to offer Article Level Metricswhat it means for PKP to offer Article Level Metrics
what it means for PKP to offer Article Level Metrics
SciELO - Scientific Electronic Library Online
 
08级第七批警务援助队绵竹教学实践活动自我鉴定报告
08级第七批警务援助队绵竹教学实践活动自我鉴定报告08级第七批警务援助队绵竹教学实践活动自我鉴定报告
08级第七批警务援助队绵竹教学实践活动自我鉴定报告Luchuan Wang
 
Redmine 260 300_new_feature
Redmine 260 300_new_featureRedmine 260 300_new_feature
Redmine 260 300_new_feature
Jun Naitoh
 
CHRD’s image gallery of the year in human rights defense in China
CHRD’s image gallery of the year in human rights defense in ChinaCHRD’s image gallery of the year in human rights defense in China
CHRD’s image gallery of the year in human rights defense in China
CHRDnet
 
La ONU
La ONULa ONU
Final slideshow hrd 2013 report
Final slideshow hrd 2013 reportFinal slideshow hrd 2013 report
Final slideshow hrd 2013 report
CHRDnet
 
It from bit
It from bitIt from bit
It from bit
Nguyen Trung
 
「通貨と持続可能性: 見失われた関連性」要約
「通貨と持続可能性: 見失われた関連性」要約「通貨と持続可能性: 見失われた関連性」要約
「通貨と持続可能性: 見失われた関連性」要約
Miguel Yasuyuki Hirota
 
China, Law and the Foreigner: Mutual Engagements on a Global Stage
China, Law and the Foreigner: Mutual Engagements on a Global StageChina, Law and the Foreigner: Mutual Engagements on a Global Stage
China, Law and the Foreigner: Mutual Engagements on a Global Stage
Larry Catá Backer
 
Recruitment -hrd 2 report (1)
Recruitment -hrd 2 report (1)Recruitment -hrd 2 report (1)
Recruitment -hrd 2 report (1)
Emmanuel Nadela
 
PM 2.5
PM 2.5PM 2.5
Enterprise grade firewall and ssl termination to ac by will stevens
Enterprise grade firewall and ssl termination to ac by will stevensEnterprise grade firewall and ssl termination to ac by will stevens
Enterprise grade firewall and ssl termination to ac by will stevens
buildacloud
 

Viewers also liked (20)

南海大餐pdf
南海大餐pdf南海大餐pdf
南海大餐pdf
 
Notafilia moedas comunitárias de portugal
Notafilia   moedas comunitárias de portugalNotafilia   moedas comunitárias de portugal
Notafilia moedas comunitárias de portugal
 
依納五穗種子-公民記者分享-中部聚會
依納五穗種子-公民記者分享-中部聚會 依納五穗種子-公民記者分享-中部聚會
依納五穗種子-公民記者分享-中部聚會
 
ellenlee-公民記者分享-中部聚會
ellenlee-公民記者分享-中部聚會 ellenlee-公民記者分享-中部聚會
ellenlee-公民記者分享-中部聚會
 
nature23-公民記者分享-中部聚會
nature23-公民記者分享-中部聚會 nature23-公民記者分享-中部聚會
nature23-公民記者分享-中部聚會
 
Hrd recruitment track report no3_book1(1)
Hrd recruitment track report no3_book1(1)Hrd recruitment track report no3_book1(1)
Hrd recruitment track report no3_book1(1)
 
盧廣《中國的污染》
盧廣《中國的污染》盧廣《中國的污染》
盧廣《中國的污染》
 
Harsh Climate for Human Rights Defenders in China:2014 in Photos 中国大陆人权捍卫者面临严...
Harsh Climate for Human Rights Defenders in China:2014 in Photos 中国大陆人权捍卫者面临严...Harsh Climate for Human Rights Defenders in China:2014 in Photos 中国大陆人权捍卫者面临严...
Harsh Climate for Human Rights Defenders in China:2014 in Photos 中国大陆人权捍卫者面临严...
 
what it means for PKP to offer Article Level Metrics
what it means for PKP to offer Article Level Metricswhat it means for PKP to offer Article Level Metrics
what it means for PKP to offer Article Level Metrics
 
08级第七批警务援助队绵竹教学实践活动自我鉴定报告
08级第七批警务援助队绵竹教学实践活动自我鉴定报告08级第七批警务援助队绵竹教学实践活动自我鉴定报告
08级第七批警务援助队绵竹教学实践活动自我鉴定报告
 
Redmine 260 300_new_feature
Redmine 260 300_new_featureRedmine 260 300_new_feature
Redmine 260 300_new_feature
 
CHRD’s image gallery of the year in human rights defense in China
CHRD’s image gallery of the year in human rights defense in ChinaCHRD’s image gallery of the year in human rights defense in China
CHRD’s image gallery of the year in human rights defense in China
 
La ONU
La ONULa ONU
La ONU
 
Final slideshow hrd 2013 report
Final slideshow hrd 2013 reportFinal slideshow hrd 2013 report
Final slideshow hrd 2013 report
 
It from bit
It from bitIt from bit
It from bit
 
「通貨と持続可能性: 見失われた関連性」要約
「通貨と持続可能性: 見失われた関連性」要約「通貨と持続可能性: 見失われた関連性」要約
「通貨と持続可能性: 見失われた関連性」要約
 
China, Law and the Foreigner: Mutual Engagements on a Global Stage
China, Law and the Foreigner: Mutual Engagements on a Global StageChina, Law and the Foreigner: Mutual Engagements on a Global Stage
China, Law and the Foreigner: Mutual Engagements on a Global Stage
 
Recruitment -hrd 2 report (1)
Recruitment -hrd 2 report (1)Recruitment -hrd 2 report (1)
Recruitment -hrd 2 report (1)
 
PM 2.5
PM 2.5PM 2.5
PM 2.5
 
Enterprise grade firewall and ssl termination to ac by will stevens
Enterprise grade firewall and ssl termination to ac by will stevensEnterprise grade firewall and ssl termination to ac by will stevens
Enterprise grade firewall and ssl termination to ac by will stevens
 

Similar to URLで遊ぼう

Write good parser in perl
Write good parser in perlWrite good parser in perl
Write good parser in perlJiro Nishiguchi
 
お前は PHP の歴史的な理由の数を覚えているのか
お前は PHP の歴史的な理由の数を覚えているのかお前は PHP の歴史的な理由の数を覚えているのか
お前は PHP の歴史的な理由の数を覚えているのか
Kousuke Ebihara
 
Apacheの展望とmod_perlの超絶技巧 #yapcasia
Apacheの展望とmod_perlの超絶技巧 #yapcasiaApacheの展望とmod_perlの超絶技巧 #yapcasia
Apacheの展望とmod_perlの超絶技巧 #yapcasia
鉄次 尾形
 
知ってるようで意外と知らないPHPの便利関数
知ってるようで意外と知らないPHPの便利関数知ってるようで意外と知らないPHPの便利関数
知ってるようで意外と知らないPHPの便利関数
Wataru Terada
 
メタメタプログラミングRuby
メタメタプログラミングRubyメタメタプログラミングRuby
メタメタプログラミングRuby
emasaka
 
PHP AST 徹底解説
PHP AST 徹底解説PHP AST 徹底解説
PHP AST 徹底解説
do_aki
 
Php in ruby
Php in rubyPhp in ruby
Php in rubydo_aki
 
Mojoliciousをウェブ制作現場で使ってみてる
Mojoliciousをウェブ制作現場で使ってみてるMojoliciousをウェブ制作現場で使ってみてる
Mojoliciousをウェブ制作現場で使ってみてるjamadam
 
2008.10.18 L4u Tech Talk
2008.10.18 L4u Tech Talk2008.10.18 L4u Tech Talk
2008.10.18 L4u Tech Talkmitamex4u
 
「Html sql」で図書館hpにアクセスしてみよう
「Html sql」で図書館hpにアクセスしてみよう「Html sql」で図書館hpにアクセスしてみよう
「Html sql」で図書館hpにアクセスしてみようKentaro Matsui
 
MT meets PHP - PHP conference Kansai 2013
MT meets PHP - PHP conference Kansai 2013MT meets PHP - PHP conference Kansai 2013
MT meets PHP - PHP conference Kansai 2013純生 野田
 
How to debug a perl script using gdb
How to debug a perl script using gdbHow to debug a perl script using gdb
How to debug a perl script using gdbakirahiguchi
 
GNU awk (gawk) を用いた Apache ログ解析方法
GNU awk (gawk) を用いた Apache ログ解析方法GNU awk (gawk) を用いた Apache ログ解析方法
GNU awk (gawk) を用いた Apache ログ解析方法博文 斉藤
 
CPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したいCPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したい
charsbar
 
20190809
2019080920190809
Phpmatsuri2011 LT j_nakada
Phpmatsuri2011 LT j_nakadaPhpmatsuri2011 LT j_nakada
Phpmatsuri2011 LT j_nakadaJunpei Nakada
 
知って得するC#
知って得するC#知って得するC#
知って得するC#Shota Baba
 
Ruby 2.5
Ruby 2.5Ruby 2.5
Ruby 2.5
Masahiro Tomita
 
Dive into RTS - another side
Dive into RTS - another sideDive into RTS - another side
Dive into RTS - another sideKiwamu Okabe
 

Similar to URLで遊ぼう (20)

Write good parser in perl
Write good parser in perlWrite good parser in perl
Write good parser in perl
 
お前は PHP の歴史的な理由の数を覚えているのか
お前は PHP の歴史的な理由の数を覚えているのかお前は PHP の歴史的な理由の数を覚えているのか
お前は PHP の歴史的な理由の数を覚えているのか
 
Apacheの展望とmod_perlの超絶技巧 #yapcasia
Apacheの展望とmod_perlの超絶技巧 #yapcasiaApacheの展望とmod_perlの超絶技巧 #yapcasia
Apacheの展望とmod_perlの超絶技巧 #yapcasia
 
知ってるようで意外と知らないPHPの便利関数
知ってるようで意外と知らないPHPの便利関数知ってるようで意外と知らないPHPの便利関数
知ってるようで意外と知らないPHPの便利関数
 
メタメタプログラミングRuby
メタメタプログラミングRubyメタメタプログラミングRuby
メタメタプログラミングRuby
 
PHP AST 徹底解説
PHP AST 徹底解説PHP AST 徹底解説
PHP AST 徹底解説
 
Php in ruby
Php in rubyPhp in ruby
Php in ruby
 
Mojoliciousをウェブ制作現場で使ってみてる
Mojoliciousをウェブ制作現場で使ってみてるMojoliciousをウェブ制作現場で使ってみてる
Mojoliciousをウェブ制作現場で使ってみてる
 
2008.10.18 L4u Tech Talk
2008.10.18 L4u Tech Talk2008.10.18 L4u Tech Talk
2008.10.18 L4u Tech Talk
 
「Html sql」で図書館hpにアクセスしてみよう
「Html sql」で図書館hpにアクセスしてみよう「Html sql」で図書館hpにアクセスしてみよう
「Html sql」で図書館hpにアクセスしてみよう
 
MT meets PHP - PHP conference Kansai 2013
MT meets PHP - PHP conference Kansai 2013MT meets PHP - PHP conference Kansai 2013
MT meets PHP - PHP conference Kansai 2013
 
How to debug a perl script using gdb
How to debug a perl script using gdbHow to debug a perl script using gdb
How to debug a perl script using gdb
 
GNU awk (gawk) を用いた Apache ログ解析方法
GNU awk (gawk) を用いた Apache ログ解析方法GNU awk (gawk) を用いた Apache ログ解析方法
GNU awk (gawk) を用いた Apache ログ解析方法
 
01 php7
01   php701   php7
01 php7
 
CPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したいCPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したい
 
20190809
2019080920190809
20190809
 
Phpmatsuri2011 LT j_nakada
Phpmatsuri2011 LT j_nakadaPhpmatsuri2011 LT j_nakada
Phpmatsuri2011 LT j_nakada
 
知って得するC#
知って得するC#知って得するC#
知って得するC#
 
Ruby 2.5
Ruby 2.5Ruby 2.5
Ruby 2.5
 
Dive into RTS - another side
Dive into RTS - another sideDive into RTS - another side
Dive into RTS - another side
 

More from Hiraku Nakano

composer-scriptsについて
composer-scriptsについてcomposer-scriptsについて
composer-scriptsについて
Hiraku Nakano
 
composerの遅さをまじめに考える #phpstudy
composerの遅さをまじめに考える #phpstudycomposerの遅さをまじめに考える #phpstudy
composerの遅さをまじめに考える #phpstudy
Hiraku Nakano
 
Composer並列化プラグイン #phpblt
Composer並列化プラグイン #phpblt Composer並列化プラグイン #phpblt
Composer並列化プラグイン #phpblt
Hiraku Nakano
 
Scrutinizer CIでPHPも静的解析 #phpstudy
Scrutinizer CIでPHPも静的解析 #phpstudyScrutinizer CIでPHPも静的解析 #phpstudy
Scrutinizer CIでPHPも静的解析 #phpstudy
Hiraku Nakano
 
JSON SchemaとPHP
JSON SchemaとPHPJSON SchemaとPHP
JSON SchemaとPHP
Hiraku Nakano
 
こわくない同時実行制御
こわくない同時実行制御こわくない同時実行制御
こわくない同時実行制御
Hiraku Nakano
 
PSR-3 Logger Interfaceの紹介
PSR-3 Logger Interfaceの紹介PSR-3 Logger Interfaceの紹介
PSR-3 Logger Interfaceの紹介
Hiraku Nakano
 
pecl-AOPの紹介
pecl-AOPの紹介pecl-AOPの紹介
pecl-AOPの紹介
Hiraku Nakano
 
Xml builderの紹介
Xml builderの紹介Xml builderの紹介
Xml builderの紹介Hiraku Nakano
 

More from Hiraku Nakano (9)

composer-scriptsについて
composer-scriptsについてcomposer-scriptsについて
composer-scriptsについて
 
composerの遅さをまじめに考える #phpstudy
composerの遅さをまじめに考える #phpstudycomposerの遅さをまじめに考える #phpstudy
composerの遅さをまじめに考える #phpstudy
 
Composer並列化プラグイン #phpblt
Composer並列化プラグイン #phpblt Composer並列化プラグイン #phpblt
Composer並列化プラグイン #phpblt
 
Scrutinizer CIでPHPも静的解析 #phpstudy
Scrutinizer CIでPHPも静的解析 #phpstudyScrutinizer CIでPHPも静的解析 #phpstudy
Scrutinizer CIでPHPも静的解析 #phpstudy
 
JSON SchemaとPHP
JSON SchemaとPHPJSON SchemaとPHP
JSON SchemaとPHP
 
こわくない同時実行制御
こわくない同時実行制御こわくない同時実行制御
こわくない同時実行制御
 
PSR-3 Logger Interfaceの紹介
PSR-3 Logger Interfaceの紹介PSR-3 Logger Interfaceの紹介
PSR-3 Logger Interfaceの紹介
 
pecl-AOPの紹介
pecl-AOPの紹介pecl-AOPの紹介
pecl-AOPの紹介
 
Xml builderの紹介
Xml builderの紹介Xml builderの紹介
Xml builderの紹介
 

URLで遊ぼう

  • 2. @Hiraku (中野 拓) ◦ PHP歴5年ぐらい ◦ Zend Framework, Yaf ◦ http://blog.tojiru.net/ ◦ https://github.com/hirak
  • 4. http://example.com/index.php?action=hoge とかだとダサい  短くてCoolなURLにしたい http://twitter.com/Hiraku  しかし短すぎると 将来の拡張性が…  SEO対策がどうとか
  • 6. 他にもURLに関するRFC があるけど、これが最新 RFC3986 http://www.ietf.org/rfc/rfc3986.txt http://www.studyinghttp.net/rfc_ja/rfc3986 (橋本英彦氏による日本語訳)
  • 8. {scheme}:{authority}{path}?{query}#{fragment} http://example.com/a/b/c.php?q=v#foo 固定 ドメイン パラメータ的な使い方 考えるだけ ???
  • 9. path = path-abempty ; "/" で始まるか、空 / path-absolute ; "/" で始まるが、"//" では始まらない / path-noscheme ; コロンの無い segment で始まる / path-rootless ; segment で始まる / path-empty ; 文字が無い path-abempty = *( "/" segment ) path-absolute = "/" [ segment-nz *( "/" segment ) ] path-noscheme = segment-nz-nc *( "/" segment ) path-rootless = segment-nz *( "/" segment ) path-empty = 0<pchar> segment = *pchar segment-nz = 1*pchar segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) ; non-zero-length segment without any colon ":" pchar = unreserved / pct-encoded / sub-delims / ":" / "@
  • 10. 使ってよい文字 ◦ 非予約文字(unreserved-character) [0-9A-Za-z._~-] ◦ %エンコードされた文字 ◦ 予約文字のうちのsub-delims [!$&'()*+,;=] ◦ 予約文字のうちのgen-delimsの一部 [@/:]
  • 11. 0 1 2 3 4 5 6 7 8 9 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz . _ ~ - ! $ & ' ( ) * + , ; = @ / :
  • 14. 0 1 2 3 4 5 6 7 8 9 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz . _ ~ - ! $ & ' ( ) * + , ; = @ / : 四則演算 できるよね
  • 15. http://calc.tojiru.net/1+2  http://calc.tojiru.net/2-1  http://calc.tojiru.net/(1+2)*10/2  URLとして妥当  リクエストすると計算結果がtext/plainで返って くる
  • 16. 0 1 2 3 4 5 6 7 8 9 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz . _ ~ - ! $ & ' ( ) * + , ; = @ / : PHP!?
  • 17. /$a=1;$b=2;echo($a+$b);  /$a=array(1,2,3);echo(implode(':',$a)); <?php $code = ltrim($_SERVER['REQUEST_URI'], '/'); eval($code); $ php -S localhost:8080 index.php  ローカルで実験しましょうね
  • 18. スペースが書けないのでclassやfunctionが無理  echoは()が必要になる  []が書けないので添え字アクセスも無理  "も書けない  できないところも多い
  • 20. 縛りプレイ ◦ 使っている文字が少なすぎる ◦ /と[0-9A-Za-z._-]だけでURL作るとか厳しい ◦ /は「階層」の意味合いを感じてしまう
  • 21. /map/lat/50/long/20/scale/32000  こういうURL設計を強要するフレームワーク、 よくあるよね ◦ lat(経度)とlong(緯度)は階層じゃない ◦ lat/50とlong/20を入れ替えても動作する方がいい  /map?lat=50&long=20&scale=32000 ◦ 入れ替え可能だし階層っぽさは消えた
  • 22. Tim Berners-Leeによる提案 http://www.w3.org/DesignIssues/MatrixURIs.html  /map;lat=50;long=20;scale=32000 ◦ セミコロンによるqueryと同等の記述 ◦ queryを使っていないところに意味がある
  • 23. /user;id=123/friends ◦ 後ろに階層を続けることができる ◦ クエリはURL中一度しか使えないので、 Matrix URIの方が拡張性高い ◦ パスの途中にパラメータを仕込む構文が可能 →覚えておくと何かと便利
  • 25. URLの記述力はすごい  "/" 以外のsub-delimsを使えば世界が広がる  みんなもっとURLで遊べばいい
  • 26. 別に「URL設計はこうあるべき」とか論じる気は ない ◦ そんなのサービスによって変わるし  その前に選択肢を知るべきだ  自分で制限して自分で苦しむなんて、バカみたい じゃないか