Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP your perfect tool

PHP your perfect tool

Why you should choose PHP for your next project

Ffdbe721956f8197910842756fcfb44a?s=128

Milan Popović

April 20, 2015
Tweet

More Decks by Milan Popović

Other Decks in Programming

Transcript

  1. YOUR PERFECT TOOL Presented by / Milan Popović @komita1981

  2. ME PHP developer 7 years in PHP development Work for

    12 Mnkys I like to learn and share knowledge Active member of PHP Srbija
  3. YOU? Who are you? What's your experience in programming? What

    do you think about PHP?
  4. “There are only two kinds of programming languages: those people

    always bitch about and those nobody uses.” Bjarne Stroustrup
  5. None
  6. HISTORY OF PHP Created in 1994 by Rasmus Lerdorf -

    @rasmus Written in C Personal Home Page Tools ZEND - Andi Gutmans and Zeev Suraski PHP - Hypertext Preprocessor
  7. TIMELINE PHP 1 - 1995 PHP 2 - 1996 PHP

    3 - 1998 - popularity gained PHP 4 - 2000 - wannabe object PHP 5 - 2004 - OO support PHP 5.3 - 2009 - Namespaces PHP 5.4 - 2012 - Traits, [] PHP 5.5 - 2013 - OPcache, Finally PHP 5.6 - 2014 - Constant Scalar Expressions PHP 7 - October 2015
  8. May 2014 - PHP github repo April 2015 - PHP

    github repo
  9. None
  10. None
  11. None
  12. None
  13. None
  14. None
  15. None
  16. WHY YOU SHOULD CHOOSE PHP?

  17. HOSTING Shared VPS Dedicated servers Heroku Google App Engine Azure

  18. POPULARITY - TIOBE INDEX

  19. Popularity - usage of languages on web

  20. COMMUNITY More than 5 millions PHP developers worldwide Up to

    thousand PHP developers in Serbia
  21. ACTIVITY

  22. None
  23. None
  24. Simplicity - Highly learnable The easiest language to learn for

    non-technical people Fast and reliable Platform independent Bunch of good tools Bunch of extensions Good (and extensive) documentation Big players involved (FB...) Open source Lets you get things done
  25. PREJUDICE <!--?php $db = connect_mysql('192.168.1.1', 'root' , 'secretPassword123' ); $item

    = get_mysql_data('SELECT * FROM my_table WHERE id= $_GET['id' ?--> <title><?php echo $item['title'];?></title> <div> <!--?php $users = get_mysql_data('SELECT * FROM users WHERE bla = '.$ite ?--> <!--?php foreach($users as $user){ ?-->
  26. Tim Bray “All the PHP code I’ve seen in that

    experience has been messy, unmaintainable crap. Spaghetti SQL wrapped in spaghetti PHP wrapped in spaghetti HTML, replicated in slightly- varying form in dozens of places”
  27. namespace League\Flysystem; use LogicException; use InvalidArgumentException; class Filesystem implements FilesystemInterface

    { // variable declaration hidden in this example /** * Constructor * * @param AdapterInterface $adapter * @param mixed $config */ public function __construct(AdapterInterface $adapter, $config = null)
  28. EDUCATION

  29. PHP THE RIGHT WAY

  30. LARACAST

  31. BOOKS http://php-books.com/

  32. None
  33. None
  34. None
  35. CONFERENCES

  36. PHP FIG PHP Framework Interop Group

  37. None
  38. PSR Php Standard Recommendation PSR-0 - Autoloading standard PSR-1 -

    Basic coding standard PSR-2 - Coding style guide PSR-3 - Logger interface PSR-4 - Improved autoloading PSR-5 - PHPDoc PSR-6 - Cache interface PSR-7 - HTTP message implementation
  39. COMPOSER Dependency Manager for PHP Created by Jordi Boggiano and

    Nils Adermann Thank you guys!
  40. Fabien Potencier “PHP has a better dependency manager than any

    other languages”
  41. curl -sS https://getcomposer.org/installer | php Can be installed globally and

    locally
  42. The problem that Composer solves is this: You have a

    project that depends on a number of libraries Some of those libraries depend on other libraries You declare the things you depend on Composer finds out which versions of which packages need to be installed, and installs them (meaning it downloads them into your project)
  43. Declaring dependencies composer.json { "name": "zendframework/skeleton-application", "description": "Skeleton Application for

    ZF2", "license": "BSD-3-Clause", "keywords": [ "framework", "zf2" ], "homepage": "http://framework.zend.com/", "require": { "php": ">=5.3.3", "zendframework/zendframework": "2.2.*", "aws/aws-sdk-php-zf2": "1.2.1", "league/flysystem": "0.4.*@dev" } }
  44. None
  45. SEMANTIC VERSIONING more info - http://semver.org/

  46. VERSION CONSTRAINTS

  47. EXACT MATCH 1.0.0, dev-master

  48. WILDCARD RANGE 1.0.*, 2.*

  49. HYPHEN RANGE 1.0 - 2.0 === >=1.0.0 < 2.1 1.0.0

    - 2.1.0 === >=1.0.0 <= 2.1.0
  50. UNBOUNDED RANGE >= 1.0 DO NOT USE THIS

  51. NEXT SIGNIFICANT RELEASE ~1.2 === >=1.2.0 <2.0.0 ~1.2.3 === >=1.2.3

    <1.3.0
  52. CARET / SEMVER OPERATOR ^1.2.3 === >=1.2.3 <2.0.0 ^ 0.3

    === >=0.3.0 <0.4.0 Libraries should use ^ and you should too!
  53. THE LOCK FILE composer.lock Provide fast installs with low memory

    usage Reproducible installs Do you add it to .gitignore? Commit it and use it with composer install
  54. DO NOT DEPLOY IT

  55. AUTOLOADING You don’t have to maintain your own autoloader Ability

    to load your code automatically include "vendor/autoload.php";
  56. "autoload": { "psr-0" : { "Application": "src/" } }

  57. "autoload": { "psr-4" : { "Application\\": "src/" } }

  58. "autoload": { "classmap" : [ "src/" ] }

  59. <!--?php // autoload_classmap.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir

    = dirname($vendorDir); return array( 'Application\\Controller\\Dashboard' =--> $baseDir . '/src/Application/Cont 'Application\\Controller\\Defaults' => $baseDir . '/src/Application/Control 'Application\\Controller\\Entry' => $baseDir . '/src/Application/Controller 'Application\\Controller\\Logbook' => $baseDir . '/src/Application/Controll 'Application\\Controller\\RequiresAuth' => $baseDir . '/src/Application/Con 'Application\\Controller\\User' => $baseDir . '/src/Application/Controller/ 'Application\\Model\\LogEntry\\Defaults' => $baseDir . '/src/Application/Mo 'Application\\Model\\LogEntry\\Gateway' => $baseDir . '/src/Application/Mod
  60. { "require": { "vendor/package": "1.3.2", "vendor/package2": "1.*", "vendor/package3": ">=2.0.3" }

    }
  61. PACKAGIST STATISTICS - MAY 2014 29 908 packages registered 110

    247 versions available 207 357 630 packages installed (since 2012-04-13)
  62. PACKAGIST STATISTICS - APRIL 2015 56 164 packages registered 246

    789 versions available 687 988 359 packages installed (since 2012-04-13)
  63. None
  64. https://github.com/ziadoz/awesome-php

  65. None
  66. None
  67. BEFORE YOU CHOOSE PACKAGE Check if it is properly tested

    Check documentation (README.md) Check Stability dev -> alpha -> beta -> RC -> stable Check number of downloads Check when it was last authored Check the licence
  68. PHP FRAMEWORKS

  69. Zend Framework 2 Symfony 2 Laravel 4, 5 Yii 2

    CakePHP 3 Aura
  70. PhalconPhp Slim Silex Lumen

  71. None
  72. TAKE CARE ABOUT THIS What do you want to build?

    Is good documentation available? Is it worth the investment? Community Comparing with other FW Check the licence Security
  73. 3 DONT'S Don't spend countless hours in search of the

    „best“ framework. There is no such thing! Don't get religious with a language / framework / whatever! Don't decide based on stupid „hello world“ benchmarks.
  74. SYMFONY 2 “If you have a PHP problem the Symfony

    community has already solved it”
  75. None
  76. None
  77. There is bundle for everything Integrates with Doctrine, Propel, PHPUnit

    ... Aims to speed up the creation and maintenance of web applications Aim at building enterprise-level applications, giving developers full control over the configuration
  78. None
  79. LARAVEL The Swiss-Knife of Startup world The Most Popular FW

    of 2015 FW with the best marketing
  80. Symfony components used by Laravel

  81. Database agnostic migrations and schema builder Great ORM - Eloquent

    Painless routing Blade Templating Engine Powerful queue library Validation Built with testing in mind
  82. LARAVEL ECOSYSTEM Forge Homestead Elixir Envoyer Laracast

  83. PHALCONPHP "The fastest framework"

  84. Implemented as a C extension Learning curve is pretty easy

    Support Micro and Macro application Loosely coupled to allow developers to use the whole framework or selected objects Neat and clean intuitive API with solid code written on powerful design patterns
  85. None
  86. PHP IS NOT FOR Building command line apps Doing heavy

    calculation Calculate statistics You need all the performance you can get
  87. THANK YOU

  88. QUESTIONS?