-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP/GAE Buildpacks cannot serve static files #234
Labels
kind/question
Further information is requested
Comments
Current solution: <?php
$file = __DIR__ . $_SERVER['PATH_INFO'];
if (is_file($file)) {
switch (preg_replace('/.*?([^.]+)$/', '$1', basename($file))) {
case 'jpg': $mime = 'image/jpeg'; break;
case 'jpeg': $mime = 'image/jpeg'; break;
case 'png': $mime = 'image/png'; break;
case 'svg': $mime = 'image/svg+xml'; break;
case 'gif': $mime = 'image/gif'; break;
case 'html': $mime = 'text/html'; break;
case 'md': $mime = 'text/plain'; break;
case 'css': $mime = 'text/css'; break;
case 'xml': $mime = 'text/xml'; break;
case 'js': $mime = 'text/javascript'; break;
case 'json': $mime = 'application/json'; break;
default: $mime = 'application/octet-stream'; break;
}
header("Content-Type: $mime");
header('Content-Length: ' . filesize($file));
flush();
readfile($file);
exit;
}
require_once __DIR__ . '/index-laravel.php'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It turns out that all requests are passed to the front controller. What about static files? I found no way to instruct nginx to serve them.
Seems https://github.com/GoogleCloudPlatform/buildpacks/blob/main/pkg/nginx/nginx.go is responsible for making nginx.conf file.
This is how I built my app for GAE:
The text was updated successfully, but these errors were encountered: