I'm trying to write a PHP extension that needs to access the currently processed request (the request URL in case of HTTP SAPIs or the file name in case of CLI), basically $_SERVER['REQUEST_URI']
or similar.
Ideally, I'd get the request in RINIT, but RSHUTDOWN works for me as well.
The juicy SAPI methods and variables aren't exported to extensions (which makes sense I suppose), so I tried to access the PHP $_SERVER
variable:
zend_hash_str_find(&EG(symbol_table), "_SERVER", strlen("_SERVER"))
It works fine if the PHP script accesses it before my extension does but it's empty otherwise. I expect the contents are lazily generated on first access but I don't know how to trigger the generation.
I want my extension to be as non-invasive as possible, so I'd really like to avoid hacks like auto_prepend_file
.
Any pointers/hints?