Dear everbody.
While working with the APi it is needed to create the PHP code that can consume the API.
By doing so, the developer has to make sure he/she creates all the well thought of code to
make this happen. Why invent the wheel twice?
In PHP we use a package manager name Composer. It is used to handle project dependencies.
There are a ton of PHP libraries, frameworks, and components to choose from. Your project will likely use several of them — these are project dependencies. Until recently, PHP did not have a good way to manage these project dependencies. Even if you managed them manually, you still had to worry about autoloaders. No more.
Currently there are two major package management systems for PHP - Composer and PEAR. Which one is right for you? The answer is both.
- Use [B]Composer[/B] when managing dependencies for a single project.
- Use [B]PEAR[/B] when managing dependencies for PHP as a whole on your system.
Composer is a brilliant dependency manager for PHP. List your project’s dependencies in a composer.json file and, with a few simple commands, Composer will automatically download your project’s dependencies and setup autoloading for you.
There are already a lot of PHP libraries that are compatible with Composer, ready to be used in your project. These “packages” are listed on Packagist, the official repository for Composer-compatible PHP libraries.
Source: PHP: The Right Way
Companies like Facebook and thousands of other companies understand that when it comes
to developing, you do not need to invent the wheel for a second time. Therefore they released
their API and a Composer package. (The SDK can be found here and there are some docs with it. GitHub - facebookarchive/facebook-php-sdk: This SDK is deprecated. Find the new SDK here: https://github.com/facebook/facebook-php-sdk-v4);
The composer package is a wrapper around the Facebook SDK and allows us to easily start developing on the Facebook platform.
Because composer is defacto, I would like to see a official composer package from Interworx.
Why this is handy and needed:
- Interworx API will be easier to consume
- The package is the same for everybody, so support can be better
- Github users can help build and improve
- Code that communicates with the API will be the same for everybody
- Building a Interworx dashboard in PHP project can start straight away
How this would work is:
Create a composer.json file when starting a php project. And add this:
require { "interworx/rest-api": "1.1.*" }
Then you could use it some what like this:
<?php
use InterworxAPI;
class InterworxApiController
{
$protected $api = null;
public function __construct()
{
$this->api = new InterworxAPI('yourdomain.com','99KCpD0HfLcy3iaRP0Hb4vtbAS8jbrEq');
}
public function listResellers()
{
// return nice JSON
return $this->api->listResellers();
}
}
So I would like to know if there are any plans on releasing a Composer package soon?
Some extra reference:
Dependency management: PHP: The Right Way
Rise of composer: The rise of Composer and the fall of PEAR |Articles - Fabien Potencier