#17 Set up PHP 8 JIT, using Vue with Laravel Cashier, and more
Welcome to the 17th Andy's Web Dev Tips newsletter! Here's a few things from the last couple weeks:
PHP 8: How to setup the JIT
Brent over at Stitcher.io posted this super helpful article a few months ago that I recently came across. The JIT, or just in time compiler, is a feature that was added to the latest version of PHP.
Unlike C, Rust, or Java, PHP isn’t a compiled language, it’s interpreted at runtime and built on the fly each time that a program/app/script is ran. With JIT, it combines some of the aspects of compiled languages to make for much faster response times. Essentially converting portions of your PHP code to compiled language, and running that in place of the original code.
The result? Faster load times, and less resources used. Check out that article for an in-depth, but concise, tutorial for getting JIT set up in your current PHP environment.
Build a Vue shopping cart with Laravel Cashier and Stripe
Last week I released a new video on my YouTube channel, showing off how I built a basic e-commerce shopping cart application with Vue, Laravel, and the official Cashier package (for handling Stripe payments). It’s a little long at around 55 minutes, but goes over everything from start to finish in a single video.
If you don’t want to sit through the whole tutorial, check out the description for helpful links to specific parts of the development process that I’ve highlighted.
Docker cheat sheet
I work with Docker, a lot. Both in production environments, and on my local machine. While I have a few commands memorized that I use on a regular basis, I find myself having to look up more obscure or less-used ones pretty often.
Stumbling across this fantastic Docker cheat sheet poster from swissarmydevops.com, I’m considering printing it out to hang on my office wall. Basically any command that you’ll need to use in your Docker environment will be found in this image.
Work with JSON directly in your terminal
More than a few times I’ve had to use curl or similar in my terminal, for testing out an API endpoint or grabbing some piece of data, and get JSON returned back. Normally I’d have to dump it into a file and open it in my code editor to see it formatted, otherwise end up trying to decipher a massive unbroken string.
Well, not anymore! I stumbled across someone mentioning a package called jq the other day, and decided to check it out for myself. What you get is a command-line application that lets you format and work with JSON directly in the terminal.
After installing with either `apt-get install jq` or `brew install jq`, you can pipe the output of a curl request into it and get nicely formatted, highlighted JSON back to you.
Today I learned
This helpful hint was inspired by this post on the phpsadness.com site. I previously thought that the parameter orders in some PHP functions were arbitrary, but it turns out the order could depend on if we’re dealing with strings or arrays.
string: $haystack, $needle
array: $needle, $haystack
That’s it for now! If you have any questions about the above, or have something you’d like me to check out, please feel free to let me know on Twitter.