Page 1 of 1

PHP 5.3.1 PHAR outputting readable chars

Posted: Wed Apr 21, 2010 11:48 pm
by jatin
Hello,
I am trying to make a simple PHAR archive work:
here's what I am trying to do : Create a .phar file that simply outputs "Hello world" nothing fancy.
using :
Ubuntu9.10
PHP 5.3.1 (using the xampp stack)

here's the code for index.php

Code: Select all

<?php
echo "Hello World";
?>
here the code I use to create the phar (create.php)

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$phar = new Phar('myphar.phar'); // I have even tried putting this as myphar.phar.php 
$phar->addFile("index.php");
?>
I execute it using
-> php5.3.1 create.php

Now above code does create a myphar.phar which is great but when I try to access this file using the command line
-> php5.3.1 myphar.phar

or even renamed and executer
-> php5.3.1 myphar.phar.php

it displays "��???" <- some rubbish with boxes and ??? if you cannot see it, same case when using the browser too. renaming to it myphar.phar.php also has no effect. I also tried setting the stub file and then using the above code does not work. I also added the httpd.conf setting to parse .phar as .php and re-tried, same results.

Anyone has an idea what wrong am I doing ? or is theres a bug in the code. :banghead:

Note : I have also tried removeing the error reporting and display errors code, no success

Re: PHP 5.3.1 PHAR outputting readable chars

Posted: Thu Apr 22, 2010 1:31 am
by requinix
PHP can't run PHARs directly unless they have a stub.

Re: PHP 5.3.1 PHAR outputting readable chars

Posted: Fri Apr 23, 2010 1:28 am
by jatin
tasairis, thx for reply that might be the case but I have even tried it with a stub file and it still does not work.
Its working on windows correctly :(