PHPackages                             volcanus/routing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. volcanus/routing

ActiveLibrary[Framework](/categories/framework)

volcanus/routing
================

request-URI routing for page-controller scripts.

3.0.1(3y ago)03.5kMITPHPPHP ^8.1

Since Oct 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/k-holy/volcanus-routing)[ Packagist](https://packagist.org/packages/volcanus/routing)[ Docs](https://github.com/k-holy/Volcanus_Routing)[ RSS](/packages/volcanus-routing/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (1)Versions (18)Used By (0)

Volcanus\_Routing
=================

[](#volcanus_routing)

[![Latest Stable Version](https://camo.githubusercontent.com/eb5a1470ecd26ed8eb03785ca78e0fc65a0523e601dfef2e2b4832624de2ccc4/68747470733a2f2f706f7365722e707567782e6f72672f766f6c63616e75732f726f7574696e672f762f737461626c652e706e67)](https://packagist.org/packages/volcanus/routing)[![Continuous Integration](https://github.com/k-holy/volcanus-routing/actions/workflows/ci.yml/badge.svg)](https://github.com/k-holy/volcanus-routing/actions/workflows/ci.yml)

ページコントローラ(PageController)パターンで「きれいなURI」を実現するためのライブラリです。

フロントコントローラ(FrontController)パターンにおいてRouterと呼ばれるクラスは、 リクエストURIを解析して特定のクラスに振り分ける役目を担います。

ページコントローラパターンでの利用を想定したVolcanus\_Routingでは、 リクエストURIを解析して特定のディレクトリにあるスクリプトファイルを読み込み、 カレントディレクトリを移動します。

また、パラメータディレクトリと呼ぶ特別な名前のディレクトリを設定することで、 リクエストURIのパスに含まれるパラメータを取得する機能を提供します。

対応環境
----

[](#対応環境)

- PHP 8.1以降

依存ライブラリ
-------

[](#依存ライブラリ)

なし

簡単な使い方
------

[](#簡単な使い方)

以下は Apache + mod\_rewrite での使用例です。

### /.htaccess

[](#htaccess)

```
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ __gateway.php [QSA,L]

```

なお Apache 2.2.16以上の場合は [FallbackResource](http://httpd.apache.org/docs/trunk/en/mod/mod_dir.html#fallbackresource) ディレクティブが便利です。

### /.htaccess (Apache 2.2.16以上)

[](#htaccess-apache-2216以上)

```
FallbackResource /__gateway.php

```

存在しないディレクトリまたはファイルへのリクエストがあれば、 以下のゲートウェイスクリプト(\_\_gateway.php)に転送されます。

### /\_\_gateway.php

[](#__gatewayphp)

```
