Speed up development with full-stack environments for every branch.

Learn More

Mounting external files into a Phar archive [PHP]

24 Runs 432 Views 104 Copies


gtsolutions 373

published 4 years ago


 * PHP Phar - Mounting external files into a Phar archive

$p = new Phar('my.phar');
//issue the Phar::startBuffering() method call to buffer changes made to the archive until you issue the Phar::stopBuffering() command
//in order to mount an external file we use the Phar::mount method in the phar stub
//this makes external files accesible as they were internal files
//this option is very useful to config files or templates
        if(file_exists( __DIR__ . 'config.xml'))
                Phar::mount('config.xml', __DIR__ . 'include/config.xml');

//add the test file in the phar archive

//Stop buffering write requests to the Phar archive, and save changes to disk
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).