Migration from 3.0 to 3.1

1. Introduction

Version 3.1 is almost fully compatible with it's predecessor. After execution of the automatic migration only minor adaptions are necessary as described in chapter 3.

As of the 3.1 release enhancement of version version 3.0 will be discontinued. Security and bug fixes will be available until end of 2016.

This article shows how to update your application to APF version 3.1. As you might already be familiar with from previous versions migration can be done in an automated fashion for nearly all changes. For this reason, the release contains two scripts: migrate-code.sh to update your HTML and PHP files and migrate-config.sh for configuration files.

The APF team recommends to use the migration scripts rather than upgrading manually. This not only saves time and money but also ensure that all relevant areas of your project code are covered.

The below chapters contain an in-depth description on how to switch to APF 3.1 and which kind of changes have to be applied to your existing application(s) to run them based on this version.

2. Automated migration

Migration can be done using the migration script shipped along with the release. This release includes changes to code, templates, and configuration files. Using migrate-code.sh and migrate-config.sh you can easily be adapted your existing application to the new scheme.

Please be sure to execute all steps described under Migration from 2.1 to 3.0. In case you are using an order version of the APF, please completely migrate to version 3.0. Instructions can be taken from Articles.
Please create a backup before execution of the scripts to be able to restore parts of your application if necessary!

In case your development environment is windows, please install the latest cygwin version (download under cygwin.com). Migration for Windows Batch Scripts is not supported.

To update the code files to the latest scheme, please execute the script as follows:

Please change to the code directory before execution to avoid unexpected results.
Code
$ /path/to/APF/migration/migrate-code.sh /cygdrive/c/xampp/php/php ############################################# # APF 3.1 automatic code migration # ############################################# Checking PHP executable available ... [OK] Using given php executable at /cygdrive/c/xampp/php/php. PHP Version: 5.6.12. ############################################# Starting migration ... * Migrate request and response obtaining ... * Migrate method signature ... ############################################# Migration done! Please check your code and follow instructions within migration documentation!

To update the configuration files to the latest scheme, please execute the script as follows:

Please change to the configuration directory before execution to avoid unexpected results.
Code
$ /path/to/APF/migration/migrate-config.sh /cygdrive/c/xampp/php/php ############################################# # APF 3.1 automatic configuration migration # ############################################# Checking PHP executable available ... [OK] Using given php executable at /cygdrive/c/xampp/php/php. PHP Version: 5.6.12. ############################################# Starting configuration migration ... ############################################# Migration done! Please check your configuration and follow instructions within migration documentation!

3. Manual steps

Unfortunately, not all components of your application can be migrated by the delivered scripts. This chapter lists all changes to be applied by hand.

3.1. Request and Response access

To ease unit test creation access to Request and Response has been changed to an instance-based approach. Instead of

PHP code
self::getRequest()

please use

PHP code
$this->getRequest()

now. This eases MOCK'ing in unit tests.

In case static access is required on the Request please use trait APF\core\http\mixins\GetRequestResponse containing static method getRequestStatic().

Same applies for the Response. Instead of

PHP code
self::getResponse()

please use

PHP code
$this->getResponse()

to obtain an instance of the Response implementation. As for the Request you can may also want to use getResponseStatic() for static access.

3.2. Method signature change

Version 3.1 introduces the abbreviated array notation into the APF code base. To ensure compatibility of your application the APF team recommends adaption of all methods overwriting APF methods. For this reason, please replace all occurrences of e.g.

PHP code
public function setAttributes(array $attributes = array())

with

PHP code
public function setAttributes(array $attributes = [])

Searching for the relevant lines you may want to use the following regular expression:

Code
( |\()array\(

Comments

Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.
There are no comments belonging to this article.