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.

Lean JS Deeply, but don't forget about PHP!

349 views

Published on

PHP is the language that WordPress is built on, and it isn’t going anywhere. “Learn JavaScript deeply” is a great sentiment, and I feel like every aspiring developer should take JavaScript seriously if they want to go down that route. However, if you are building JavaScript (framework or not) applications powered by the WordPress REST API, don’t forget about PHP. I’ll run through a few examples of full on JavaScript application builds, where there is equal if not more PHP custom code than JavaScript. So before you learn JS deeply, do you have a moment to talk about PHP?

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Lean JS Deeply, but don't forget about PHP!

  1. 1. @royboy789 Learn JS Deeply, but Don't Forget About PHP! Roy Sivan | RoySivan.com | CalderaLearn.org
  2. 2. @royboy789 CalderaLearn.com Hi I'm Roy @royboy789 Senior Software Engineer | The Walt Disney Company I teach about WordPress @calderalearn & @lynda I am a member of The WP Crowd! @thewpcrowd I blog @roysivan.com too!
  3. 3. @royboy789 What We're Covering Today Intro to the WordPress REST API Why JavaScript Cake (not PHP) Why PHP PHP Business logic WordPress PHP
  4. 4. @royboy789 What We're Covering Today Josh Pollock and I have already covered it. TheWPCrowd - Episode 43.
  5. 5. @royboy789 CalderaLearn.com Quick Intro To The WordPress REST API What Is It? Why Is It Exciting? How Does It Work?
  6. 6. @royboy789 CalderaLabs.org What Is The WordPress REST API??
  7. 7. @royboy789 CRUD Routes For WordPress Content Posts Users Comments Taxonomies Sites
  8. 8. @royboy789 Post Routes /wp/v2/posts First page of posts /wp/v2/posts/42 Post 42 /wp/v2/comments First page of comments
  9. 9. @royboy789 This Is The WordPress REST API
  10. 10. @royboy789
  11. 11. @royboy789 CalderaLearn.com Why JavaScript Good Its yummy and nutritious!
  12. 12. @royboy789 “ CalderaLabs.org “Learn JavaScript, Deeply” - Matt M.
  13. 13. @royboy789 Why I JavaScript Angular Angular Angular Angular Angular React
  14. 14. @royboy789 Why I JavaScript… for reals Headless WordPress, yas! Create really custom UI It is a great time to be a JS developer! https://github.com/royboy789/Angular-Wordpress-Theme https://github.com/WordPress-Admin-JavaScript-Boilerplate/ReactJS-Boilerplate
  15. 15. @royboy789 CalderaLearn.com Time for Cake!
  16. 16. @royboy789 JK!!!!!!!!!!!!!! It is a pie. The cake is a lie.
  17. 17. @royboy789 CalderaLearn.com Why PHP?
  18. 18. @royboy789 Why PHP? PHP isn’t going anywhere PHP is stable If you level up as a developer, there are just as many PHP frameworks as good JS frameworks
  19. 19. @royboy789 WordPress is PHP
  20. 20. @royboy789 So much PHP! Ever notice those sneaky <?php tags? The REST API is also built in PHP The P in LAMP, LEMP, LNMP, LAPP, WAMP, MAMP, XAMP(<- this one)P(<- sometimes this one)
  21. 21. @royboy789 “ CalderaLabs.org “WordPress will be rebuilt in Node” - Chief Editor of FakeWPNews.com
  22. 22. @royboy789 FALSE “FALSE” - Matt Cromwell FALSE FALSE FALSE
  23. 23. @royboy789 WordPress & Node For the foreseeable future, there is no reason that WordPress will be magically rebuilt on node. If it is going to be rebuilt, it will stay PHP, probably be PHP7 amazing.
  24. 24. @royboy789 API can be used without JS
  25. 25. @royboy789 API your stuff with PHP You can use the REST API’s PHP classes to run the functions a route does, except it is all done server side without wp_safe_remote_get/post $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
  26. 26. @royboy789 PHP Frameworks Just like there are JS frameworks to learn as you become more advanced, there are PHP frameworks. You can build advanced functionality with one of these, still communicating to your WordPress data Laravel, Symfony - popular, good Phalcon, CakePHP - not as popular, still good
  27. 27. @royboy789 CalderaLearn.com Ok, but seriously I mean, you’re wearing an Angular hat.
  28. 28. @royboy789 Use JS for what it is good for JavaScript is good for Client Side Render of UI nothing more
  29. 29. @royboy789 CalderaLearn.com PHP Means Business Don’t mess with it.
  30. 30. @royboy789 Business Logic Code Business logic is the code that is, functionality wise, the meat of your business. Ex: If you run a Woocommerce store, the creation of the order, payment processing, and anything else check out related that happens before the “thank you” page- Business Logic
  31. 31. @royboy789 Business Logic in API JavaScript is best used for UI leave it that way! JavaScript can hit the API API will do all the logic Send back appropriate data to modify UI
  32. 32. @royboy789 Business Logic in API - Example 1. Your JS checkout app sends call with data to API 2. API handles all Woo code to create order 3. API handles all Woo code to create payment 4. API handles all Woo code to finalize order 5. Data sent back is just the final success / failure, and order ID (and associated meta)
  33. 33. @royboy789 Extend the API for Business Logic As you need more business logic code, extending the API is the way to go… and that is done (should be done) in PHP Create custom routes & endpoints for your business logic Use the REST API to create your own REST API
  34. 34. @royboy789 Extend the API for Business Logic
  35. 35. @royboy789 CalderaLearn.com WordPress PHP The WP Way
  36. 36. @royboy789 WordPress PHP Want to learn something deeply? Learn the WordPress way of doing things!
  37. 37. @royboy789 WordPress PHP Actions & Filters wp_enqueue_ & wp_localize_object Create Plugins - Stop using functions.php as a catch-all for your advanced functionality Create Custom Themes - Go ahead, try it
  38. 38. @royboy789 Questions?
  39. 39. @royboy789 Places To Learn More PHP Caldera Learn.com WordPress TV - WordPress.tv/?s=rest+api Lynda.com
  40. 40. CalderaLearn.com Caldera Learn teaches through 4-week live classroom style webinars. Teachers are Josh Pollock and Roy Sivan
  41. 41. @royboy789 CalderaLearn.com Thank You @royboy789 RoySivan.com TheWPCrowd.com CalderaLearn.com Lynda.com/Roy-Sivan/5111285-1.htmlYou’re Welcome Matt

×