#8 Pest PHP, HTTPS with a local Docker setup, and more
Welcome to the 8th Andy's Web Dev Tips newsletter! Here's a few things from this week:
Introducing Pest PHP
Do you write unit tests in your PHP projects? If you do, you've likely heard of PhpUnit. Its basically the testing library for PHP. Offering all kinds of methods for asserting that your code actually does what you think it does and even coming bundled in Laravel by default. However, it can be a little verbose when creating even a simple test.
@enunomaduro thought the same thing, and ended up creating a brand-new testing library called PestPHP. Its fundamental goal is simplicity, and I think it perfectly achieves that. As someone who was originally hesitant about writing tests because of the complex appearance, I’m hoping this opens up more developers to get into testing their PHP code.
Enabling HTTPS on your local Docker dev environment
If you haven’t come across it yet, I release a new video this week that details how to create a self-signed SSL certificate and use it to enable HTTPS on a local Docker Nginx dev environment. It’s a pretty short tutorial (around 15 minutes), but it’s the combined effort of a few hours of work earlier this month. I’ve spent that time struggling with getting HTTPS enabled so you don’t have to!
A simple Laravel whereDate() tip
@barryvdh over on Twitter shared the screenshot below of a quick Laravel tip he discovered. When using whereDate() in Laravel, you’re unable to to use an index, since it’s a MySQL date column. In order to get around that, you can use a comparison operator (<, >, <=, >=) or a between statement instead. To simplify this even more and keep your code DRY, you can add that functionality to a custom scope and reuse it across any of your Eloquent models.
Automatically generate your Vue Router configuration
Marcus Oberlehner came out with an article recently that talked about a useful Vue plugin called vue-auto-routing. What it essentially does is monitor your Vue components and how they fit together, and then build your Vue Router configuration around them. That way, if you delete a component or add a new one, you don’t have to worry about updating your router configuration to avoid it being out of sync.
That’s it for this week! 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.