phar

Include PHP PHAR without .phar extension

孤街浪徒 提交于 2020-01-24 22:23:04
问题 I'm having trouble including a PHAR into my application bootstrapping code. I'm attempting to include the phpunit/phpunit PHAR to have the PHPUnit classes available in my application. Given I have the following directory structure: /path/to/code/ app.php phpunit Where phpunit is the PHPUnit as a PHAR, and app.php contains: <?php $phar = 'phar://' . __DIR__ . '/phpunit'; include $phar; assert(class_exists('\\PHPUnit\\Framework\\TestCase')); I get the following error: PHP Warning: include(phar:

How to run composer update on PHP server?

一曲冷凌霜 提交于 2020-01-12 18:44:29
问题 Is there a way to run composer update command on our production/test environment? Problem is that i don't have access for Command Line. 回答1: Yes. there is a solution. but it could demands some server configuration... and some of these are forbidden by default due to security risks!! download composer.phar https://getcomposer.org/download/ - this is PHP Archive which can be extracted via Phar() and executed as regular library. create new php file and place it to web public folder. i.e. /public

How to run composer update on PHP server?

我的未来我决定 提交于 2020-01-12 18:44:08
问题 Is there a way to run composer update command on our production/test environment? Problem is that i don't have access for Command Line. 回答1: Yes. there is a solution. but it could demands some server configuration... and some of these are forbidden by default due to security risks!! download composer.phar https://getcomposer.org/download/ - this is PHP Archive which can be extracted via Phar() and executed as regular library. create new php file and place it to web public folder. i.e. /public

How to place a phar file inside a phar file?

有些话、适合烂在心里 提交于 2020-01-12 04:31:34
问题 I'd like to place a phar file inside a phar file. I tried it most straight forward: $p = new Phar('test.phar', null, 'self.phar'); $p->setStub('<?php Phar::mapPhar(); include \'phar://self.phar/index.php\'; __HALT_COMPILER(); ?>'); $p['index.php'] = '<?php echo "hello world\n";'; $p = new Phar('test2.phar', null, 'self.phar'); $p->setStub('<?php Phar::mapPhar(); include \'phar://self.phar/index.php\'; __HALT_COMPILER(); ?>'); $p['index.php'] = '<?php echo "hello phar world\n";'; $p['test.phar

How to place a phar file inside a phar file?

走远了吗. 提交于 2020-01-12 04:30:27
问题 I'd like to place a phar file inside a phar file. I tried it most straight forward: $p = new Phar('test.phar', null, 'self.phar'); $p->setStub('<?php Phar::mapPhar(); include \'phar://self.phar/index.php\'; __HALT_COMPILER(); ?>'); $p['index.php'] = '<?php echo "hello world\n";'; $p = new Phar('test2.phar', null, 'self.phar'); $p->setStub('<?php Phar::mapPhar(); include \'phar://self.phar/index.php\'; __HALT_COMPILER(); ?>'); $p['index.php'] = '<?php echo "hello phar world\n";'; $p['test.phar

PharData extractTo method failed to extract .tar.gz on linux environment

邮差的信 提交于 2020-01-04 04:11:09
问题 I would like to extract .tar.gz file into the particular folder. I have used cURL to download the .tar.gz file from MailChimp batch operation. I have used below code to extract tar file. $phar = new \PharData('upload/test.tar.gz'); $phar->extractTo('upload/',null, true); It is working on windows environment. But on Linux(Ubuntu), I got below error when to run above code. Uncaught exception 'PharException' with message 'Extraction from phar "upload/test.tar" failed: Cannot extract ".",

--enable-phar=shared Do I have to recompile PHP to Install Composer?

倖福魔咒の 提交于 2020-01-03 17:26:07
问题 I am trying to get Composer installed on a DreamHost VPS Linux 3.1.9-vs2.3.2.5vs2.3.2.5+ Web PHP Version 5.4.11 CLI Version PHP 5.4.11 (cli) phpinfo() output has only one reference to phar and it says --enable-phar=shared but when I attempt the following the output says I need phar enabled. sudo -u myuser curl -sS https://getcomposer.org/installer | /usr/local/php54/bin/php #!/usr/bin/env php Some settings on your machine make Composer unable to work properly. Make sure that you fix the

Advantages of PHAR archives in PHP

点点圈 提交于 2019-12-31 13:07:14
问题 PHP 5.3 has a new feature called PHAR similar to JAR in JAVA. It's basically a archive of PHP files. What are its advantages? I can't understand how they can be helpful in the web scenario. Any other use other than "ease of deployment" - deploy an entire application by just copying one file 回答1: There are tremendous benefits for open source projects (in no particular order). Easier deployment means easier adoption. Imagine: You install a CMS, forum, or blog system on your website by dragging

How to make an executable phar?

荒凉一梦 提交于 2019-12-31 10:49:08
问题 I want to start a phar script as an executable, directly by doing foo.phar <params> instead of php foo.phar <params> . 回答1: It's easy by modifying the default stub (adding the shebang corresponding to php). // start buffering. Mandatory to modify stub. $phar->startBuffering(); // Get the default stub. You can create your own if you have specific needs $defaultStub = $phar->createDefaultStub('index.php'); // Adding files $phar->buildFromDirectory(__DIR__, '/\.php$/'); // Create a custom stub

How to create a Phar archive without index?

被刻印的时光 ゝ 提交于 2019-12-24 03:14:38
问题 I'm trying to make a Phar archive with one of my lib. The lib is just a bunch of classes organized into folders and subfolders. No index.php at all here, just a static Config class to call to initiate the autoloader. Anyway, I built a archive like this : $phar = new Phar(__DIR__ . '/lis.phar',0,'lib.phar'); $phar->buildFromDirectory(__DIR__ . '/class','/\.php$'); $phar->stopBuffering(); After that I'm trying to use the phar like this : require('lib.phar'); Config::register(); // Config is in