PHP PHAR: Once again about creation of .phar in a proper way

Asked
Active3 hr before
Viewed126 times

5 Answers

90%

Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,The question is: how to create a PHAR archive for use as a PHP resource that I can simply 'include'?,Connect and share knowledge within a single location that is structured and easy to search., With enough copper wire, can I attach one end to one side of a 9V battery, then circle the earth and connect it back?

To set the shebang, use:

$phar - > setStub("#!/usr/bin/env php".PHP_EOL
   .$phar - > createDefaultStub(file_get_contents('st.php')));
88%

Example #3 Converting a phar archive from phar to tar file format, The phar extension is also capable of converting a phar archive from tar to zip or to phar file format in a single command: ,Example #2 Using a file within a phar archive, In fact, one can treat a phar archive exactly as if it were an external disk, using any of fopen()-related functions, opendir() and mkdir()-related functions to read, change, or create new files and directories within the phar archive. This allows complete PHP applications to be distributed in a single file and run directly from that file.

<
? php include '/path/to/external/file.php'; ? >
load more v
72%

PHAR files may be in one of three formats: tar, and ZIP, which are compatible with their respective tooling, and a custom PHAR format. Regardless of the format used, all PHAR files use the .phar file extension. Tar and Zip format archives may be created and unpacked using standard tar and zip utilities, while the PHAR format requires custom PHP code using the PHAR extension for PHP, or the PEAR PHP_Archive package. ,A PHAR file allows for a Tar, Zip or PHAR formatted archive. Regardless of format, each archive contains three sections: ,In software, a PHAR (PHP Archive) file is a package format to enable distribution of applications and libraries by bundling many PHP code files and other resources (e.g. images, stylesheets, etc.) into a single archive file. ,Additionally, it is possible to mark a PHAR file as executable, and to add an appropriate shebang to make the PHAR executable directly.

In software, a PHAR (PHP Archive) file is a package format to enable distribution of applications and libraries by bundling many PHP code files and other resources (e.g. images, stylesheets, etc.) into a single archive file.

PHAR files may be in one of three formats: tar, and ZIP, which are compatible with their respective tooling, and a custom PHAR format. Regardless of the format used, all PHAR files use the .phar file extension. Tar and Zip format archives may be created and unpacked using standard tar and zip utilities, while the PHAR format requires custom PHP code using the PHAR extension for PHP, or the PEAR PHP_Archive package.

.phar
load more v
65%

After creating the runner, your web root should look like this:,Then open a terminal window, navigate to the myapp directory and run it:,The contents of index.php looks like:,Begin by creating the application’s directory structure; somewhere on your system, create the following:

Open php.ini, find the phar.readonly directive, and modify it accordingly:

phar.readonly = 0
load more v
75%

Now run composer in order to run Composer instead of php composer.phar.,This is the easiest way to get Composer set up on your machine.,Now run php bin/composer in order to run Composer.,Now run php composer.phar in order to run Composer.

You can install Composer to a specific directory by using the --install-dir option and additionally (re)name it as well using the --filename option. When running the installer when following the Download page instructions add the following parameters:

php composer - setup.php--install - dir = bin--filename = composer
load more v

Other "undefined-undefined" queries related to "PHP PHAR: Once again about creation of .phar in a proper way"