LoginSignup
12
9

More than 5 years have passed since last update.

GAE/SE PHP 5.5環境と7.2環境のapp.yamlの違い

Last updated at Posted at 2018-09-09

GAE/SE (Google App Engine Standard Environment) のPHP 5.5環境で動いていたアプリケーションを最近発表されたPHP 7.2環境に引っ越そうとしたところ、それまで動いていたapp.yamlの書き方では動かなくなっていた、という話題です。

第一世代のGAE/SE環境では、下記のようなapp.yamlが一般的だったと記憶しています。

app.yaml (GAE/SE第一世代)
runtime: php55

handlers:
- url: /js
  static_dir: js
- url: /css
  static_dir: css
- url: /
  script: php/index.php

第二世代のGAE/SE環境では全リクエストをフロントコントローラで受けるモデルが前提になっており、デフォルト設定では全リクエストをindex.phpで受けるようになっています。

下記のようにentrypointを設定すればフロントコントローラのパスが変更できます。

app.yaml (GAE/SE第二世代)
runtime: php72
entrypoint: serve php/index.php

ところで以前のように静的ファイルのパスをhandlersで指定しようとするとentrypointの設定が無視されてしまって意外とハマります(私はハマりました)。

公式ドキュメント「app.yaml Configuration File」に書いてある通り、下記のように記述すればhandlersentrypointを共存させることができます。

app.yaml (GAE/SE第二世代)
runtime: php72
entrypoint: serve php/index.php

handlers:
- url: /js
  static_dir: js
- url: /css
  static_dir: css
- url: /
  script: auto

補足ですが、php72になってscriptにPHPファイルを指定しても動かなくなったので、php55時代にマルチコントローラで書いていたアプリケーションを移植する場合はルーティングするだけのフロントコントローラを書く必要があります(参考:「PHP 7.2 Runtime Environment」)。

12
9
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
12
9