Your SlideShare is downloading. ×
0
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.....
php.net
PHP internal dev process
• Predictable yearly release cycle
• Support old versions for 3 years
• Development on GitHub -
g...
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();
...
Anonymous functions
// PHP 5.4 array syntax
$items = ['lancashire', 'cheddar',
'manchego', 'brie'];
array_walk($items, fun...
PHP 5.4
• Released March 2012
• Traits
• Short syntax for arrays
• Built-in webserver for testing
• Removed really old stu...
Traits
class Cart {
use Maths;
}
class Maths {
function calculateVAT() { }
}
$cart = new Cart()
$cart->calculateVAT();
htt...
Built-in webserver
$ php -S localhost:8000
PHP 5.4.10 Development Server started at Tue
Aug 27 22:47:36 2013
Listening on ...
PHP 5.5
• Released June 2013
• Simple password hashing!
• Generators
• “finally” for try/catch statements
• Built-in opcode...
Password hashing
// Create hash
$hash = password_hash('refresh');
// Test password
$result = password_verify('refresh', $h...
Community
PHP FIG
(Framework Interop Group)
• Common patterns in PHP projects
to help code sharing
• PSR-0 standard file, class and n...
PHP FIG
• Used by projects such as Drupal, Zend,
Symfony, CakePHP, phpBB,AWS SDK
• www.php-fig.org
• Nice post on recent up...
Composer
• Dependency manager
• Used to install PHP packages
• Loads everything into vendor/
• Autoloader supplied in
vend...
Composer
{
"name": "My Project",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.2.*",
"zf-commons/zfc-ba...
$ composer install
Loading composer repositories with package
information
Installing dependencies (including require-dev)
...
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 refr...
Upcoming SlideShare
Loading in...5
×

Modern PHP

5,691

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,691
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
23
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Modern PHP"

  1. 1. Modern . Refresh Cambridge, 2 Sept 2013 Simon R Jones, Studio 24 www.studio24.net
  2. 2. So.. PHP • Has a bad rep, it’s cool to diss PHP • Massively successful language • Low barrier to entry • Bad practices
  3. 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
  4. 4. php.net
  5. 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. 6. PHP 5.3 (pretty old now) • Released June 2009 • Namespaces • Closures / Anonymous functions • DateTime manipulation
  7. 7. Namespaces // My/Class/Example.php namespace MyClass; // In the past was called My_Class_Example class Example { }
  8. 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. 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. 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. 11. Traits class Cart { use Maths; } class Maths { function calculateVAT() { } } $cart = new Cart() $cart->calculateVAT(); http://php.net/traits
  12. 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. 13. PHP 5.5 • Released June 2013 • Simple password hashing! • Generators • “finally” for try/catch statements • Built-in opcode cache
  14. 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
  15. 15. Community
  16. 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. 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. 18. Composer • Dependency manager • Used to install PHP packages • Loads everything into vendor/ • Autoloader supplied in vendor/autoload.php • Really, really easy!
  19. 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. 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
  21. 21. packagist.org
  22. 22. Education
  23. 23. www.phptherightway.com
  24. 24. nomadphp.com
  25. 25. nomadphp.com
  26. 26. daycamp4developers.com
  27. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×