SlideShare a Scribd company logo
Modern .
Refresh Cambridge, 2 Sept 2013
Simon R Jones, Studio 24
www.studio24.net
So.. PHP
• Has a bad rep, it’s cool to diss PHP
• Massively successful language
• Low barrier to entry
• Bad practices
PHP..
• Naming inconsistencies
• register_globals
• Unpredictable releases.
5.2 in 2006, 5.3 in 2009, PHP 6?..
• However...
It’s a great language for getting things done
php.net
PHP internal dev process
• Predictable yearly release cycle
• Support old versions for 3 years
• Development on GitHub -
github.com/php/php-src
• Public RFCs - wiki.php.net/rfc
PHP 5.3
(pretty old now)
• Released June 2009
• Namespaces
• Closures / Anonymous functions
• DateTime manipulation
Namespaces
// My/Class/Example.php
namespace MyClass;
// In the past was called My_Class_Example
class Example {
}
Namespaces
namespace MyClass;
use ZendHttpClient;
class Example {
// MyClassFoo
$fish = new Foo()
$client = new Client();
$client->setUri('http://bbc.co.uk');
$response = $client->dispatch();
}
http://php.net/language.namespaces
Anonymous functions
// PHP 5.4 array syntax
$items = ['lancashire', 'cheddar',
'manchego', 'brie'];
array_walk($items, function(&$value) {
if ($value == 'manchego') {
$value .= ' is great!';
}
$value = ucfirst($value);
});
php.net/functions.anonymous
PHP 5.4
• Released March 2012
• Traits
• Short syntax for arrays
• Built-in webserver for testing
• Removed really old stuff: safe_mode,
register_globals, magic_quotes
Traits
class Cart {
use Maths;
}
class Maths {
function calculateVAT() { }
}
$cart = new Cart()
$cart->calculateVAT();
http://php.net/traits
Built-in webserver
$ php -S localhost:8000
PHP 5.4.10 Development Server started at Tue
Aug 27 22:47:36 2013
Listening on http://localhost:8000
Document root is /Users/sjones
Press Ctrl-C to quit.
[Tue Aug 27 22:48:39 2013] ::1:49251 [200]: /
php.net/features.commandline.webserver
PHP 5.5
• Released June 2013
• Simple password hashing!
• Generators
• “finally” for try/catch statements
• Built-in opcode cache
Password hashing
// Create hash
$hash = password_hash('refresh');
// Test password
$result = password_verify('refresh', $hash);
Forward-compatible PHP 5.3 port -
github.com/ircmaxell/password_compat
php.net/password
Community
PHP FIG
(Framework Interop Group)
• Common patterns in PHP projects
to help code sharing
• PSR-0 standard file, class and namespace
conventions to support code sharing
• PSR-1 & PSR-2 coding standards
• PSR-3 common interface for logging
PHP FIG
• Used by projects such as Drupal, Zend,
Symfony, CakePHP, phpBB,AWS SDK
• www.php-fig.org
• Nice post on recent updates -
philsturgeon.co.uk/blog/2013/08/progress-
in-the-phpfig
Composer
• Dependency manager
• Used to install PHP packages
• Loads everything into vendor/
• Autoloader supplied in
vendor/autoload.php
• Really, really easy!
Composer
{
"name": "My Project",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.2.*",
"zf-commons/zfc-base": "0.1.*",
"zf-commons/zfc-twig": "1.1.*",
"phpunit/phpunit": "3.7.*",
"zendframework/zend-developer-tools":
"0.0.*"
}
}
$ composer install
Loading composer repositories with package
information
Installing dependencies (including require-dev)
- Installing zendframework/zendframework (2.2.4)
Loading from cache
- Installing zf-commons/zfc-base (v0.1.2)
- Installing twig/twig (v1.13.2)
Downloading: 100%
- Installing zf-commons/zfc-twig (1.1.5)
Downloading: 100%
- Installing symfony/yaml (v2.3.4)
getcomposer.org
packagist.org
Education
www.phptherightway.com
nomadphp.com
nomadphp.com
daycamp4developers.com
Thanks!
Slides on slideshare.net/simonrjones
Next Refresh meetup first week of November
Sign up to our mailing list at refreshcambridge.org
Sponsored by Studio 24 - www.studio24.net
@simonrjones
@refreshcambs

More Related Content

PDF
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
ODP
PHP Tips for certification - OdW13
PDF
PHP7 is coming
PPTX
Php7 HHVM and co
PPTX
PHP 5.3
ODP
The why and how of moving to php 5.4
ODP
The promise of asynchronous PHP
PDF
Quick tour of PHP from inside
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
PHP Tips for certification - OdW13
PHP7 is coming
Php7 HHVM and co
PHP 5.3
The why and how of moving to php 5.4
The promise of asynchronous PHP
Quick tour of PHP from inside

What's hot (20)

PPTX
PHP 7 Crash Course - php[world] 2015
PDF
PHP traits, treat or threat?
PPTX
Php 7 hhvm and co
PDF
Last train to php 7
PPTX
PHP 5.6 New and Deprecated Features
ODP
Mastering Namespaces in PHP
PDF
Diving into HHVM Extensions (PHPNW Conference 2015)
PDF
CLI, the other SAPI
PPTX
Doctrine 2.0 Enterprise Persistence Layer for PHP
ODP
The why and how of moving to PHP 5.4/5.5
PDF
How to deploy node to production
KEY
Zend Framework Study@Tokyo #2
ODP
The why and how of moving to PHP 5.5/5.6
PDF
2021.laravelconf.tw.slides2
PPTX
Php string function
PPT
Introduction to PHP
PDF
Exakat for PHP : smart code reviewing engine
ODP
Caching and tuning fun for high scalability @ FrOSCon 2011
PDF
Introduction to PHP - Basics of PHP
PDF
Melhorando sua API com DSLs
PHP 7 Crash Course - php[world] 2015
PHP traits, treat or threat?
Php 7 hhvm and co
Last train to php 7
PHP 5.6 New and Deprecated Features
Mastering Namespaces in PHP
Diving into HHVM Extensions (PHPNW Conference 2015)
CLI, the other SAPI
Doctrine 2.0 Enterprise Persistence Layer for PHP
The why and how of moving to PHP 5.4/5.5
How to deploy node to production
Zend Framework Study@Tokyo #2
The why and how of moving to PHP 5.5/5.6
2021.laravelconf.tw.slides2
Php string function
Introduction to PHP
Exakat for PHP : smart code reviewing engine
Caching and tuning fun for high scalability @ FrOSCon 2011
Introduction to PHP - Basics of PHP
Melhorando sua API com DSLs
Ad

Similar to Modern PHP (20)

PPTX
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
PPTX
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
PPTX
PHP ITCS 323
PDF
What's new in PHP 7.1
PPTX
Upstate CSCI 450 PHP Chapters 5, 12, 13
PPTX
Introduction to webprogramming using PHP and MySQL
PPT
PPTX
A brief to PHP 7.3
PDF
Preparing code for Php 7 workshop
PPTX
PHP language presentation
PPTX
Unit 4-6 sem 7 Web Technologies.pptx
PDF
PHP - Programming language war, does it matter
PPTX
Peek at PHP 7
PPT
Introduction to PHP - SDPHP
PPTX
introduction to php and its uses in daily
PPTX
Geecon 2019 - Taming Code Quality in the Worst Language I Know: Bash
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
PHP ITCS 323
What's new in PHP 7.1
Upstate CSCI 450 PHP Chapters 5, 12, 13
Introduction to webprogramming using PHP and MySQL
A brief to PHP 7.3
Preparing code for Php 7 workshop
PHP language presentation
Unit 4-6 sem 7 Web Technologies.pptx
PHP - Programming language war, does it matter
Peek at PHP 7
Introduction to PHP - SDPHP
introduction to php and its uses in daily
Geecon 2019 - Taming Code Quality in the Worst Language I Know: Bash
Ad

Recently uploaded (20)

PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Getting Started with Data Integration: FME Form 101
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
Modernising the Digital Integration Hub
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
STKI Israel Market Study 2025 version august
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Getting Started with Data Integration: FME Form 101
1 - Historical Antecedents, Social Consideration.pdf
Group 1 Presentation -Planning and Decision Making .pptx
TLE Review Electricity (Electricity).pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Module 1.ppt Iot fundamentals and Architecture
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
OMC Textile Division Presentation 2021.pptx
Assigned Numbers - 2025 - Bluetooth® Document
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Modernising the Digital Integration Hub
Hindi spoken digit analysis for native and non-native speakers
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
WOOl fibre morphology and structure.pdf for textiles
observCloud-Native Containerability and monitoring.pptx
DP Operators-handbook-extract for the Mautical Institute
STKI Israel Market Study 2025 version august

Modern PHP

  • 1. Modern . Refresh Cambridge, 2 Sept 2013 Simon R Jones, Studio 24 www.studio24.net
  • 2. So.. PHP • Has a bad rep, it’s cool to diss PHP • Massively successful language • Low barrier to entry • Bad practices
  • 3. PHP.. • Naming inconsistencies • register_globals • Unpredictable releases. 5.2 in 2006, 5.3 in 2009, PHP 6?.. • However... It’s a great language for getting things done
  • 5. PHP internal dev process • Predictable yearly release cycle • Support old versions for 3 years • Development on GitHub - github.com/php/php-src • Public RFCs - wiki.php.net/rfc
  • 6. PHP 5.3 (pretty old now) • Released June 2009 • Namespaces • Closures / Anonymous functions • DateTime manipulation
  • 7. Namespaces // My/Class/Example.php namespace MyClass; // In the past was called My_Class_Example class Example { }
  • 8. Namespaces namespace MyClass; use ZendHttpClient; class Example { // MyClassFoo $fish = new Foo() $client = new Client(); $client->setUri('http://bbc.co.uk'); $response = $client->dispatch(); } http://php.net/language.namespaces
  • 9. Anonymous functions // PHP 5.4 array syntax $items = ['lancashire', 'cheddar', 'manchego', 'brie']; array_walk($items, function(&$value) { if ($value == 'manchego') { $value .= ' is great!'; } $value = ucfirst($value); }); php.net/functions.anonymous
  • 10. PHP 5.4 • Released March 2012 • Traits • Short syntax for arrays • Built-in webserver for testing • Removed really old stuff: safe_mode, register_globals, magic_quotes
  • 11. Traits class Cart { use Maths; } class Maths { function calculateVAT() { } } $cart = new Cart() $cart->calculateVAT(); http://php.net/traits
  • 12. Built-in webserver $ php -S localhost:8000 PHP 5.4.10 Development Server started at Tue Aug 27 22:47:36 2013 Listening on http://localhost:8000 Document root is /Users/sjones Press Ctrl-C to quit. [Tue Aug 27 22:48:39 2013] ::1:49251 [200]: / php.net/features.commandline.webserver
  • 13. PHP 5.5 • Released June 2013 • Simple password hashing! • Generators • “finally” for try/catch statements • Built-in opcode cache
  • 14. Password hashing // Create hash $hash = password_hash('refresh'); // Test password $result = password_verify('refresh', $hash); Forward-compatible PHP 5.3 port - github.com/ircmaxell/password_compat php.net/password
  • 16. PHP FIG (Framework Interop Group) • Common patterns in PHP projects to help code sharing • PSR-0 standard file, class and namespace conventions to support code sharing • PSR-1 & PSR-2 coding standards • PSR-3 common interface for logging
  • 17. PHP FIG • Used by projects such as Drupal, Zend, Symfony, CakePHP, phpBB,AWS SDK • www.php-fig.org • Nice post on recent updates - philsturgeon.co.uk/blog/2013/08/progress- in-the-phpfig
  • 18. Composer • Dependency manager • Used to install PHP packages • Loads everything into vendor/ • Autoloader supplied in vendor/autoload.php • Really, really easy!
  • 19. Composer { "name": "My Project", "require": { "php": ">=5.3.3", "zendframework/zendframework": "2.2.*", "zf-commons/zfc-base": "0.1.*", "zf-commons/zfc-twig": "1.1.*", "phpunit/phpunit": "3.7.*", "zendframework/zend-developer-tools": "0.0.*" } }
  • 20. $ composer install Loading composer repositories with package information Installing dependencies (including require-dev) - Installing zendframework/zendframework (2.2.4) Loading from cache - Installing zf-commons/zfc-base (v0.1.2) - Installing twig/twig (v1.13.2) Downloading: 100% - Installing zf-commons/zfc-twig (1.1.5) Downloading: 100% - Installing symfony/yaml (v2.3.4) getcomposer.org
  • 27. Thanks! Slides on slideshare.net/simonrjones Next Refresh meetup first week of November Sign up to our mailing list at refreshcambridge.org Sponsored by Studio 24 - www.studio24.net @simonrjones @refreshcambs