New in PHP 8
– stitcher.io – Edit
My colleague Brent explains everything that's coming in PHP 8. Union types alone will make it a worthwile release.
Read more [stitcher.io]
– stitcher.io – Edit
My colleague Brent explains everything that's coming in PHP 8. Union types alone will make it a worthwile release.
Read more [stitcher.io]
Disabling client-side browser validation will allow you to test your real validation rules, instead of Chrome's.
Read more [cwhite.me]
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
– twitter.com – Edit
🕵️♂️ Just discovered "->optional()" in $faker for my Laravel factories.
— Caleb Porzio (@calebporzio) January 18, 2020
Check it out.
Did you already know about this? pic.twitter.com/MrVETY7i3f
Read more [twitter.com]
by Freek Van der Herten – 10 minute read – Edit
For many years we've relied on Travis to run the tests of our packages. For projects we used Circle CI. Recently we moved this responsibility from Travis and Circle CI to GitHub actions. In this blogpost I'd like to explain why and how we did this.
– reinink.ca – Edit
Jonathan Reinink wrote another excellent blog post.
As much as possible, keep data fetching to the perimeter of your Laravel applications. What do I mean by this? In the simplest terms, it means running your database queries in your controllers.
Read more [reinink.ca]
– twitter.com – Edit
TIL: in @laravelphp blade you can pass data up the main layout you are extending #laravel #php pic.twitter.com/IEWYHv0uyE
— Sidrit Trandafili (@strandafili) 23 december 2019
Read more [twitter.com]
– twitter.com – Edit
⚗️ 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.
— Jason McCreary (@gonedark) 23 december 2019
Since it uses the existing `Client` and `Response` objects, there's no need to change your implementation. pic.twitter.com/Ui2Zyqj2Lt
Read more [twitter.com]
by Freek Van der Herten – 1 minute read – Edit
In this video I demonstrate how to you can create a fluent API by using pending objects. We'll take a look at how subscribers can be created in Mailcoach. As a bonus I explain how jobs are dispatched using a pending object in Laravel.
– twitter.com – Edit
TIL that there's a shorthand for the dreaded pluck('id')->toArray() combo in #Laravel:$user->posts->modelKeys() will return all related post IDs that are attached to the user model! 🔥https://t.co/imIPlVNjwi
— Alex (@AlexVanderbist) 19 november 2019
S/O to @rubenvanassche for telling me this existed 👌 pic.twitter.com/c3sANn52M8
Read more [twitter.com]
– stitcher.io – Edit
Brent explains what view models are and how you can use them. We use view models in almost every project at Spatie.
In essence, view models are simple classes that take some data, and transform it into something usable for the view. In this chapter I'll show you the basic principles of the pattern, we'll take a look at how they integrate in Laravel projects, and finally I'll show you how we use the pattern in one of our projects.
Read more [stitcher.io]
– twitter.com – Edit
Here's a little tip: you can use `yield` in phpunit data providers to make them a little more readable pic.twitter.com/rQeKw7jBed
— Brent (@brendt_gd) 12 december 2019
Read more [twitter.com]
– twitter.com – Edit
🔥 Like Model::query() to align subsequent calls, here's the world's simplest macro to do something similar in routes. pic.twitter.com/OzWJ7Fcx8F
— Paul Redmond 🇺🇸 (@paulredmond) 12 december 2019
Read more [twitter.com]
– Edit
Nikita Popov discusses some low level performance optimizations in PHP.
by Freek Van der Herten – 17 minute read – Edit
A year ago, I wrote a recap of 2018. Now that 2019 is coming to a close, I thought it might be fun to write a similar post on what I did this year.
– twitter.com – Edit
Not sure if your dependencies are up-to-date? Run `composer outdated` and find out. ⚡️ pic.twitter.com/6ZShopPapn
— NUNO MADURO ➕ (@enunomaduro) December 3, 2019
Read more [twitter.com]
– twitter.com – Edit
Thanks to the improved type variance in PHP 7.4, the `self` return type hint is now safe to use in a class that you expect to be overridden (happens a lot in the packages we create)
— Freek Van der Herten (@freekmurze) December 3, 2019
Demo: https://t.co/7vRTaOwRhD
RFC: https://t.co/1RpnFIjlKC#php pic.twitter.com/SfAaxRDt4m
Read more [twitter.com]
– stitcher.io – Edit
As usual, my colleague Brent wrote a post with clear instructions on how to upgrade. As a bonus he also provides some necessary steps to get PHP 7.4 to work in Valet.
Read more [stitcher.io]
by Freek Van der Herten – 3 minute read – Edit
In PHP 7.4, two new features were introduced that I'd like to use in my packages and projects: short closures and typed properties. Even though an IDE can help with converting to the new syntax, I'd don't want to manually hunt down all the places where the new syntax can be used. Lucky there's a tool that can do this work automatically.
– twitter.com – Edit
?You can mutate request data using @laravelphp 's form requests instead of doing it in the controller. By overwriting the validationData() method, you can mutate data BEFORE validation. Overwrite the validated() method to mutate AFTER validation. #Laravel #php pic.twitter.com/VAVXYAHCFC
— Neil Keena (@neilkeena) November 4, 2019
Read more [twitter.com]
by Freek Van der Herten – 3 minute read – Edit
A while ago, I created an easy to use framework agnostic PHP package to read and write CSV and Excel files called spatie/simple-excel. Behind the scenes, generators are used to ensure low memory usage, even when working with large files. Today I added a method that allows you to stream CSV files to the browser. In this small blog post, I'd like to demonstrate how you can use it.