LoginSignup
2
2

More than 5 years have passed since last update.

ebiのルーティング

Last updated at Posted at 2015-12-02

ebiの一番シンプルなルートはクロージャです。
routes.php を開き(または作成し)ルートを定義してください。

<?php
include('ebi.phar');

\ebi\Flow::app([
    'users'=>['action'=>function(){
        return ['msg'=>'Users!'];
    }]
]);

Webブラウザーで routes.php/users へアクセスすればレスポンスとしてJsonが表示されます。

{
    "result": {
        "msg": "Users!"
    }
}

ルートはクラスメソッドで指定することもできます。例えば:

'users'=>['action'=>'User::index']

このルートがフレームワークに伝えているのは、/usersへのアクセスでUserクラスのindexメソッドが呼び出されるという内容です。

※built-in web serverを起動しているものとします。

参考:
https://github.com/tokushima/ebi
http://readouble.com/laravel/4/2/0/ja/quick.html

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2