lean js deeply, but don't forget about php!

41
@royboy789 Learn JS Deeply, but Don't Forget About PHP! Roy Sivan | RoySivan.com | CalderaLearn.org

Upload: calderalearn

Post on 06-Apr-2017

105 views

Category:

Technology


0 download

TRANSCRIPT

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

@royboy789

Learn JS Deeply, but Don't Forget About PHP!

Roy Sivan | RoySivan.com | CalderaLearn.org

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

@royboy789

CalderaLearn.com

Hi I'm Roy@royboy789

Senior Software Engineer | The Walt Disney CompanyI teach about WordPress @calderalearn & @lyndaI am a member of The WP Crowd! @thewpcrowdI blog @roysivan.com too!

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

@royboy789

What We're Covering Today

Intro to the WordPress REST APIWhy JavaScriptCake (not PHP)Why PHPPHP Business logicWordPress PHP

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

@royboy789

What We're Covering Today

Josh Pollock and I have already covered it.

TheWPCrowd - Episode 43.

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

@royboy789

CalderaLearn.com

Quick Intro To The WordPress REST API

What Is It? Why Is It Exciting? How Does It Work?

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

@royboy789

CalderaLabs.org

What Is TheWordPress REST API??

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

@royboy789

CRUD Routes For WordPress Content

PostsUsersCommentsTaxonomiesSites

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

@royboy789

Post Routes

/wp/v2/postsFirst page of posts

/wp/v2/posts/42Post 42

/wp/v2/commentsFirst page of comments

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

@royboy789

This Is The WordPress REST API

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

@royboy789

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

@royboy789

CalderaLearn.com

Why JavaScript GoodIts yummy and nutritious!

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

@royboy789

CalderaLabs.org

“Learn JavaScript, Deeply”- Matt M.

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

@royboy789

Why I JavaScript

AngularAngularAngularAngularAngularReact

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

@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

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

@royboy789

CalderaLearn.com

Time for Cake!

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

@royboy789

JK!!!!!!!!!!!!!! It is a pie.

The cake is a lie.

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

@royboy789

CalderaLearn.com

Why PHP?

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

@royboy789

Why PHP?

PHP isn’t going anywherePHP is stableIf you level up as a developer, there are just as many PHP frameworks as good JS frameworks

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

@royboy789

WordPress is PHP

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

@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)

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

@royboy789

CalderaLabs.org

“WordPress will be rebuilt in Node”- Chief Editor of FakeWPNews.com

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

@royboy789

FALSE

“FALSE”- Matt Cromwell

FALSE

FALSEFALSE

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

@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.

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

@royboy789

API can be used without JS

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

@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' );

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

@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

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

@royboy789

CalderaLearn.com

Ok, but seriouslyI mean, you’re wearing an Angular hat.

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

@royboy789

Use JS for what it is good for

JavaScript is good for

Client Side Render of UInothing more

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

@royboy789

CalderaLearn.com

PHP Means BusinessDon’t mess with it.

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

@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

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

@royboy789

Business Logic in API

JavaScript is best used for UI

leave it that way!

JavaScript can hit the APIAPI will do all the logicSend back appropriate data to modify UI

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

@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)

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

@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

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

@royboy789

Extend the API for Business Logic

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

@royboy789

CalderaLearn.com

WordPress PHPThe WP Way

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

@royboy789

WordPress PHP

Want to learn something deeply?

Learn the WordPress way of doing things!

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

@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

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

@royboy789

Questions?

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

@royboy789

Places To Learn More PHP

Caldera Learn.comWordPress TV - WordPress.tv/?s=rest+apiLynda.com

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

CalderaLearn.com

Caldera Learn teaches through 4-week live classroom style webinars.

Teachers are Josh Pollock and Roy Sivan

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

@royboy789

CalderaLearn.com

Thank You@royboy789

RoySivan.comTheWPCrowd.comCalderaLearn.comLynda.com/Roy-Sivan/5111285-1.htmlYou’re Welcome Matt