Given a PHP application with the following structure:
/ lib/ mylib.php web/ index.php // includes "mylib.php" with: require_once __DIR__ . "/../lib/mylib.php"
I am trying to cover the following cases simultaneously with the same source base:
- No Phar : the ability to use the application as is, with DocumentRoot pointing to the website and redirecting all requests to index.php.
- Minimum Phar : the ability to create a phar that contains only web / index.php and which will be saved as: web / application-minimal.phar.
- Full Phar : the ability to create a phar that contains both the contents of the lib directory and web / index.php, and this will be saved as: web / application-full.phar.
In the case of phar files, all requests will be redirected to the phar file itself.
Is it possible to achieve all these use cases without changing the value of * require_once *?
I tried different approaches (relative / absolute) to enable lib / mylib.php from * web / index.php ", and also try some tricks with Phar :: mount (). None of my attempts have been successful.
source share