current state-of-php

73
Current State of PHP Richard McIntyre

Upload: richard-mcintyre

Post on 22-Jan-2018

429 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Current state-of-php

Current State of PHP

Richard McIntyre

Page 2: Current state-of-php

About me→ PHPer

→ JavaScripter→ Rubyist→ Other

→ Contributer to Lithium #Li3 and BEAR.Sunday frameworks

→ Author of Spout CMS and ShouldIT?

Page 3: Current state-of-php

PHP History

Page 4: Current state-of-php

Organically grown

Page 5: Current state-of-php

PHP 3Objects

What year?

Page 6: Current state-of-php

1998

Page 7: Current state-of-php

PHP 4Zend Engine

Page 8: Current state-of-php

2000

Page 9: Current state-of-php

PHP 5.3Namespaces Lamdas / Closures

Page 10: Current state-of-php

2009

Page 11: Current state-of-php

Projects became messy!

Page 12: Current state-of-php

O'Reilly BLog

Embedding PHP in regular HTMLIf you have been paying attention to our earlier

articles, you hopefully have picked up on how PHP can be embedded into a regular HTML document. For example, we should already know that the following

is an example of how PHP is embedded:

Page 13: Current state-of-php

<html><head><title>My first PHP Page</title></head><body>This is normal HTML code<?php

// php code goes here?>

Back into normal HTML

</body></html>

Page 14: Current state-of-php

<?php// database connection stuff hereif (!isset($screen)) $screen = 0;$start = $screen * $rows_per_page;$sql = "SELECT description FROM table_name ";$sql .= "LIMIT $start, $rows_per_page";$result = mysql_query($sql, $db);$rows = mysql_num_rows($result);for ($i = 0; $i < $rows; $i++) { $description = mysql_result($result, $i, 0); echo "\$description = $description<br>\n";}echo "<p><hr></p>\n";// let's create the dynamic links nowif ($screen > 0) { $url = "example.php?screen=" . $screen - 1; echo "<a href=\"$url\">Previous</a>\n";}// page numbering links nowfor ($i = 0; $i < $pages; $i++) { $url = "example.php?screen=" . $i; echo " | <a href=\"$url\">$i</a> | ";}if ($screen < $pages) { $url = "example.php?screen=" . $screen + 1; echo "<a href=\"$url\">Next</a>\n";}?>

Page 15: Current state-of-php

The answer!Frameworks

Page 16: Current state-of-php

Too many frameworks!

Page 17: Current state-of-php

Best Practices

Page 18: Current state-of-php

Testing

Page 19: Current state-of-php

Design Patterns

Page 20: Current state-of-php

Composer

Page 21: Current state-of-php

What about JS?

Page 22: Current state-of-php

The hipster thing to do

Page 23: Current state-of-php

Rich User Experiences

Page 24: Current state-of-php

Long running processes

Page 25: Current state-of-php

Functional Programming

Page 26: Current state-of-php

Isomorphic Applications

Page 27: Current state-of-php
Page 28: Current state-of-php

We can do everything in this

Page 29: Current state-of-php

But...

Page 30: Current state-of-php

Fragile tooling

Page 31: Current state-of-php

Messy applications

Page 32: Current state-of-php

Competing async models

Page 33: Current state-of-php

export default (filesMap) => { return new Promise((resolve, reject) => { let filePromises = []; for (let name of Object.keys(filesMap)) { filePromises.push(readFile(filesMap[name])); } Promise .all(filePromises) .then((filesData) => { resolve(filesData.reduce((prev, curr) => prev += curr)); }, reject); });};

Page 34: Current state-of-php

Devs are scarce

Page 35: Current state-of-php

What is great about PHP

Page 36: Current state-of-php

Mature

Page 37: Current state-of-php

Build Businesses on IT

Page 38: Current state-of-php
Page 39: Current state-of-php
Page 40: Current state-of-php

Community

Page 41: Current state-of-php
Page 42: Current state-of-php

Elegant coding implementations

Page 43: Current state-of-php
Page 44: Current state-of-php

<?php

namespace App\Http\Controllers;

use App\Repositories\UserRepository;

class UserController extends Controller{ /** * The user repository instance. */ protected $users;

/** * Create a new controller instance. * * @param UserRepository $users * @return void */ public function __construct(UserRepository $users) { $this->users = $users; }}

Page 45: Current state-of-php

Throwaway request response lifecycle

Page 46: Current state-of-php

A faster and improved PHP

Page 47: Current state-of-php

Uniform Variable Syntax ($object->closureProperty)();

Page 48: Current state-of-php

Uniform Variable Syntaxclass foo { static $bar = 'baz'; }class baz { static $bat = 'Hello World'; }

baz::$bat = function () { echo "Hello World"; };

$foo = 'foo';($foo::$bar::$bat)();

Page 49: Current state-of-php

Return Typesfunction isValidStatusCode(int $statusCode): bool { return isset($this->statuses[$statusCode]);}

Page 50: Current state-of-php

Amazing PHP Projects

Page 51: Current state-of-php
Page 52: Current state-of-php

Ray.DI

Page 53: Current state-of-php
Page 54: Current state-of-php

ORM

Page 55: Current state-of-php

FastRoute

Page 56: Current state-of-php

PHPMailer

Page 57: Current state-of-php

Codeception

Page 58: Current state-of-php

Prophecy

Page 59: Current state-of-php

So....Should I use? PHP or JS?

Page 60: Current state-of-php

What does your Stack look like?

Page 61: Current state-of-php
Page 62: Current state-of-php

What kind of processing do you want to do?

Page 63: Current state-of-php
Page 64: Current state-of-php
Page 65: Current state-of-php

Sometimes there is an

even better fit?

Page 66: Current state-of-php

Do you need it to be a single page app?

Page 67: Current state-of-php

Are you an agency?

Page 68: Current state-of-php

Enterprise→ Java→ .net

Page 69: Current state-of-php

Enterprise→ Java→ .net→ PHP

Page 70: Current state-of-php

On what tools do you think you can build your empire?

Page 71: Current state-of-php

Use both?!

Page 72: Current state-of-php

Take-home Challenge

Page 73: Current state-of-php

ThanksQuestions@mackstar