PHP Auto Update Script 1.3 brings new API to PHP self-update system for even more powerful automation.
Last week, we announced Auto PHP Licenser 2.2 with completely new API. Today, we release PHP Auto Update Script 1.3 to bring all the benefits of new API into PHP version management software. Those already owning a copy of PHP license manager can upgrade right away; they already know how new API works. Hence, we dedicate this post to developers who are not familiar with new phpmillion API yet. Let the fun begin!
The first and most obvious change is response body. Starting with version 1.3, PHP self-update system always returns JSON-based data. No matter which API function script called and what result was, response body always contains JSON data. At the same time, each API call now returns additional fields for easier and more detailed debugging. Here’s an example response from new PHP auto update system:
Array ( [api_action_success] => 1 [api_error_detected] => 0 [action_success] => 1 [error_detected] => 0 [page_message] => My-Product-Name version 2.0 added to the database. )
Attention: API response is json-encoded by default, we decoded data in this example for easier reading.
As can be seen from response data, PHP version management software called API to upload a new version (2.0), of product My-Product-Name to updates server. Obvious, isn’t it? Now, let’s analyze each of these 5 fields.
New API response fields in PHP self-update script 1.3.
The first two fields (those starting with api_) indicate the status of PHP Auto Update Script API itself. No matter the final result, api_action_success should always return a value of 1, while api_error_detected should return a value of 0. If PHP self-update script returns opposite values, it means there’s a problem with API itself. The cause might invalid security key, unauthorized IP, API being disabled, and so on. In either case, page_message field will return the exact reason for easy fixing.
If API itself works and call was authorized, two other fields (action_success and error_detected) will indicate the result of original request. In the example above, call succeeded; therefore, action_success contains a value of 1 and error_detected contains a value of 0. In case original request fails (for example, version already exists), those fields will contain values of 0 and 1, while page_message will report: Duplicated version.
How to upgrade PHP auto update system?
As usually, upgrade is very straightforward; click Maintenance > Software Updates and confirm this upgrade. New API uses exactly the same authentication methods and function arguments as old one; therefore, old API calls work with new system out of the box. Authors, who want to take benefit of new API features, might need to update their scripts accordingly, but, thanks to full backwards compatibility, this step is optional. Needless to say, we also updated PHP self-update system documentation; check it out for more details on new features.