Reputation: 21880
I'm experimenting with migration my php 5.5 google app engine site to a php 7.2 site. The biggest difference I've seen is that instead of defining individual url handlers in the app.yaml that we need to define an entrypoint (e.g. index.php) and all php requests are routed through that. Then index.php should contain code that deals with the various url paths and requires the correct php script.
The migration documentation says that instead of running a special GAE dev_server that we should just use the built-in PHP webserver when testing on localhost:
php -S localhost:8080
However, when I do that, it is not sending all requests to my index.php and so none of my routing code is being used.
What do I need to do so that I can test my GAE site on localhost?
I'm on a Mac and I've got php 7.1 installed on the command line. Is the difference between 7.1 and 7.2 the thing tripping me up?
EDIT:
I read through the docs on the built-in PHP webserver and it looks like I need to pass the router script as a parameter when starting up the webserver like so:
php -S localhost:8080 index.php
However, when I do this, then all of my static resources (listed in my app.yaml) stop serving. They are being caught my the end of my router script which sends anything that wasn't found to a 404.php script.
Upvotes: 2
Views: 987
Reputation: 2080
Me too, I saw their documentation saying we had to specify a php -S command in the entrypoint directive of app.yaml, but I didn't need to. All I had to do was to add this directive to my app.yaml:
entrypoint: serve src/www/index.php
(or wherever my index.php was, from the root folder of my app, the level that contains app.yaml).
Upvotes: 0
Reputation: 11
I'm also migrating from php55 to php72. I had the same problems too.
In app.yaml instead the "script auto" add the exact match to the script and it will also work locally. Ex: script: index.php
This will work locally and in GAE
Upvotes: 1
Reputation: 21880
I'm getting closer, but I had to add some code at the top of my index.php router script so that it would ignore static files for routing purposes:
if (preg_match('/\.(?:png|jpg|jpeg|gif|svg|js|css|csv)$/', $_SERVER["REQUEST_URI"])) {
return false; // serve the requested resource as-is.
}
All of this seems highly questionable though, because when I'm developing and testing on localhost, the app.yaml
is not being used at all which seems like a horrendous approach because my app can behave completely differently in production.
Upvotes: 0