All other static files are serving as normal at domain.
It seems PHP file wasn't running; when I don't try to run it as a script (and just upload it as a static file) it works fine; returning plaintext when jQuery calls it - so its definitely not a file path problem.
But once I list it as a php file in yaml and expect the jQuery to GET 'hello, world!' it returns 404 in the Firefox network monitor and there's a no response in the console.
Is there something I'm missing with regard to running a solitary server-side php script on App Engine Standard?
app.yaml
runtime: php55
api_version: 1
threadsafe: true
handlers:
# Serve php scripts another way.
- url: /scripts/elastic.php
script: scripts/elastic.php
# Handle the main page by serving the index page.
# Note the $ to specify the end of the path, since app.yaml does prefix matching.
- url: /$
static_files: index.html
upload: index.html
# Handle folder urls by serving the index.html page inside.
- url: /(.*)/$
static_files: \1/index.html
upload: .*/index.html
# Handle nearly every other file by just serving it.
- url: /(.+)
static_files: \1
upload: (.*)
elastic.php
<?php
return 'Hello, world!'
?>
script.js (called after jQuery loads in my index.html)
$(document).ready(function(){
$.get("./scripts/elastic.php", function( data ) {
console.log(data);
});
});
What I think is happening is that your final handlers
directive is telling the deployment to treat all files in your application as uploadable and static. I believe this is resulting in your calls to the earlier script being mishandled (maybe an App Engine bug...).
If you change your final handler to be either a PHP script or something like the following then you should be mostly good:
- url: /(.*)
static_files: \1
upload: (.*)\.html
You'll also want to have your PHP script echo
or print
results in the response rather than return
, which doesn't actually return anything to the browser for display.