From 33b601121c716290aef18c73c0bb18f6949e7a19 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 3 Dec 2019 14:01:56 -0800 Subject: [PATCH] pogolib - Helper for finding script location --- docs/faq.md | 4 +++- templates/pogolib.php | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index a491e22..a074519 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -14,11 +14,13 @@ You may find it easier to use `pogo` for micro-services in async environments, a ### The examples are mostly single-page scripts/apps. Does it work with includes? -Yes... `include`, `require`, `include_once`, and `require_once` still work as normal. +Yes... `include`, `require`, `include_once`, and `require_once` still work. But no... dependencies are not determined transitively through included files. The scanner currently has no specific support for multi-file projects. +Note: For the main script, the content of `__DIR__` will depend in on the runner. Use `pogo_script_dir()` if you need a consistent value across all runners. + ### Why does it redownload dependencies after a week? That's a security precaution - to make sure we don't run stale libraries. diff --git a/templates/pogolib.php b/templates/pogolib.php index f21d0b5..36fbfae 100644 --- a/templates/pogolib.php +++ b/templates/pogolib.php @@ -8,6 +8,14 @@ function pogo_script() { return pogo_clean_script(file_get_contents(getenv('POGO_SCRIPT'))); } +/** + * @return string + * The folder in which the script was originally stored + */ +function pogo_script_dir() { + return dirname(getenv('POGO_SCRIPT')); +} + /** * @param string $c * PHP code, which may begin with a shebang