public function __construct($binDir, $jsonDir) { \Phar::loadPhar($binDir . '/composer.phar', 'composer.phar'); require 'phar://composer.phar/src/bootstrap.php'; $this->io = new \Composer\IO\NullIO(); $this->composer = \Composer\Factory::create($this->io, $jsonDir . '/composer.json'); $vendorDir = $this->composer->getConfig()->get('vendor-dir'); $jsonFile = new \Composer\Json\JsonFile($vendorDir . '/composer/installed.json'); $this->composer->getRepositoryManager()->setLocalRepository(new \Composer\Repository\InstalledFilesystemRepository($jsonFile)); }
/** * Check for composer in Namespace * and include via phar if possible */ public static function checkComposer($pathToComposer = null) { if (!class_exists('Composer\\Factory')) { if (false === ($pathToComposer = self::whichComposer($pathToComposer))) { throw new \RuntimeException("Could not find composer.phar"); } \Phar::loadPhar($pathToComposer, 'composer.phar'); include "phar://composer.phar/vendor/autoload.php"; } }
/** * Check for composer in Namespace * and include via phar if possible */ public static function checkComposer($pathToComposer = null) { if (!class_exists("Composer\\Factory")) { if (false === ($pathToComposer = self::whichComposer($pathToComposer))) { throw new \RuntimeException("Could not find composer.phar"); } \Phar::loadPhar($pathToComposer, 'composer.phar'); $loader = new UniversalClassLoader(); $namespaces = (include "phar://composer.phar/vendor/composer/autoload_namespaces.php"); $loader->registerNamespaces(array_merge(array('Composer' => "phar://composer.phar/src/"), $namespaces)); $loader->register(true); } }
public function testExecuteRegExp() { $this->checkReadonly(); $plugin = $this->getPlugin(array('regexp' => '/\\.(php|phtml)$/')); $path = $this->buildSource(); $plugin->getPHPCI()->buildPath = $path; $this->assertTrue($plugin->execute()); $this->assertFileExists($path . '/build.phar'); PHPPhar::loadPhar($path . '/build.phar'); $this->assertFileEquals($path . '/one.php', 'phar://build.phar/one.php'); $this->assertFileEquals($path . '/two.php', 'phar://build.phar/two.php'); $this->assertFileNotExists('phar://build.phar/config/config.ini'); $this->assertFileEquals($path . '/views/index.phtml', 'phar://build.phar/views/index.phtml'); }
* * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ // Set the Joomla execution flag. define('_JEXEC', 1); // Allow the application to run as long as is necessary. ini_set('max_execution_time', 0); // Note, you would not use these settings in production. error_reporting(E_ALL); ini_set('display_errors', true); // Ensure that required path constants are defined. if (!defined('JPATH_BASE')) { define('JPATH_BASE', realpath(__DIR__)); } Phar::loadPhar(realpath(JPATH_BASE . '/../libraries/joomla.phar')); // Define the path for the Joomla Platform. if (!defined('JPATH_PLATFORM')) { $platform = getenv('JPLATFORM_HOME'); if ($platform) { define('JPATH_PLATFORM', realpath($platform)); } else { // Platform directory instead of phar: define('JPATH_PLATFORM', JPATH_BASE . '/../../joomla-platform/libraries'); define('JPATH_PLATFORM', 'phar://joomla.phar/libraries'); } } // Ensure that required path constants are defined. if (!defined('JPATH_CONFIGURATION')) { $path = getenv('WEBSERVICE_CONFIG'); if ($path) { define('JPATH_CONFIGURATION', realpath($path));
<?php Phar::loadPhar(__DIR__ . '/phar1.phar'); require_once 'phar://p.phar/includes1/file.php';
<?php $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; $pname = 'phar://' . $fname; $file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>'; $files = array(); $files['a.php'] = '<?php echo "This is a\\n"; include \'' . $pname . '/b.php\'; ?>'; $files['b.php'] = '<?php echo "This is b\\n"; include \'' . $pname . '/b/c.php\'; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\\n"; include \'' . $pname . '/b/d.php\'; ?>'; $files['b/d.php'] = '<?php echo "This is b/d\\n"; include \'' . $pname . '/e.php\'; ?>'; $files['e.php'] = '<?php echo "This is e\\n"; ?>'; $files['.phar/test'] = '<?php bad boy ?>'; include 'files/phar_test.inc'; Phar::loadPhar($fname); require $pname . '/a.php'; $p = new Phar($fname); var_dump(isset($p['.phar/test'])); try { $p['.phar/test']; } catch (Exception $e) { echo $e->getMessage(), "\n"; } ?> ===DONE===
<?php $fname1 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php'; $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php'; $fname = $fname1; $alias = ''; $pname = 'phar://hio'; $file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>'; $files = array(); $files['a.php'] = '<?php echo "This is a\\n"; include "' . $pname . '/b.php"; ?>'; $files['b.php'] = '<?php echo "This is b\\n"; include "' . $pname . '/b/c.php"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\\n"; include "' . $pname . '/b/d.php"; ?>'; $files['b/d.php'] = '<?php echo "This is b/d\\n"; include "' . $pname . '/e.php"; ?>'; $files['e.php'] = '<?php echo "This is e\\n"; ?>'; include 'files/phar_test.inc'; copy($fname1, $fname2); var_dump(Phar::loadPhar($fname1, 'hio')); var_dump(Phar::loadPhar($fname1, 'copy')); $a = new Phar($fname1); try { var_dump(Phar::loadPhar($fname2, 'copy')); } catch (Exception $e) { echo $e->getMessage() . "\n"; } ?> ===DONE===
<?php ini_set('phar.readonly', 1); function print_exception($e) { echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; } Phar::mungServer('hi'); Phar::createDefaultStub(array()); Phar::loadPhar(array()); Phar::canCompress('hi'); try { $a = new Phar(array()); } catch (TypeError $e) { print_exception($e); } try { $a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar'); } catch (PharException $e) { print_exception($e); } $a->convertToExecutable(array()); $a->convertToData(array()); try { $b = new PharData(dirname(__FILE__) . '/whatever.tar'); } catch (PharException $e) { print_exception($e); } try { $c = new PharData(dirname(__FILE__) . '/whatever.zip'); } catch (PharException $e) {
<?php $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; $pname = 'phar://hio'; $file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>'; $alias = ''; $files = array(); $files['a.php'] = '<?php echo "This is a\\n"; include "' . $pname . '/b.php"; ?>'; $files['b.php'] = '<?php echo "This is b\\n"; include "' . $pname . '/b/c.php"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\\n"; include "' . $pname . '/b/d.php"; ?>'; $files['b/d.php'] = '<?php echo "This is b/d\\n"; include "' . $pname . '/e.php"; ?>'; $files['e.php'] = '<?php echo "This is e\\n"; ?>'; include 'files/phar_test.inc'; Phar::loadPhar($fname, 'hio'); include $fname; echo "======\n"; include $pname . '/a.php'; ?> ===DONE=== <?php error_reporting(0); unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
} /** * Install composer */ if (!is_file('composer.phar')) { copy('http://getcomposer.org/composer.phar', 'composer.phar'); if (!is_file('composer.phar')) { $error = error_get_last(); echo json_encode(['message' => 'Downloading dependencies, this may take several minutes...', 'done' => false, 'error' => $error['message']]); } else { echo json_encode(['message' => 'Downloading dependencies, this may take several minutes...', 'done' => true, 'error' => false]); } exit; } if (!is_file('Vendor/autoload.php')) { \Phar::loadPhar('composer.phar', 'composer.phar'); require 'phar://composer.phar/src/bootstrap.php'; $input = new Symfony\Component\Console\Input\ArrayInput(array('command' => 'install')); $application = new Composer\Console\Application(); $output = new \Symfony\Component\Console\Output\BufferedOutput(); $application->setAutoExit(false); $result = $application->run($input, $output); echo json_encode(['message' => 'Done. Reloading installation...', 'done' => false, 'error' => $result !== 0 ? nl2br($output->fetch()) : false]); exit; } require 'Vendor/autoload.php'; define('CACHE_DI_PATH', 'Cache/DI'); define('CACHE_DOCTRINE_PROXY_PATH', 'Cache/DoctrineProxies'); define('CACHE_DOCTRINE_MODULE_FILE', 'Cache/doctrine_module_dir.cache'); define('JS_FOLDER', '/js'); define('CSS_FOLDER', '/css');
/** * Inlcude composer */ public function loadComposer() { putenv("COMPOSER_HOME=.composer"); ini_set('memory_limit', '-1'); if (!class_exists(\Composer\Console\Application::class)) { \Phar::loadPhar('composer.phar', 'composer.phar'); require_once 'phar://composer.phar/src/bootstrap.php'; } }