#IPC15 review - part I

Design how your Objects talk to each other through Mocking 

by Konstantin Kudryashov

Doubles 

Dummy - they just do nothing

Stub - care with specific arguments only

Spy - care that method is called

Mock - delayed version of Spy

Fake - fake saving into databse etc.

state vs. messages

Test-driven development 

<?php

class MyTest extends PHPUnit_Framework_TestCase
{
    public function testSomething()
    {
        $class = new Vendor\Library\Class();

        $this->assertEquals('something', $class->getSomething());
    }
}

Behaviour-driven development

<?php

class MyTest extends PHPUnit_Framework_TestCase
{
    public function testSomething()
    {
        $prophet = new Prophecy\Prophet;
        $mock = $prophet->prophesize('App\Entity\User');

        $class = new Vendor\Library\Class($mock->reveal());

        $mock->someMethod()->shouldBeCalled();
        
        $this->assertEquals('something', $class->getSomething());

        $prophet->checkPredictions();
    }
}

S.O.L.I.D

<?php

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class TestController extends Controller
{
    public function indexAction()
    {
        $products = $this
            ->getDoctrine()
            ->getRepository('AppBundle:Product')
            ->findAll()
        ;

        return $this->render('hello/index.html.twig', array('products' => $products));
    }
}
<?php

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class TestController extends Controller
{
    public function indexAction($repository)
    {
        $products = $repository->getAllProducts();

        return $this->render('hello/index.html.twig', array('products' => $products));
    }
}

From 1 to 20 Million Users, the technical Story of BlaBlaCar 

by Matthieu Moquet

Behind the Scenes of Maintaining an Open Source Project 

by Jordi Boggiano

At the Push of a Button, and without a maintenance Window 

by Arne Blankerts & Sebastian Bergmann

How to deploy? 


  git pull && composer update

Active sessions 

Data structure changes / layout changes

SSH usage

Packaging

Build

Distribute

Activate

User session versioning

Running PHP on NGINX – Tips and Tricks for High Performance Websites 

by Harald Zeitlhofer

PHP 7 – What changed internally? 

by Nikita Popov

As a result of an engine rewrite with focus on more efficient data structures, PHP 7 offers much improved performance and memory usage

<?php

declare(strict_types = 1);

class Foo
{
    function increment(int $a): int
    {
         return $a + 1.0; // strictly type checked return
    }
}
  • scalar type(int, float, string and bool) declarations
  • return type declarations
Made with Slides.com