nrr06402
@nrr06402

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

10数年前のPHPプログラムを現代版い変更したつもりですが!?

Q&A

PHPの旧型プログラムは下記です。
MiniBlogApplication.php

*/ class MiniBlogApplication extends Application { protected $login_action = array('account', 'signin'); public function getRootDir() { return dirname(__FILE__); } protected function registerRoutes() { return array( '/' => array('controller' => 'status', 'action' => 'index'), '/status/post' => array('controller' => 'status', 'action' => 'post'), '/user/:user_name' => array('controller' => 'status', 'action' => 'user'), '/user/:user_name/status/:id' => array('controller' => 'status', 'action' => 'show'), '/account' => array('controller' => 'account', 'action' => 'index'), '/account/:action' => array('controller' => 'account'), '/follow' => array('controller' => 'account', 'action' => 'follow'), ); } protected function configure() { $this->db_manager->connect('master', array( 'dsn' => 'mysql:dbname=mini_blog;host=localhost', 'user' => 'root', 'password' => '', )); } } ?>

下記は上記を現代版に変更したつもりですが 果たして正解でしょうか?

StatusController::class, 'action' => 'index']], ['POST', '/status/post', ['controller' => StatusController::class, 'action' => 'post']], ['GET', '/user/{user_name}', ['controller' => StatusController::class, 'action' => 'user']], ['GET', '/user/{user_name}/status/{id:\d+}', ['controller' => StatusController::class, 'action' => 'show']], ['GET', '/account', ['controller' => AccountController::class, 'action' => 'index']], ['GET|POST', '/account/{action}', ['controller' => AccountController::class]], ['POST', '/follow', ['controller' => AccountController::class, 'action' => 'follow']], ]; } protected function configure(): void { $this->db_manager->connect('master', [ 'dsn' => 'mysql:dbname=mini_blog;host=localhost;charset=utf8mb4', 'user' => 'root', 'password' => 'root', ]); } } ?>

宜しくお願い致します。

0

4Answer

「正解」というのは要求仕様に合っているかどうかという意味と思うのですが、ご質問内容では仕様が解らないので分かりません。単純に配列の要素が増えているので互換性は大丈夫なのかなとは思いました。
それと、マークアップ記法は以下とされていますのでご参考まで。
https://qiita.com/Qiita/items/c686397e4a0f4f11683d

0Like

Your answer might help someone💌