Why is PHP Awesome

Preview:

DESCRIPTION

University of Manchester: COMP101 Guest Lecture Monday 10th March, 11am Kilburn LT1.1 This talk will argue that PHP's bad reputation is a thing of the past and look at where and how PHP is used in the wild. We will describe some really useful tools and libraries which people can take away and play with. We will touch on the jobs market for PHP, agency working and how to get involved. We will finally talk about the huge community for PHP around the world but also specifically in Manchester. Speaker Biographies: Steph Cook @steph_cook22 and Damien Walsh @themainframe are web developers @magma_digital and recent graduates of @csmcr. Jeremy Coates @phpcodemonkey is the Managing Director of Magma Digital, the leading software development agency in Lancashire.

Citation preview

@magma_digital

Why PHP Is AwesomeHonest.

@magma_digital

The Team

@magma_digital

Speaking today

Jeremy Coates @phpcodemonkey

Steph Cook @stephcook22

Damien Walsh @themainframe

@magma_digital

– w3techs.com

“PHP is used by 81.8% of all the websites whose server-side programming language we

know.”

@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-9\s]/", "", $_POST[‘f_n’]);

//Does it exist? while(file_exists("/home/cocoder/.data/{$fn_temp}{$n}/")) $n++;

?> <h1>Project Created!</h1> <?php //DB... $return_id = cc_core::make_project( $_POST['n_name'], ($fn_temp.$n), $_SESSION['user_id'] ); ?>

i

Magic strings…

Suddenly… HTML

Highly procedural

@magma_digital

Now…

@magma_digital

public function editAction(Request $request) { $this->form->handleRequest($request); $entity = $this->form->getData();

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() ) ); }

Interact with Model

Render View

@magma_digital

The cool stuffTo make your projects easier

@magma_digital

@magma_digital

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

Composer

@magma_digital

{ "require": { "monolog/monolog": "1.2.*" }}

Composercomposer.json:

@magma_digital

Composerinclude ‘classes/Foo.class.php’; include ‘classes/Bar.class.php’; include ‘classes/OtherStuff.class.php’; include ‘classes/MyClass.class.php’; include ‘classes/AnotherClass.class.php’;

@magma_digital

Composer

include ‘vendor/autoload.php’;

... $foo = new Foo();

@magma_digital

Silex

@magma_digital

{ "require": { "silex/silex": "~1.1" }}

Silexcomposer.json:

@magma_digital

Silexrequire_once __DIR__ . '/../vendor/autoload.php';

$app = new Silex\Application();

$app->get('/hello/{name}', function($name) use($app) {

return 'Hello '.$app->escape($name);

});

$app->run();

Fire up composer.

Create the App

Run it.

Be safe!

Add a route

@magma_digital

Twig

@magma_digital

<ul>

{% for user in users %} <li> {{ user.name }} </li> {% else %} <li> <strong>No users have been found.</strong> </li>{% endfor %}

</ul>

Twig

@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

$I = new WebGuy($scenario); $I->wantTo('create a wiki page'); $I->amOnPage('/'); $I->click('Pages'); $I->click('New'); $I->see('New Page');

Codeception

@magma_digital

Full Stack FrameworksSymfony2 & 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