Tip: Begin every test with a series of comments that describe your given/when/then. Then, one by one, convert those comments to actual code.
Unless it's very basic, I begin *every* test in this way to gather my thoughts. https://t.co/67FtU9DmwH
#TIL about (*SKIP)(*FAIL) in PCRE https://t.co/P7ruvvtev8
Just another reminder that you can run phpunit with the --testdox flag to get a beautiful output https://t.co/BwZY0sRIC6
⚗️ One of the most common integrations developers struggle to test is Guzzle. Fortunately, it has a `MockHandler` you can set up to return predefined responses.
Since it uses the existing `Client` and `Response` objects, there's no need to change your implementation. https://t.co/Ui2Zyqj2Lt
I don't think most people know that you can pretty easily run a WP website like this, with everything managed by Composer. https://t.co/BOF9i6qPTy
🔥 Something I'm doing a *lot* in my own codebases: extracting exception messages to domain exceptions and readable static methods. Really cleans up codebases and allows for better reusability.
More #DevTips: https://t.co/LhsCAz563J https://t.co/OQH4D3IZV9
🔥 If you work with PHP composer all day, consider adding ./vendor/bin to your path to save those precious keystrokes ⌨️ https://t.co/J6V1ZLxSYZ
⚗️ Need to control a defined constant in your tests?
You can use the <const> element in your phpunit.xml file to define a dummy value your code will use when the tests run. https://t.co/cMMpWOJBzt
Quick reminder: you can run `composer outdated` to get a quick overview of available updates. Red: can be updated with current constraints. Yellow: Update available that doesn't match your current requirements. https://t.co/DpyAHgUMIb
⚗️ Whenever I generate test data, I like to explicitly set values which could change behavior, even if they are currently defaulted with the same value.
The future brings change and resolving such a failure can be hard. https://t.co/d030JfKbJO
🎉 #PHP 🎉
Find URLs in Text, Make Links https://t.co/kfogfg4JyA
TIP: You want to export #laravel eloquent query to native mysql? Here's a quick way to do it: https://t.co/ORGfKtEHNY - Gives out everything you need to run it in mysql console
* Warning, doesn't go friendly with relationships and so on. Works on single queries
🔥 In many cases avoiding `else` and using early returns will greatly improve readability of your code.
I wish somebody would have told me this sooner in my career.
Contrived example in the image. Real world example: https://t.co/oOsSGAJLZm
Came across a quick way to fake a single requirement so Composer can install a dependency instead of using the heavy handed `--ignore-platform-reqs`. https://t.co/LYsHRmTJon
🌟 Here is another great #Tip for Composer:
If you don't want to scroll through all the installation conflicts when doing a `composer update`, did you know you can ask composer why a specific package can not be installed?
Just use `composer why-not <package> <version>`? https://t.co/RCZs4x34eu
Too impatient to wait for third-party packages to update their requirements?
Use with care (and good test coverage!) 😅 https://t.co/rRdiPiPp3F
🔥Want to have a test route but don't want to worry about taking it out for production/ exposing it by mistake?
Use this to make it only available on local. ✊
#php #laravel #100DaysOfCode
#Laravel tip of the day: you can do *recursive* Laravel relationships in Eloquent, see screenshot and read more in this article: https://t.co/4UgBf52WLQ https://t.co/aWMapCIwWg
#Laravel tip of the day: Laravel Collection has nice firstWhere() method to make your code a little shorter. See example in the screenshot and the docs: https://t.co/vpKM0BMZCt https://t.co/K4sdYsg9zA
🔥 When working with logic to determine exception throwing, consider extracting it to a separate method. This allows for less cognitive overload inside the method you're scanning through and for re-usability.
💡 More dev tips: https://t.co/LhsCAz563J
#PHP #DevTips https://t.co/Y7zowSh6Xl