Over the past few years, dependency management tools have become a key component to successfully building high-level applications.
The number of third party libraries (with all the dependencies involved) has just insanely grown during the last few years – and expected to grow even more in the upcoming years – that managing the packages, the versions and the dependencies can become a serious nightmare for both developers and project managers. Dependency management tools therefore provide solutions to relieve them of the hassle of keeping dependencies up to date and organized so they can focus on their main mission, building awesome applications.
To make libraries easily shareable online and available for downloads, submissions, updates, bug reporting…Dependency management tools rely naturally on central repositories (we can name Maven central repository for Java, PyPI for python…and the list goes on).
As introduced in our previous posts, our Java SDK is already available on Maven, our Python SDK is also available on PyPI, so the next move logically is to add the PHP SDK to a central repository for PHP to make it easily available for the public…but what do we have for PHP?
In the same logic as most dependency management tools , Composer is available via command line interface which offers indeed way more powerful possibilities than a GUI.
To be able to execute Composer commands, you need to have it installed first on your computer, for more information you can refer to install composer.
Once composer is successfully installed, you can check if your environment is well set up via the following command :
Your first sample code
Next step is to create a sample code to call method getVersionInfo() from Class Core on pma-php (once obviously installed via composer).
To install pma-php via composer in a PHP project, you simply issue the following command in the project folder :
As you could already notice, we didn’t specify any version to install for composer, so it installed automatically the latest release (v22.214.171.124).
Targeting a specified release is straightforward via this command :
For the list of available releases for pma-php library, you can refer to its official Packagist page
Once the library pma-php is successfully installed on a project folder, the following files/folders are created :
Next step is to create a PHP file to call method getVersionInfo() of Class Core on pma-php :
<?php require_once 'vendor/autoload.php'; use Pathomation\PmaPhp\Core; echo Core::getVersionInfo();
Running this script returns value “126.96.36.1996”, which is the version of PMA.start installed on my own computer.
That’s all it takes! easy, isn’t it?