• Increase font size
  • Default font size
  • Decrease font size
Home Software PHK Why PHK ?

Why PHK ?

E-mail Print
Read : 17,022 times
(1 vote, average 5.00 out of 5)



PHK stands for PHp pacKage. It is a package system for PHP. Unlike most file formats, used for software distribution and deployment only, a PHK application runs directly from its package file, without file extraction, making it a PHP-oriented equivalent of Java's jar features.

But PHK goes much further than a raw jar-like package builder, as it provides developers with an extensive set of high-level features, making it easy to switch an existing application to PHK.

Here are the main features, focusing on the benefits it can bring to your projects :

  • No more install procedure : Installing a PHK package is just moving a package file to its final location, optionally renaming it with a suffix corresponding to the user's environment, and that's all ! No shell access required, no chown, chgrp, chmod, gunzip, recursive ftp... Any developer involved in software support knows how valuable it can be to suppress all these basic but time-consuming installation problems !
  • Easier software management : As your software remains in a single file, it becomes much easier to manage, copy, move, remove, or upgrade.
  • No runtime needed : your customers don't have to install anything before using a PHK package, as every package contains the needed runtime code. Any PHP interpreter (version 5.3.0 or more) is ready to include or execute a PHK package without any modification.
  • Data integrity : Every time the package is loaded, its integrity is checked, detecting any file corruption like those due to file transfer issues. Please note that this feature is not a digital signature, as it only protects against unintentional modifications.
  • Fast runtime : An optional PECL extension is available. This extension acts as an accelerator and does not bring any new feature, except a dramatic performance improvement. Installing the extension is extremely easy as it is automatically and transparently used when present, without anything to configure. Work is still in progress but the objective is to make a PHK application clearly faster than its its 'unpackaged' counterpart.
  • PHK supports libraries, applications, plugins : a PHK package can contain a library or an application (an application is a library with an entry point). PHK also provides some specific features to design a plugin architecture.
  • Integrated Autoloader : PHK embeds an advanced map-based autoloader, named Automap. At package creation time, the PHP scripts are analyzed and the class/interface names are registered. At runtime, the scripts are automagically included when needed. This mechanism is fully transparent and automatic. Using this mechanism, you can remove every include/require directives from your OO software and forget 'undefined class' errors.
  • Unlimited number of subfiles in an package : a PHK package can contain an unlimited number of subfiles and directories. A subfile can contain up to 2 Gbytes of binary data. Every subfile can be, on a file by file basis, compressed (gzip or bz2), and/or stripped from comments (making it smaller and faster).
  • Webinfo introspection : the webinfo mode is a built-in introspection tool. In webinfo mode, the package file behaves like a small web site, displaying information about the package. PHK provides standard locations for meta-information like package's name, author, license, copyright, etc. It also allows to specify an icon and a reference URL.
  • Built-in CLI commands : several built-in CLI commands are available. These commands are the equivalent, in CLI mode, of the webinfo mode. They allow to display every information about the PHK package's structure and content.
  • Nested packages : PHK allows a PHK package to be incorporated as a subfile inside another PHK package, along with other regular files. This feature can be used, for instance, to integrate a library in an application, or when integrating unit tests in a package. Autoloading files from nested packages is automatic.
  • Enforces extension dependency : Through options you set at build time, each time the package is loaded, it will ensure that the extensions it requires are present. If one is missing and cannot be dynamically loaded, the execution aborts with a meaningful error message. Most important, you get the error the first time you run the package, not two months later when testing a new feature...
  • Web path protection : When accessing a PHK package directly through a web server, package subfiles are automatically protected from incorrect or unauthorized access. The legitimate web entry points are explicitely identified, making your software easier to secure.
  • Digital signatures : This feature, not available yet, will allow to digitally sign the packages you distribute (using a digital certificate). Support for nested packages is essential here, as nested packages will keep their signatures.

Enough ? OK. Now, it's time to proceed with a small tutorial, which will show you how easy it is to build your first PHK package.

 

Please login or register to add a comment