Daniel Gafitescu Freelance web developer focused on open source solutions


​ O’Reilly – Up to Speed with PHP 7

Recently I had updated my VPS Php version to 7. It was easy and pretty smooth. I only had to add a single file so that WordPress would work with mysqli extension instead of old mysql extension which was deprecated.
I wanted to see what's new in Php 7 and I saw that O'Reilly had a course about it so I went and what it. Here is a short review of the course.

Php 7
- first major version release since PHP5 in 2004 after Php6 was abandoned in 2010
- is powered by a new engine PHPNG ( Php new generation)

Changes :

Internal changes
- according to Rasmus Lerdorf 100%+ performance on the most real-world apps
- lower memory usage
on Wodpress 4.1.1 PHP7 is slightly slower than HHVM 3.6.1
- simplifies creating add-on tools
- yield doesn’t require parentheses
- empty list() now allowed
- 64-bit integer support in Windows
- support for strings >= 2^31 on 64-bit builds ( video file conversion as string )
- very few breaks in backward compatibility
- most fatal errors now catchable ( Exception being thrown)
- mysql extension has been deprecated
- new json extension
- assert controller by configuration settings
- posix regex has been removed
- alternative php tags have been removed
- assign of new by reference has been removed

New operators:
- Spaceship operator ( already in Perl & Ruby )

$a = 6;
$b = $c = 10;
echo ($a <=> $b); ==> -1
echo ($b <=> $c ); ==> 0
echo ($c <=> $a) ==> 1

- Null coalesce operator

$variable = $non_existent ?? ‘default’ ;
also can be used in cascade
$var = $non_existent ?? $name ?? ‘default’;

Unicode escape syntax

$name = “Caf\u{00e9}” => Café

- random_bytes(20) ( Usage bin2hex(random_bytes(20));
- random_int(1,6) ==> generate a number between 1 and 6

Return type declaration
- is optional
prevent unintended return values
- forces sub classes to return expected data type

function convertor($string) : array {
return $array;

- Scalar type hinting
used for boolean (bool ), integer(int), float & string
- optional
- have 2 modes week & strong ( is done by declare(strict_types=1);
and needs to be first statement in the file

function multiply(int $a, int $b): int {
return $a*$b;

Anonymous classes
-can be assign to a variable
-return from a function
-pass as argument to a function
-extend a class , implement interface & use traits
- can’t be serialised

$testClass = new class() extends SplHeap {
protect function test($data1,$date2)
return ($data1 <=> $data2);

Generators return expressions

function generate() {
$total = 0;
for($i=1; $i<10;$i++) {
yield $i;
$total += $i;
return $total;
$counter = generate();
foreach($counter as $number)
echo $number;
echo “total = “. $counter->getReturn();

Generator delegation;
Binding to closures at call time;
Grouping Use Declarations

use SomeNamesSpace\SomePackage\SomeClass;
use SomeNamesSpace\SomePackage\SomeOtherClass;
use SomeNamesSpace\SomePackage\SomeDifferentClass;

Some as

use SomeNamesSpace\SomePackage\ {SomeClass, SomeOtherClass , SomeDifferentClass};

- Can be used for constants a function as well & even mix and match;

-catching fatal errors using Error class
-errors and expectations belong to different classes
-both implement the Throwable interface
-errors/exception can be catch in block

Other improvements
-improve security of unserialize;
-preserve 0 fraction when encoding as JSON

Tagged as: , , No Comments

Became a Zend Certified Php Engineer


At the begging of 2013 I have read the article Become a ZCE in 2013 so I have set myself the goal that by the end of the year I should do be a Zend Certified Engineer. For the next 11 month I have totally forgot about it and in December I saw a tweet that said that Zend has upgraded the certification from Php 5.3 to Php 5.5 & rebranded from Zend Certified Engineer to Zend Certified Php Enginner so I bought a voucher.

The voucher is available for a year long so it gives you plenty of time to prepare for it, but I chosen the second to last day of the year to take it which was in fact the last day that I could schedule that exam. Ever since I have finished the university in 2008 I haven't taken an exam and I missed the thrill of going to one and even if I wasn't 100% sure I'll pass I went anyway. After the first 15-20 questions I was pretty confident that I was going to take it and in the end I wasn't sure on 4 questions , 2 of them were theory questions and the other 2 were code samples.

Advantages of being ZCE

  1. Proof that you are senior developer
  2. your future employ will be easier pursued into hiring you, and you can demand a raise on the current one
  3. looks good on your resume
  4. You will get to put a nice icon on your website ZCE logo to prove that you are certified and link it to Zend Yellow Pages.
  5. fill in the gaps in your Php knowledge and learn new stuff so you can use later

Testing system

I quite liked the testing system which was quite simple and intuitive. You have to answer 70 questions in 90 minutes , so you have around a minute and 30 seconds per question which is quite enought. Most of the time the question that are theoretic can be answer just in few second and you should take the time left to focus on the code sample ones.

If you are not sure of an answer you have the option to mark it for review and go back to it whenever you like, and even if you forget about it when you finish the exam you are asked to check again the marked for review questions. I was given 2 sheets of plastic paper that can be easily erased and 2 markers if you need to write something down other than that you can have anything with you.

As far as I recall around 15-20 question are from the new material starting with Php 5.4. Even if there are 70 questions in one question you are required to know the theory from several topics so they will cover the whole spectrum.

If you fail the exam they give you a report on specific topics that you lack knowledge so that you can improve on them next time but they don't give you the specific questions that you failed.

In order to find a test center you can access Zend Technologies Certification Testing from Pearson Vue but most likely you'll find one if you live in a big city.

Type of questions

There are 3 types of questions:

  1. Single answer. You are given 4 options in which just one is correct. Most of the question are like this type
  2. Multiple answers. You are given at least 4 options in which at least 2 of them are correct.This type of question are marked as multiple and you can easily figure it out because you get checkboxes instead of radio buttons.
  3. Fill in the blanks. You are given a sentence that you have to word or a phrase. In one of the questions I was given it was require to give the name of a function (func_num_args). There are only 2 or 3 questions like this one.

Where to study from ?

  1. The main source is obviously is the official website: php.net
  2. Video training
  1. Books
  1. Blogs that you can find by googling ZCE


  1. Don't pay the full price for a voucher

There is always a coupon code that you can use and get at least 10% of the Zend PHP Certification Voucher and you can get it just by doing a simple search on google. I have used the coupon code CJ4ZEND which is around $15 off the total of 195 and the coupon still work today. Also if you fail the exam for the first time, the second time you want to buy the voucher you will have a discount.

  1. Zend Certification Study Guide

You get a pdf file to down in email once you buy the voucher but seems like the file is not there any more http://static.zend.com/topics/PHP-5-3-Study-Guide-v1.pdf . In this draft pdf file you got sample questions devided per chapter but from my point of view they were easier than the one from the actual exam

  1. Read the php docs on the ebook reader/table device

In my case I have download the the php documentation fromhttp://doc.php.net/downloads/epub/php_manual_en.epub as epub format and read it on my kindle where I can make notes with ease.

  1. Test Prep: Zend PHP Certification online course

There is a very expensive test preparation from Zend which cost $1000 including the examn voucher which from my point of view is quite expensive.

  1. Upgrade from PHP 5.3 Certified

In October 2013 at a Zend Conference in Paris the new certification has been announce and it included PHP 5.4 and 5.5 and keeping a lot of the question from the previous exam but you can easily apply for an upgrade if you are allready PHP 5.4 Certified. In my case I have waiting for the new Php 5.5 certification for quite a while and everytime I email Zend they replied that it was a working in progress and they didn't have a release date. The chapters has been upgraded as well and you can found them in Exam information section.


They way I prepared was quite simple: I allocated 4 hours per each chapter and I have started with the part that was most familiar with and increase the time on the chapters that wasn't that good at like regular expressions, SPL and Traits in my case. In order to pass the exam you should be flawless on the Php Basics and you must treat all the question here as a trap. Don't always go for the obvious answer especially that you have code that you need to check. In my mind come the example with the strpos function.

if (strpos('abcdefg','abc')){
    echo "found it!";
    echo "didn't find it..";

At first glance you would say that it will echo "found it" but if you pay closer attension the strpos will return 0 which will be cased to a false boolean so in fact it will show "didn't find it..".

For the SPL which I never used before I study from the php|architect's Mastering the SPL Library and was just frustrated that I didn't used this before but after looking and studying it now everything that I can do with SPL I am using it. Regular expressions were another chapter that I wasn't that familiar with and I payed more attention to it and to the php functions.

All the function regarding strings, array & file management you need to lean by heart if you don't know them by now and also the operator priority list is another part that you need to be familiar with.

For the XML chapter you got to deal with SimpleXml , DOM and for this the best aproach was to get a xml file and play with all the function and methods so you can get more familiar with it. I have got 5 question involving XML so practicing was very importing on this matter.

Where to go next

Working in our field where thing change with such a pace and new technologies and framework emerge so often it's hard to settle for a certain version or framework. You always have to learn & research so you be up to date, and this sort of certification prove that you do that and you are always trying to improve and move forward.

There are a lot of other test/certification that you can take. The most appealing for me right now it's the Sensio Labs's Symfony certification specially if you are working with Symfony 2. There is also the Zend Framework 2 certification that you can take also from Zend. There is also ThePHP Curriculum which look really promising and the fact that Sebastian Bergmann ( the PhpUnit creator) is behind the project.

Anyway if you are looking forward to take the exam good luck with it and if you allready have passed it please share your experience in the comments below.


Lynda.com PHP 5.4 New Features review

Another great title from Lynda.com on the Php server side programming :
PHP 5.4 New Features .

What can you learn from this title :

  • How to install Php 5.4 on Windows , Unix & Mac OS X
  • Built-in web server
  • Improvements on array handling
  • New features like JsonSerializable ,closures , http_response_code
  • Access class members on instantion
  • Traits

Quick comparison between Symfony 1.4 and Zend Framework 1.1

Quick comparison between Symfony 1.4 and Zend Framework based on my personal experience.

MVC structure
Both framework are using the MVC pattern but they have a different structure of the code organization

Symfony : Project > Applications (Frontend/Backend) > Modules > Actions (controllers) > Views

Zend Framework : Application > Modules > Controllers > Views

Command Line
Symfony is using heavily  CLI to generate code and default structure on the other site ZF is using something similar ,  Zend Tool but it's not that powerful as the SF one.

Code organization
Zend Framework is a loosely-coupled architecture allows developers to use components individually like ( Zend_Search_Lucene ) on the other side Symfony is a full stack framework  that standardize the development of a web app.

Database (Model)
Symfony is using Doctrine/Propel ORM  as the Model and ZF is using Data Mapper classes to interact with the database, but as well can be extended to use Doctrine as well.

Testing enviroments

ZF as well as SF is using environments , most common configuration are local , dev , test and production. You can do a lot of changes from this perspective since you can log and debug easily and use different approaches to test the live site and see debug information only from a certain IP address.

The configuration files :
Symfony is using YML standard for configuration files and uses a hierarchy and same configuration can be found in many files, this means that's override.  There is also an inheritance of the environments settings that you can again override whenever you like. Zend framework on the other side uses by default .ini files but you can change that to use xml or php files.

Unit testing

From the unit testing perpective Zend framework is using PHPUnit the  de facto standard on unit testing on Php oppose to Symfony who is version 1.4 is using Lime. You can still use PHPUnit with Symfony 1.4 but you need to install a couple of plug-ins.


Symfony is using scaffolding & admin generator to do CRUD operation on a database table structure , Zend Framework doesn't have that build in but can be extend to do something similar.

Extending the framework
Symfony can be easily extended using plugin and libraries , even use Zend framework stand alone components , on Zend Framework you can extend current component or you can as well use external libraries.


Both framework have huge communities around them starting with forums, email lists and irc chats channels. Also they have dedicated conferences : For Zend Framework you have ZendCon and Symfony has Live Symfony .

Company behind it

The company the Zend Frameword is Zend who is a PHP company all the way from IDE, code protection & obfuscation with Zend Guard,  Zend Server  , certifications, training  and more recently the cloud computing solutions. All this play nicely with each other but in order to have them you need to pay.

On the other end Symfony is a Sensiolabs release started by Fabien Potencier. Sensiolabs offers trainings, organize conferences and offer support on Symfony projects.

On 28th July 2011 Symfony2 was officially  launch which take the framework to a next level embracing Php 5.3 namespaces , decoupling of modules which some of them are going to power Drupal 8, choose PhpUnit as a standardized testing framework, new templeting system (Twig) , MongoDB support and Doctrine2 for working with databases.

On the other hand Zend Framework 2 is still in beta3, so from my point of view are a step behind Symfony.

Airbus vs Boeing

Don't know why for me it's the first thing I got on my mind when I compare these 2 frameworks. The French have launched A380 in late 2007 and  USA rival Boeing 747-8 was launched in mid 2011 and its the French who win here.


This comparison is a subjective one each framework it's great if the right coder is using it and since everyone is different will be different conclusions.As for me I am going with Symfony ...even with Symfony 1.4




PHP & MongoDB Web Development: Beginner’s Guide

A very well written book with lots of example that get you started with MongoDB and Php. It also covers GridFS and session manager build upon MongoDB .

Tagged as: , , , No Comments

MVC Frameworks for Building PHP Web Applications from Lynda.com

A great objective overview of the 4 most used and popular frameworks Zend Framework, Symfony, Codeigniter and CakePhp.

Drew Falkman goes and show each framework features, what patterns it uses and implements a single join email list application which uses all MVC concepts.

For a php developer it's a must watch tutorial so when you start a new project you can see which framework to use.

Go check it out!