Guy
Guy

Reputation: 876

Google App Engine PHP Include Error on deployed site

I have been working on a PHP site with the Google App Engine PHP SDK locally and everything works fine on my machine. I then deploy the site and it says it uploads successfully, however, when I view the hosted website the page is blank. When I check the log in the App Dashboard I get a number of Warnings and Errors:

PHP Warning:  include(): apc failed to locate includes/functions.php - bailing in /base/data/home/apps/s~raven3mil/1.373024475561310665/login.php on line 2

PHP Warning:  include(includes/functions.php): failed to open stream: No such file or directory in /base/data/home/apps/s~raven3mil/1.373024475561310665/login.php on line 2

PHP Warning:  include(): Failed opening 'includes/functions.php' for inclusion (include_path='.;/base/data/home/apps/s~raven3mil/1.373024475561310665/;/base/data/home/runtimes/php/sdk') in /base/data/home/apps/s~raven3mil/1.373024475561310665/login.php on line 2

PHP Warning:  require_once(includes/session.php): failed to open stream: No such file or directory in /base/data/home/apps/s~raven3mil/1.373024475561310665/login.php on line 3

PHP Fatal error:  require_once(): Failed opening required 'includes/session.php' (include_path='.;/base/data/home/apps/s~raven3mil/1.373024475561310665/;/base/data/home/runtimes/php/sdk') in /base/data/home/apps/s~raven3mil/1.373024475561310665/login.php on line 3

This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

Does anyone have any insight on the matter? I'm not sure where to go from here... Thanks!

UPDATE:

app.yaml

application: raven3mil
version: 1
runtime: php
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /includes
  static_dir: includes

- url: /fullcalendar-1.6.2/fullcalendar
  static_dir: fullcalendar-1.6.2/fullcalendar

- url: /ckeditor
  static_dir: ckeditor

  # Serve php scripts.
- url: /(.+\.php)
  script: \1

- url: /.*
  script: login.php

error_handlers:
- file: errors/404.php

The application names match and everything runs well locally.

Upvotes: 1

Views: 2424

Answers (2)

Jens Tandstad
Jens Tandstad

Reputation: 109

The error can also be caused by the fact that on some operating systems (MAMP stack for example) is not case sensitive, but Jetty is (which GAE is built on). So if you are developing on an Apache stack and migrating to GAE, you need to check that all your include paths are case sensitive.

Upvotes: 2

Stuart Langley
Stuart Langley

Reputation: 7054

By default files in static file handlers cannot be read by your application unless you specify the application_readable flag as part of the handler in the app.yaml, so you should change

- url: /includes
  static_dir: includes

to

- url: /includes
  static_dir: includes
  application_readable: true

Of course if you only have php scripts in this folder that you don't actually want to serve from your application but just want to deploy and access at runtime, then you should remove this handler all together. You do not need entries in the app.yaml file for the files to be uploaded with your application, only if you want then to be served in response to an incoming request.

Upvotes: 8

Related Questions