Open Daniel15 opened 8 years ago
From an email thread, some options are:
Also, src/
should not be the www docroot; strongly recommend moving src/index.php
and static/
to a new public/
folder instead, and making all endpoints only accessible through index.php via pretty urls.
Easiest way when using HHVM's built-in webserver is to configure hhvm.server.default_document
and hhvm.server.error_document404
to point to index.php; not sure what would be required for your nginx setup (though you can probably switch to the built-in webserver anyway and simplify the configuration).
not sure what would be required for your nginx setup
If you're using Nginx, the easiest solution is probably to do:
try_files $uri /index.php?p=$uri
This will try to load the URI directly if it exists (ie. a static file), or rewrite/"internally redirect" to index.php if it doesn't exist (so /game
would go to /index.php?p=game
)
Adding a new routing library may be overkill since index.php
is already handling routing (unless you want to remove that and instead use one of the routers mentioned by @fredemmott)
Easiest way when using HHVM's built-in webserver
I was going to say "wasn't that deprecated?" but it looks like it was replaced with a proxygen-based server at some point. My knowledge is outdated 😛
Adding a new routing library may be overkill since index.php is already handling routing (unless you want to remove that and instead use one of the routers mentioned by @fredemmott)
Yeah, depends on if you want to have /foo/?bar=somevalue
or /foo/somevalue
; if the former, a library might be overkill, if the latter, no point reinventing it.
proxygen
The proxygen http server's been recommend over FastCGI since 3.9 :)
The proxygen http server's been recommend over FastCGI since 3.9
Cool, good to know 😄 I was having various segfault issues when trying to switch over to HHVM (https://github.com/facebook/hhvm/issues/6498 but also others I couldn't figure out the cause for) so I ended up switching to PHP7 instead, except for my sites that use Hack. Maybe I should try switching back.
FYI hack-router and hack-router-codegen are now part of hhvm/, not fredemmott/
This should probably be on hold until we're on 3.23 or above; it's now likely there'll be some fairly major changes to the libraries between 3.23 and 3.24
Is it possible to get pretty URLs - For example
/game
rather than/index.php?p=game
? The fact that the site is built with PHP is an implementation detail that shouldn't necessarily be reflected in URLs 😄