CategorySylius

PHP 7 – A new way of coding for PHP

upgrades

At the start of 2016 we have began updating our client web servers  to use PHP version 7, as we wanted to take advantage of the immediate performance benefits it brings.  We first concentrated on the low hanging fruit and updated the Symfony 2 – 3 applications that we develop and manage.  We are yet to look into updating the many  Wordpress servers we maintain as these code bases can often depend upon 3rd party plugins which may not have been tested under php 7.

Using a Ubuntu server it is quite easy to update to PHP 7 simply by adding the PPA.  Once PHP 7 is installed we can expect quicker response times (which we have witnessed) as well as access to the new features of PHP 7.

New Features of PHP 7

If you wish to read about all the new features in PHP 7 then you can do so here.  However we will discuss a couple that we have enjoyed using so far below:

Return type declarations and Scalar type declarations

This is a couple of new features we started using right away.  When developing you domain code, we practice true professionalism by practicing TDD (test driven development) and as such we also try to follow the SOLID principals.  Writing code in this way has many benefits, and it is now aided by the addition of return type and scalar argument type declarations:

public function getUniversityId() : int
{
    return $this->universityId;
}

public function setUniversityId(int $universityId)
{
    $this->universityId = $universityId;
}

Using these new features allows us in the PHP community to structure our code in a more strict way, and provides clarity when reading code.  It also allows IDEs to better predict what is expected from a method of some object.  A breath of fresh air in a language which has a bad reputation for ugly code.

Anonymous Classes

We have not used these much yet, but I can already think of many situations recently when these would be useful.  Specifying interfaces and being able to create anonymous classes that are very simple and implement those interfaces is extremely convenient.

So far PHP 7 has been a great improvement for us and we hope this continues and improves the code bases of our existing frameworks and CMSs such as Symfony, WordPress, Magento, Drupal and Zend.

 

 

 

Why developers love Sylius E-commerce

Before we tell the world how much we love using Sylius, first off we should explain what exactly Sylius is.

sylius

Sylius

Sylius is an e-commerce platform built using the Symfony 2 framework.  It is still in it’s early days and as such it is not as feature rich as some other e-commerce platforms such as Magento, however it is getting there and does already have most of the features you would expect from an online shop.

Why we love it and you should too

Sylius is built on top of Symfony 2 and as such it is built in a much better decoupled way that other e-commerce platforms.  This makes development much more enjoyable and it allows you to easily plug in any number of thousands of Symfony 2 bundles into your project (as Sylius has already done).  As you can imagine this can speed up development time a lot.

Also Sylius has been built using BDD / TDD methodologies.  This make it great to learn from a developers perspective and it allows for faster development through automated tests.  As uncle bob says “The only way to go fast is to go well”.

With Sylius being so young, it is at a great point in its development to make some contributions.  Here and here are a couple I have made myself.  Easy once you are involved and enjoyable.  There is also plenty to get involved in with regards to new features.  Simply find the repository and get involved.

Sylius is also being used in production environments already.  One such project we have built using the framework is PrecisionCodeWorks, an e-commerce store for purchasing ECU tuning file credits.

Out of the box Sylius is also quick to setup.  If you compare it to the amounts of XML for example within Magento, it is much faster to get up and running.