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

The Miraculous Plants

It was a very cold winter, with snow everywhere. For the eastern tribe, it was a terrible time .many people were sick and there was no medicine to help them .every day, people died .the leader didn't know what to do .his cute son, Bassou, was also very ill. If he couldn't help him, he was going to die, and thus the tribe will die out. The leader sat by his fire, but he didn't feel warm. ''It’s the end '', he thought.’ If he dies, I don't want to live '' he looked into the fire. The wood burnt noisily. Suddenly, he remembered his wiser teacher, and he heard his fierce words ''you must save your son, and your tribe .go and look for the medicine! There is a medicine for everything. Go quickly! It will soon be too late '' The leader began his journey that night. He walked through the snow and the dark forest all night. In the morning, he was cold and hungry. '' How can I find the medicine plants which will ...

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

Green planet

Fifty years ago green was just a colour .Now it’s a way of looking at our world .But how green is our planet today? Planet earth On February 2002, scientists in kourou, French Guiana, were worried. They knew that in a few hours ‘time the Arianne rocket would leave on its journey .on the rocket was Envisat, the biggest and most expensive satellite ever made in Europe .Envisat was ready and waiting after twenty years’ work by hundreds of people .but now , at the last minute, something was wrong with the rocket carrying the satellite. Scientists worked all night to get the rocket working again .late in the evening on 1march everyone in kourou stopped working to watch the rocket leave. The weather was good and the rocket was ready .five four three two one ......the Arianne rocket went up into the sky, carrying Envisat with it. What is special about Envisat? It is as big as a bus, and very heavy. It travels 800km above the earth, and it goes round the earth once every 100 minutes. Envisat g...