Why PHP Is Awesome
Honest.

@magma_digital
The Team

@magma_digital
Speaking today
Jeremy Coates
@phpcodemonkey

@magma_digital

Steph Cook
@stephcook22

Damien Walsh
@themainframe
“PHP is used by 81.8% of all the websites
whose server-side programming language we
know.”
– w3techs.com

@magma_digital
@magma_digital
So why the reputation

@magma_digital
PHP has moved on.

@magma_digital
The dark ages…

@magma_digital
//genearate a filename...

$fn_temp = preg_replace("/[^a-zA-Z0-9s]/", "", $_POST[‘f_n’]);	

Magic strings…

//Does it exist?

while(file_exists("/home/cocoder/.data/{$fn_temp}{$n}/"))

$n++;	
?>

<h1>Project Created!</h1> 

<?php


Suddenly… HTML



//DB...

$return_id = cc_core::make_project(

$_POST['n_name'],

i
($fn_temp.$n),

$_SESSION['user_id']

);



?>

@magma_digital

Highly procedural
Now…

@magma_digital
public function editAction(Request $request)

{

$this->form->handleRequest($request);

	
$entity = $this->form->getData();	

	

Interact with Model

if ($this->form->isValid()) {

$this->em = $this->doctrine->getManager();

$this->em->persist($entity);

$this->em->flush();

}




	
	
	
	
	
	

	
	
	
	
	
	
}

return $this->render(

	
‘TestBundle:Items:edit.html.twig',

	
array(

	
	
'entity' => $entity,

	
	
'form'
=> $this->form->createView()

	 )

);


@magma_digital

Render View
The cool stuff
To make your projects easier

@magma_digital
@magma_digital
Composer
curl -sS https://getcomposer.org/installer | php

@magma_digital
Composer
composer.json:
{

"require": {

"monolog/monolog": "1.2.*"

	 }

}

@magma_digital
Composer
include
include
include
include
include

@magma_digital

‘classes/Foo.class.php’;

‘classes/Bar.class.php’;

‘classes/OtherStuff.class.php’;

‘classes/MyClass.class.php’;

‘classes/AnotherClass.class.php’;
Composer
include ‘vendor/autoload.php’;	
...



$foo = new Foo();

@magma_digital
Silex

@magma_digital
Silex
composer.json:
{

	
	
	
}

@magma_digital

"require": {

	 "silex/silex": "~1.1"

}

Silex

Fire up composer.

require_once __DIR__ . '/../vendor/autoload.php'; 	
$app = new SilexApplication(); 	

Create the App

$app->get('/hello/{name}', function($name) use($app) { 	
return 'Hello '.$app->escape($name); 	
}); 	
$app->run();

@magma_digital

Be safe!
Run it.

Add a route
Twig

@magma_digital
Twig
<ul>	
{% for user in users %}

<li> {{ user.name }} </li>

{% else %}

<li>

	 	 <strong>No users have been found.</strong>

	
</li>

{% endfor %}	
</ul>

@magma_digital
@magma_digital
Xdebug!
Install the extension
Install the browser extension
Setup for integration with IDE (NetBeans, PHPStorm)
Press Play
Refresh your page
Profit

@magma_digital
Codeception

@magma_digital
Codeception
$I = new WebGuy($scenario);

$I->wantTo('create a wiki page');

$I->amOnPage('/');

$I->click('Pages');

$I->click('New');

$I->see('New Page');

@magma_digital
Full Stack Frameworks
Symfony2 & Zend Framework 2

@magma_digital
@magma_digital
@magma_digital
Types of Projects

@magma_digital
@magma_digital
Manchester Digital has revealed that 32% of
digital organisations in the region were forced
to refuse work in 2013 due to a lack of resource,
despite 83% of businesses experiencing
growth.

@magma_digital
Get involved!

@magma_digital
@magma_digital
PHPNW

@magma_digital
Have we convinced
you yet

@magma_digital
All resources over here:!
http://bit.ly/phpawesome

@magma_digital

Why is PHP Awesome