Results 1 to 6 of 6

Thread: Why we use PHAR in PHP?

  1. #1
    Join Date
    Jul 2006
    Posts
    339

    Why we use PHAR in PHP?

    Hello friends,
    I have now started with the PHP programming language. The solution that you provided me last time was really very helpful. Now I am stuck at a topic of the compressions that take place in PHP. I just saw an example in my tutorial mentioning about the phar. I don't know anything about it. So thought that you guys can explain me better.!! Please tell me why we use PHAR in PHP? Reply soon as possible.!!

  2. #2
    Join Date
    Jul 2006
    Posts
    286

    Re: Why we use PHAR in PHP?

    The phar extension provides a way to put a complete PHP application in a single file called a "phar" (PHP Archive) for installation and configuration easy. In addition to this service, the extension also provides an abstraction class file format to create and manipulate tar files and zip through the class PharData, much as PDO provides a unified interface for accessing different databases. But unlike PDP, who can not translate data from one database to another, Phar has the ability to convert tar files, zip and phar using a single line of code.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  3. #3
    Join Date
    Jul 2006
    Posts
    442

    Re: Why we use PHAR in PHP?

    You can use the Phar:: convertToExecutable to convert a phar archive to another file format executable phar archive. One thing you will have to keep in mind that this method requires that the variable configuration INI phar.readonly is set to 0 to work with objects Phar. Otherwise, an exception PharException will be thrown. This method is used for converting a phar archive to another file format. For example, it can be used to create an archive tar-based phar starting a phar archive based on zip or from an executable phar archive based on the phar file format.
    "When they give you ruled paper, write the other way..." J.R.J.

  4. #4
    Join Date
    Aug 2006
    Posts
    227

    Re: Why we use PHAR in PHP?

    Phar archives are actually a convenient way to group several files into one. Thus, a phar archive can distribute a complete PHP application in a single file and run it from the file without extracting it to disk. Moreover, phar archives can be executed by PHP as easily as any other file, both in command line via a web server. Phar is kind of USB key for PHP applications. Phar implements this functionality via a stream. Normally, to use an external file from a PHP script, you must use include ().
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  5. #5
    Join Date
    Mar 2008
    Posts
    349

    Re: Why we use PHAR in PHP?

    We can consider that PHP actually translating / path / to / external / file.php into a stream file: / / / path / to / file / external, and it uses so hidden functions flow flat files to access local files. To use a file named file.php contained within a phar archive / path / to / myphar.phar, the syntax is very easy :
    PHP Code:
    <?php
     
    include 'phar:///path/to/myphar.phar/file.php';
     
    ?>

  6. #6
    Join Date
    Jul 2006
    Posts
    289

    Re: Why we use PHAR in PHP?

    PharData The class provides a high level interface to access and create tarballs and zip files non-executable. Because these records do not include container and they can be executed by the phar extension, it is possible to create and manipulate tar and zip files using the normal class PharData even if the setting phar.readonly php.ini. The PharFileInfo class provides a high level interface to access the content and attributes of a file within a phar archive.
    Signatures reduce available bandwidth

Similar Threads

  1. What is the Phar manifest file entry in PHP?
    By Emily123 in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 05:53 AM
  2. How to Create Phar Archives in PHP?
    By Leoniee in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 05:29 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,513,178.78168 seconds with 17 queries