Phar Hosting : Compare Hosting

Showing top 10 results Show All

Oops! No Hosting Plans Match Your Search

You've selected a combination of features that none of the web hosts we profile offer. We suggest you remove your last filter or reset & start again.

Ask Our Experts

Need help with your hosting? Tell us exactly what you are looking for and we’ll do our very best to help. Please allow one working day for a response.

Please fill in all fields.

Thanks! Your request has been sent. We'll reply within 24 hours.

Filtering by:
  • Phar
Reset

What is a Phar?

Phar is a PHP Hypertext Preprocessor (PHP) extension. It provides a way to put entire PHP applications into one single file called a PHP Archive, or “Phar,” for simple installation and distribution. Further, it provides a method of file format extraction for making and manipulating .zip and .tar files, called the PharData class interface.

Phar format files trace their inspiration to a similar Java Archive file format called JAR. In 2005 PHP programmer Davey Shafik wanted to find a way to duplicate the easy deployment of JAR files within the PHP environment and came up with the idea Phar files. After further refinement the file type was added a standard part of PHP beginning with version 5.3 in 2009.

As a general-purpose free scripting language, PHP is well suited to Web development. It's known to be flexible, practical, and fast, and so is used for everything from personal blogs to large, popular websites and applications. The code itself is interpreted by Web servers using PHP processor modules to generate Web pages. The vast functionality of PHP is expanded by extensions, of which the language has thousands. Developers may also write their own extensions for specific functionality.

Phar is a convenient means of grouping multiple files into one file, and easily distributing a complete PHP application and running it from that single file. The Phar archive file doesn't need to be extracted to a disk, and PHP executes the files easily. You might think of Phar as a sort of “thumb drive” for PHP applications. In fact, you can handle Phar archives as if they were thumb drives, using common functions to view and change files, as well as create new ones - but only if you take advantage of the option to format the Phar file as a .zip or .tar archive.

Stream wrappers allow Phar to implement its significant functionality. Streams generalize operations sharing common uses and functions, and exhibit streamable behavior as resource objects. Wrappers are additional codes for teaching streams how to use certain encodings or protocols.

Can I use a Phar file on my hosting account?

The Phar extension was added as a standard feature in PHP 5.3. PHP version 5.3 was released in 2009, so any web server that is even remotely up-to-date will be able to host and execute Phar files. PHP is supported by both Windows and Linux servers, so virtually all modern servers will support the use of Phar file extensions for PHP applications without any problem. Phar files are supported by shared servers, virtual private servers, and dedicated servers. If you have a PHP application in Phar format you want to deploy, virtually any server will do.

Why do developers package PHP applications in Phar format?

The biggest reason Phar file archives are a popular way to distribute PHP applications has to do with ease of deployment. An application that deploys from a single file is that much easier to install. If an application is easier to install it will make it much easier for users to adopt. So distributing a PHP application in a Phar archive can help increase adoption of the application.

In addition, tinkering with the code inside the files contained in a Phar archive is not as easy as tinkering with individual PHP files and generally can’t be done on a live hosted Phar archive. If you deploy a PHP application using standard PHP files and folders and you want to test out a modification it can be very tempting to tinker with the live files. However, this can create disruptions for users who happen to be accessing the application while you tinker. So developing files in standard PHP format makes for easy coding, and then compiling the files and deploying in Phar format will help discourage tinkering with live files by authorized or unauthorized users.

In short, using Phar’s make deployment and installation of PHP applications easier, and easier deployment can help improve adoption.

Are there any drawbacks to using Phar archives?

The fact that the entire application is contained in a single file is the reason for most of the benefits of Phar archives. However, this same characteristic creates some challenges.

If an application is deployed in Phar format there’s no way to push a small update. The entire application has to be replaced. So if you discover one minor issue you want to correct there’s no way to push a patch to address just that one issue to user deployments. This creates headaches for end users since updating to new versions of a Phar-format PHP application is a manual process.

Using Phar format makes it harder to look inside the file and tinker. While this can be considered a good thing since it prevents anyone from tinkering with files while they’re deployed, it also means changing the contents of the archive is difficult. So creating a custom mod in a Phar format PHP application is not easy.

Installation and upgrade instructions are usually kept in a README.txt or INSTALL.txt file in the main application folder. When you use Phar file format you’ve giving up this convention, and have to find another effective way to make sure your users have any necessary instructions for installation and upgrading.

Does a Phar archive pull the code out of individual PHP files and combine it into a single file?

No. A Phar file does not compile all of your PHP code into a single file. Instead, a Phar file is actually an archive of your PHP files and folders, but one that is designed to be executable by a web server running PHP without having to be manually unzipped or extracted.

If the Phar concept was developed in 2005 why wasn't it added to PHP until version 5.3 in 2009?

The functionality of Phar files could be achieved using a now deprecated PHP function called PHP_Archive as part of the PEAR repository. The PEAR repository package could optionally be added to any web server running PHP, thereby augmenting the functionality of PHP on that server to include the functions supported by the PEAR repository. So leading up to 2009 PHP_Archive was usable on servers with the correct PEAR package implemented. Between 2005 and 2009 the Phar concept was further refined and developed until it was ready for inclusion in the standard PHP package beginning with version 5.3 in 2009.

I want to use a Phar but also make the files within it accessible. Is this possible?

Phar files can be formatted either natively (.phar) or as a .tar or .zip compressed file. If they are formatted as either .tar or .zip they can be opened and the contents viewed using any standard tool for working with compressed files. However, if you do format a Phar archive as either .tar or .zip an additional Phar extension must be installed within the version of PHP on your web server in order for the archive to be executable by PHP. If you use the native .phar file extension then any server running PHP 5.3 or newer will execute the file without requiring the Phar extension.

So yes, it is possible make the files within a Phar archive accessible, but doing so adds the requirement that the Phar extension be installed on the web server hosting the application.

WhoIsHostingThis Recommends

★★★★
Support
★★★★
Features
★★★★
Uptime
★★★★
Value
★★★★

Pros: Free domain name , Unlimited traffic, emails, DBs

Cons: No Windows-based plans

SiteGround is an established web host managing well over 1,000 servers and... Read more

Visit host

2. iPage

ipage logo
★★★★
Support
★★★★
Features
★★★★
Uptime
★★★★
Value
★★★★

Pros: Unlimited Disk Space, Bandwidth & Email , Unlimited MySQL Databases

Based in the US, iPage specialises in low-cost shared hosting. Each plan... Read more

Visit host
★★★
Support
★★★
Features
★★★★
Uptime
★★★
Value
★★★

Pros: Free Domain , Unlimited Bandwidth

Bluehost provides customers with low-cost shared hosting, as well as reseller, VPS... Read more

Visit host

Updating...