LoginSignup
3
4

More than 5 years have passed since last update.

PHP built-in webserverでphalconとwebtoolsも併用する

Posted at

PHP ビルトインサーバーの利用¶でのコードでは、以下のように.htrouter.phpを指定して起動しますが。
これだと、webtools.phpやコントローラー、アクションにクエリ文字列を付与する時などにうまく動作してくれないので・・・

.htrouter.php
<?php
// これはphalconのマニュアルに記載
if (!file_exists(__DIR__ . '/' . $_SERVER['REQUEST_URI'])) {
    $_GET['_url'] = $_SERVER['REQUEST_URI'];
}
return false;

以下のように書き換えるなどしてみました。

.htrouter.php
<?php
// これならwebtools.phpもOK
if (!file_exists(__DIR__ . '/' . $_SERVER['REQUEST_URI'])) {
    list($url, $querys) = explode('?', $_SERVER['REQUEST_URI']);
    $_GET['_url'] = $url;
    if ($querys) {
        $params = explode('&', $querys);
        foreach ($params as $param) {
            list($key, $value) = explode('=', $param);
            $_GET[$key] = $value;
        }
    }
}
return false;
3
4
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
3
4