Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Current state-of-php

460 views

Published on

How in a JavaScript world PHP still has meaning.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Current state-of-php

  1. 1. Current State of PHP Richard McIntyre
  2. 2. About me → PHPer → JavaScripter → Rubyist → Other → Contributer to Lithium #Li3 and BEAR.Sunday frameworks → Author of Spout CMS and ShouldIT?
  3. 3. PHP History
  4. 4. Organically grown
  5. 5. PHP 3 Objects What year?
  6. 6. 1998
  7. 7. PHP 4 Zend Engine
  8. 8. 2000
  9. 9. PHP 5.3 Namespaces Lamdas / Closures
  10. 10. 2009
  11. 11. Projects became messy!
  12. 12. O'Reilly BLog Embedding PHP in regular HTML If 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:
  13. 13. <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>
  14. 14. <?php // database connection stuff here if (!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 now if ($screen > 0) { $url = "example.php?screen=" . $screen - 1; echo "<a href="$url">Previous</a>n"; } // page numbering links now for ($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"; } ?>
  15. 15. The answer! Frameworks
  16. 16. Too many frameworks!
  17. 17. Best Practices
  18. 18. Testing
  19. 19. Design Patterns
  20. 20. Composer
  21. 21. What about JS?
  22. 22. The hipster thing to do
  23. 23. Rich User Experiences
  24. 24. Long running processes
  25. 25. Functional Programming
  26. 26. Isomorphic Applications
  27. 27. We can do everything in this
  28. 28. But...
  29. 29. Fragile tooling
  30. 30. Messy applications
  31. 31. Competing async models
  32. 32. 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); }); };
  33. 33. Devs are scarce
  34. 34. What is great about PHP
  35. 35. Mature
  36. 36. Build Businesses on IT
  37. 37. Community
  38. 38. Elegant coding implementations
  39. 39. <?php namespace AppHttpControllers; use AppRepositoriesUserRepository; 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; } }
  40. 40. Throwaway request response lifecycle
  41. 41. A faster and improved PHP
  42. 42. Uniform Variable Syntax ($object->closureProperty)();
  43. 43. Uniform Variable Syntax class foo { static $bar = 'baz'; } class baz { static $bat = 'Hello World'; } baz::$bat = function () { echo "Hello World"; }; $foo = 'foo'; ($foo::$bar::$bat)();
  44. 44. Return Types function isValidStatusCode(int $statusCode): bool { return isset($this->statuses[$statusCode]); }
  45. 45. Amazing PHP Projects
  46. 46. Ray.DI
  47. 47. ORM
  48. 48. FastRoute
  49. 49. PHPMailer
  50. 50. Codeception
  51. 51. Prophecy
  52. 52. So.... Should I use? PHP or JS?
  53. 53. What does your Stack look like?
  54. 54. What kind of processing do you want to do?
  55. 55. Sometimes there is an even better fit?
  56. 56. Do you need it to be a single page app?
  57. 57. Are you an agency?
  58. 58. Enterprise → Java → .net
  59. 59. Enterprise → Java → .net → PHP
  60. 60. On what tools do you think you can build your empire?
  61. 61. Use both?!
  62. 62. Take-home Challenge
  63. 63. Thanks Questions @mackstar

×