If you want to test your Zend Framework 2(ZF2) or any PHP application with PHP7 we have a good news for you! We have prepared new isolated development environment based on our previous box.
PHP7 is the next generation of PHP that promises big performance improvement (around 1,5 to 2,1 times faster than PHP 5.6 ) and additional syntactic sugar.
At the moment PHP7 is still in heavy development and the installation and updates in your existing operating system can be challenging. Therefore we have prepared for you a script that can help you create an isolated development environment with PHP7 and the sample application from “Learn ZF2” in it for your testing pleasure. Of course you can add your own PHP applications to the box and test if they are working with PHP7.
Here are the steps that you need to create your own dev box with PHP7.
First you will need to install the latest version of Vagrant and Virtualbox. If you are using Ubuntu 14 you can check the instructions on that external page.
Then you need to clone the learnzf2-box repository using the following command:
git clone -b php7 https://github.com/slaff/learnzf2-box.git learnzf2-box-php7
And when the repository is cloned you have to start the virtual machine using
After some minutes you will have brand new isolated development environment with Ubuntu 14, apache web server with PHP7 and the latest version of the “Learn ZF2” source code from github.
In order to ssh to the virtual machine you can type
And in order to access the web server from outside you can type in your browser http://localhost:8080
The source code is in a shared folder named dev and can be accessed and modified both from inside the virtual machine and from your physical machine.
As a follow-up to our Zend Framework 2 (ZF2) performance article we created a composer package that can be used right away in your ZF2 application.
We have noticed that in real world applications routing can take
300 ms or more. With this module the routing can take less than 40 ms.
Run the following command from the root folder of your ZF2 application.
php composer.phar require learnzf2/route-cache:*
First: To enable the module make sure to add it to the list of modules in your config/application.config.php.
Second: This module requires a cache service that is called “var-cache”. The cache service
should be able to store variables. If you already have such a service but it has a different name then you can use aliases in the service_manager section of your application configuration. This can be achieved by adding the following lines:
'service_manager' = array(
'aliases' => array (
'var-cache' => '<your-cache-service-name>'
If you don’t have a cache service in your application then copy the file
vendor/learnzf2/route-cache/config/cache.local.php.dist to config/autoload/cache.local.php.