This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add start | |
$app = new Micro(); | |
$app->get( | |
'/api/v2/getData', | |
function () { | |
$ret = [ | |
'name' => 'yamada', | |
'id' => 20 | |
]; | |
echo json_encode($ret); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
use Phalcon\Di\FactoryDefault; | |
use Phalcon\Mvc\Micro; | |
error_reporting(E_ALL); | |
define('BASE_PATH', dirname(__DIR__)); | |
define('APP_PATH', BASE_PATH . '/app'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
class V1Controller extends ControllerBase | |
{ | |
public function editAction($aaa, $bbb) | |
{ | |
$lang = $this->request->getQuery('lang'); // getQueryでキー指定してクエリパラメータを取得する | |
echo $aaa , ':' , $bbb , ':', $lang; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$router = $di->getRouter(); | |
// Define your routes here | |
$api = new \Phalcon\Mvc\Router\Group([ | |
'controller' => 'v1' | |
]); | |
$api->addGet('/edit/{id}/{code}?lang={val}', ['action' => 'edit']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
class V1Controller extends ControllerBase | |
{ | |
public function editAction($aaa, $bbb) | |
{ | |
echo $aaa , ':' , $bbb; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$router = $di->getRouter(); | |
// Define your routes here | |
$api = new \Phalcon\Mvc\Router\Group([ | |
'controller' => 'v1' | |
]); | |
$api->addGet('/edit/{id}/{code}', ['action' => 'edit']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
class V1Controller extends ControllerBase | |
{ | |
public function editAction($aaa) | |
{ | |
echo $aaa; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$router = $di->getRouter(); | |
// Define your routes here | |
$api = new \Phalcon\Mvc\Router\Group([ | |
'controller' => 'v1' | |
]); | |
$api->addGet('/edit/{id}', ['action' => 'edit']); // {id}がパスパラメータ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
class V1Controller extends ControllerBase | |
{ | |
public function indexAction() | |
{ | |
echo 'OK'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$router = $di->getRouter(); | |
// V1Controllerでグルーピング | |
$api = new \Phalcon\Mvc\Router\Group([ | |
'controller' => 'v1' | |
]); | |
$api->addGet('', ['action' => 'index']); // GETメソッドのみ、indexActionメソッド実行 | |
$router->mount($api); |