Phar档案:回到网站

Currently, I produce a PHAR archive, which is used as a library. In the stub, this is done:

Phar::mapPhar('___PHAR___');
// Custom autoloader for external classes
spl_autoload_register('wl_autoload_external');
// Custom autoloader for in-library classes
spl_autoload_register('wl_autoload');
set_include_path("phar://" . __FILE__ . PATH_SEPARATOR . get_include_path());
// Composer autoloader
require_once("phar://" . __FILE__ . "/vendor/autoload.php");

Phar file is then require'd where it is needed. It is usually not deployed in publicly accessible directories. However, I would like to serve a fallback website, instead of making the phar file available for download, should it be deployed there. I know I could just disallow access to it from Apache configuration, but if a fallback is possible, that would be great to know.

Webserver is Apache httpd 2, and PHP is up to 5.5.14.

You can use Phar::webPhar() to show a HTML page when the .phar is accessed directly in the browser (and the webserver is configured to let PHP handle .phar files).