Why is PHP Awesome

37
@magma_digital Why PHP Is Awesome Honest.

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.

Transcript of Why is PHP Awesome

Page 1: Why is PHP Awesome

@magma_digital

Why PHP Is AwesomeHonest.

Page 2: Why is PHP Awesome

@magma_digital

The Team

Page 3: Why is PHP Awesome

@magma_digital

Speaking today

Jeremy Coates @phpcodemonkey

Steph Cook @stephcook22

Damien Walsh @themainframe

Page 4: Why is PHP Awesome

@magma_digital

– w3techs.com

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

know.”

Page 5: Why is PHP Awesome

@magma_digital

Page 6: Why is PHP Awesome

@magma_digital

So why the reputation

Page 7: Why is PHP Awesome

@magma_digital

PHP has moved on.

Page 8: Why is PHP Awesome

@magma_digital

The dark ages…

Page 9: Why is PHP Awesome

@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

Page 10: Why is PHP Awesome

@magma_digital

Now…

Page 11: Why is PHP Awesome

@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

Page 12: Why is PHP Awesome

@magma_digital

The cool stuffTo make your projects easier

Page 13: Why is PHP Awesome

@magma_digital

Page 14: Why is PHP Awesome

@magma_digital

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

Composer

Page 15: Why is PHP Awesome

@magma_digital

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

Composercomposer.json:

Page 16: Why is PHP Awesome

@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’;

Page 17: Why is PHP Awesome

@magma_digital

Composer

include ‘vendor/autoload.php’;

... $foo = new Foo();

Page 18: Why is PHP Awesome

@magma_digital

Silex

Page 19: Why is PHP Awesome

@magma_digital

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

Silexcomposer.json:

Page 20: Why is PHP Awesome

@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

Page 21: Why is PHP Awesome

@magma_digital

Twig

Page 22: Why is PHP Awesome

@magma_digital

<ul>

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

</ul>

Twig

Page 23: Why is PHP Awesome

@magma_digital

Page 24: Why is PHP Awesome

@magma_digital

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

Page 25: Why is PHP Awesome

@magma_digital

Codeception

Page 26: Why is PHP Awesome

@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

Page 27: Why is PHP Awesome

@magma_digital

Full Stack FrameworksSymfony2 & Zend Framework 2

Page 28: Why is PHP Awesome

@magma_digital

Page 29: Why is PHP Awesome

@magma_digital

Page 30: Why is PHP Awesome

@magma_digital

Types of Projects

Page 31: Why is PHP Awesome

@magma_digital

Page 32: Why is PHP Awesome

@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.

Page 33: Why is PHP Awesome

@magma_digital

Get involved!

Page 34: Why is PHP Awesome

@magma_digital

Page 35: Why is PHP Awesome

@magma_digital

PHPNW

Page 36: Why is PHP Awesome

@magma_digital

Have we convinced you yet

Page 37: Why is PHP Awesome

@magma_digital

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