https://github.com/uzulla/ore2
https://github.com/uzulla/ore2
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/uzulla/ore2
- Owner: uzulla
- Created: 2016-04-14T03:54:29.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-21T15:41:46.000Z (almost 9 years ago)
- Last Synced: 2025-04-02T13:12:03.746Z (26 days ago)
- Language: PHP
- Size: 70.3 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ore2 Framework
This is NOT for production use.
Just hobby project.
## 概要
- PSR-7対応風なフレームワークサンプル
## setup
```
$ composer install
$ cd public
$ php -S 127.0.0.1:8080
$ open http://127.0.0.1:8080
```## router
```php
$router = new \Ore2\Router();## ルート登録
# / => 引数のclosureがコール
$router->get('/', function(){
return $this->html('123');
});# /name/uzulla => 引数のクロージャがコールされ、コンテナには引数が
$router->get('/name/:name', function(){
return $this->html("hello {$this->c->routeParams['name']}");
});# クラス名での設定
$router->get('/sample', '\\MyApp\\SampleAction::sample');## ルーティング実行
$method = 'get';
$path = '/sample';
$match_result = $router->findMatch($method, $path);# containerと合成してアクションを生成(action節を参照してください)
$action = $match_result->buildAction($container);## アクションを実行して結果(ResponseInterface)取得
$psr7_response = $action($psr7_request, $psr7_response);
// responseをブラウザに送信する箇所はTransmitterを参照のこと// $actionは https://github.com/relayphp/Relay.Relay と互換性
## 特にこまかい事を考えたくない場合、以下でもOK
$router = new \Ore2\Router();
$router->get('/', function(){
return $this->html('123');
});
$router->run($container, $request, $response);## Middlewareとして実行例
$seqencer = new \Ore2\MiddlewareSequencer([
new \Ore2\Transmitter(),
$action
]);
$seqencer($request, $response);```
# TBD