Questions tagged [phar]

Phar is the PHP Archive format. It is analogous to Java's JAR files.

Phar is the PHP Archive format.

A Phar file consists of a collection of PHP scripts combined into a single compressed file, for easy distribution and installation.

More information can be found here.

310 questions
51
votes
7 answers

Extracting files from .phar archive

There is something I entirely missed as for phar files. I am installing a project that requires phpunit, pdepend and other dependencies. I fetched them as .phar files. But, I am not able ot extract the files from them using command line tool (php…
epsilones
  • 10,137
  • 18
  • 57
  • 80
33
votes
3 answers

How to use PHP Composer on HostGator

I recently decided to start a project in Zend Framework 2 and was having trouble getting it to run on a HostGator shared server. By default, HostGator's shared servers run in PHP 5.2.2 and if you upload the ZF2 Skeleton Application, it will not run…
Zach
  • 1,252
  • 2
  • 11
  • 17
25
votes
8 answers

PHP: Class 'Phar' not found

I try to use the Silex framework as base for my web application. However, if I try to include the *.phar archive, PHP throws the following error: Fatal error: Class 'Phar' not found in /var/www/framework/silex.phar on line 11 The following relevant…
SecStone
  • 1,693
  • 3
  • 20
  • 30
24
votes
1 answer

Generating a PHAR for a simple application

I'm experimenting in building CLI tools using the Symfony2 console library. I've got something basic working and now I want to package it as a phar. I've read a few examples but the ones I've seen are very simple (3 files, no namespaces, etc). In my…
Bendihossan
  • 2,099
  • 5
  • 18
  • 25
23
votes
9 answers

PHP Phar creation slow on a powerful PC, how to speed up (loading/reading ~3000 files)?

I'm trying to pack my web application (Symfony 2 project) with Phar. I've successfully packed Silex, a micro framework with hundred of files in a reasonable time (1-2 minutes). The problem is on my development machine (i7 4770k, 16GB, SSD Raid 0,…
gremo
  • 45,925
  • 68
  • 233
  • 380
18
votes
2 answers

Please explain how to create PHP's Phar stubs

I'm trying to create a very simple PHP CLI application that can be run as a phar file from the command line: # php myProject.phar This is what I've tried so far: My Project My project is in a directory called MyProject and it has these two files in…
JW.
  • 4,553
  • 4
  • 41
  • 58
16
votes
8 answers

How to run a webphar PHP file from built-in PHP 5.4 webserver?

As per title, I created a very simple test phar. I'd like to test it with the built-in webserver(PHP 5.4) but it seems impossible. php -S localhost:80 /path/to/myphar.php Result: blank page (in the phar front controller is index.php doing some HTML…
gremo
  • 45,925
  • 68
  • 233
  • 380
14
votes
5 answers

Advantages of PHAR archives in PHP

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…
aWebDeveloper
  • 31,131
  • 35
  • 150
  • 224
13
votes
5 answers

Can't enable phar writing

I am actually using wamp 2.5 with PHP 5.5.12 and when I try to create a phar file it returns me the following message : Uncaught exception 'UnexpectedValueException' with message 'creating archive "..." disabled by the php.ini setting…
user3292788
  • 327
  • 3
  • 14
13
votes
3 answers

Using phar Stream to Write PharData Files

When I try this: $phar = new PharData('./phar.tar', 0, null, Phar::TAR); $phar->addEmptyDir('test'); file_put_contents('phar://./phar.tar/test/foo.txt', 'bar'); I get the following error: Warning:…
Alix Axel
  • 141,486
  • 84
  • 375
  • 483
13
votes
1 answer

How to place a phar file inside a phar file?

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(''); $p['index.php'] =…
hakre
  • 178,314
  • 47
  • 389
  • 754
12
votes
1 answer

'php pyrus.phar' won't get executed

I use PHP 5.3 on Debian and according to php -m 'Phar' is loaded. But executing php pyrus.phar or php pyrus.phar config-show leads to no output at all. What might be the problem? debian:~# php -v PHP 5.3.5-1 with Suhosin-Patch (cli) (built: Feb 19…
Raffael
  • 18,058
  • 12
  • 73
  • 140
12
votes
1 answer

How to access to external files from Phar archives?

I need to place config file out of phar of my web application. I need to mount it. In my stub file I tried:
PHPst
  • 14,868
  • 20
  • 85
  • 158
10
votes
3 answers

how to install dependencies or use composer at all in windows

I've installed composer via windows installer, and set the correct path variables for php to wamp's php, now I created a composer.json( and later .phar) file and attempt to install dependencies listed there { "name": "phpunit/php-unit", "require":…
user2167582
  • 5,103
  • 10
  • 50
  • 95
9
votes
1 answer

How do I correctly create, and then require a PHAR file?

I'm currently trying to package library code, which would then be shipped out to people actually trying to use that library code. After creating the PHAR file, I'm trying to verify that it was done correctly with a simple test script. At some point…
E.T.
  • 496
  • 2
  • 13
1
2 3
20 21