IISでSilexを使うときにはまったこと
前提としてIIS7.0以上+PHP5.3以上のインストールが済んでいるものとします。
▼はまりポイント1
Silexのユーザガイドにあるweb.configを使うと、500エラーが出る。
HTTP エラー 500.19 - Internal Server Error
■原因
「URLの書き換え」モジュールがインストールされていない。
■解決方法
「Web Platform Installer」から「URL Rewrite 2.0」をインストールする。
IIS7.5でURL Rewrite Module(mod_rewrite)設定
▼はまりポイント2
pharの読み込みに失敗する。
Warning: require_once(phar://C:/inetpub/php/silex.phar/vendor/composer/autoload_real.php): failed to open stream: phar error: "vendor/composer/autoload_real.php" is not a file in phar "C:/inetpub/php/silex.phar" in phar://C:/inetpub/php/silex.phar/vendor/autoload.php on line 5Fatal error: require_once(): Failed opening required 'phar://C:/inetpub/php/silex.phar/vendor/composer/autoload_real.php' (include_path='.;C:\php\pear') in phar://C:/inetpub/php/silex.phar/vendor/autoload.php on line 5
■原因
pharが使える状態になっていない(?)
■解決方法
pharファイルではなく、phpファイルにばらしたライブラリを使う。
現在は、Silexの公式ページでもpharファイルではなく、ばらばらの状態で配布されています。
[sourcecode language="php"]
//require_once __DIR__.'/silex.phar';
require_once __DIR__ . '/vendor/autoload.php';
[/sourcecode]