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

 

<?php

 

/**

 * MiniBlogApplication.

 *

 * @author Katsuhiro Ogawa <fivestar@nequal.jp>

 */

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' => '',

        ));

    }

}

 

?>

 

下記は上記を現代版に変更したつもりですが

 果たして正解でしょうか?

<?php

 

/**

 * MiniBlogApplication.

 *

 * @author Katsuhiro Ogawa

 */

class MiniBlogApplication extends Application

{

    protected array $login_action = ['account', 'signin'];

 

    public function getRootDir(): string

    {

        return dirname(__FILE__, 2);

    }

 

    protected function registerRoutes(): array

    {

        return [

            ['GET', '/', ['controller' => 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',

        ]);

    }

}

 

?>

以上宜しくお願い致します。