LoginSignup
5
5

More than 5 years have passed since last update.

Phalcon ルーターの作成

Last updated at Posted at 2015-07-15

Phalconでのルータ作成

初投稿になります。
Phalconでルーティングするための設定を書いたので、忘れた時ように書いておきます

前提としてPhalconをインストール及びDevToolsをインストールしているとします。

Router.php の作成

/app/config/ の中に router.php を作成しておきます。

Config.php の編集

/app/config/config.php の application の中に以下を追記します。

config.php
    'configDir'      => APP_PATH . '/app/config/',

Service.php の編集

/app/config/service.php の url の下ぐらいに以下を追記します

service.php
    /**
     * Router
     */
    $di->set('router', function () use ($config){
        require $config->application->configDir . 'router.php';
        return $router;
    });

Router.php の編集

先ほど作成したRouter.phpを編集します。
PATH : /app/config/router.php

router.php
<?php
    $router = new \Phalcon\Mvc\Router();

    /**
     *  /
     */
    $router->add(
        '/',
        array(
            'controller' => 'index',
            'action' => 'index'
        )
    );

これでRouterが動くはずです。

参考文献

Phalcon Router

5
5
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
5
5