Skip to main content

Deploying PHP applications as PHAR archives

             
               Deploying PHP applications as PHAR archives

Today I discovered a very powerful addition to the PHP world. Phar is an archive extension for PHP that allows an entire PHP application to be packaged into a single file. It's basically PHP's answer to Java's .jar archive format. Don't get excited yet, it gets better...
There are a few things that make this particularly handy. For one, it is being integrated into the next major PHP release (5.3) which means that any standard PHP installation running the latest version will support .phar files right out of the box.
The other advantage is of course in deployment. Using a .phar file you can deploy an entire PHP application by working with just one file, rather than a bunch of files and directories. This is where .phar really shines. Imagine deploying a popular web app like WordPress by simply copying a single .phar file to your web server's root, rather than figuring out how to zip it up, upload it, and somehow unzip it remotely. Piece of cake!
The development side is equally as simple, being able to access files within the .phar file as easily as if it were another directory in the file system. The .phar file itself can be included in a script using any of PHP's standard import constructs (include, include_once, require, require_once). This also means external libraries can be more easily integrated, having just a single file to include in order to utilize a given library. A .phar archive can also be accessed as a stream using the same functions used to read/write other types of streams.
Certainly there are disadvantages as well, and this is not a one-size-fits-all solution. Using .phar files does result in a performance hit, meaning traffic-intensive sites and heavyweight applications are probably not the best place to use this tool. It also may not be ideal for a web app that is fairly modular, or other situations where source files might be added or removed on a regular basis. It does have its uses though, and for me it will be a welcome addition to the PHP core.
Reference:
#site_crafting

Comments

Popular posts from this blog

NOCOPY Parameter Hint in PL/SQL

Before we get to understanding the NOCOPY parameter hint in PL/SQL, it would help to first look at PL/SQL parameter modes and the ways in which they pass values in and out of a subprogram. PL/SQL subprograms have three parameter modes: IN parameter mode is used to send values into the subprogram from the calling program. An IN parameter can only be read, its value cannot be modified inside the subprogram. OUT parameter mode is used to return values from the subprogram to the calling program. IN OUT parameter mode is a hybrid of IN and OUT. It is used to send values into the subprogram, and its value can be modified within the subprogram. On exit, the subprogram returns the updated value of the IN OUT parameter to the calling program.  Continue reading at Source :  NOCOPY Parameter Hint in PL/SQL

Paradoxes

1 What runs but has no legs? Your nose a river a comb your word a bottle ________________________________________ 2 What runs but has no legs? A tap a river a comb your word a bottle ________________________________________ 3 What can stay in the same corner but, at the same time, travel around the world? A tap a stamp a comb your word a bottle ________________________________________ 4 What has a mouth but does not speak? A towel a river a comb a book a bottle ________________________________________ 5 What is black when it is clean and white when it is dirty? A tap a stamp a blackboard your word a bottle ________________________________________ 6 What has a bed but does not sleep? A towel a river a comb a book a bottle ________________________________________ 7 What has teeth but cannot bite? a towel a river a comb a book a bottle ________________________________________ 8 What has a neck but no head? a towel a river a comb your word a bo