Improving assertions on Laravel fakes original
by Freek Van der Herten – 4 minute read – Edit
by Freek Van der Herten – 4 minute read – Edit
– medium.com – Edit
Liam Hammet wrote a good blogpost on the isset language construct.
Let’s take a look through how isset behaves and what’s so special about it. Even if you’re a veteran PHP developer, hopefully, you’ll pick up something new here.
Read more [medium.com]
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."
by Freek Van der Herten – 8 minute read – Edit
A webhook is a mechanism where an application can notify an other application that something has happened. Technically, the application sends an HTTP request to that other application. In this blog post, I'd like to introduce you to two packages that we recently released. The first is laravel-webhook-server, which allows you to send webhook requests. The second one is laravel-webhook-client, which makes it easy to receive those webhook request.
– stitcher.io – Edit
Brent wrote another nice post on PHP. This time on the upcoming typed hints feature of PHP 7.4.
Typed class properties were added in PHP 7.4 and provide a major improvement to PHP's type system. These changes are fully opt-in and backwards compatible. In this post we'll look at the feature in-depth.
Read more [stitcher.io]
– twitter.com – Edit
In the project that @freekmurze and I are working on, I needed the ability to replicate an existing Eloquent model into a different Eloquent model.
— Marcel Pociot ? (@marcelpociot) June 12, 2019
If you feel like this could be useful for you as well, here's the little trait for that:https://t.co/IXFpAsxE35 pic.twitter.com/fCccKmLdQs
Read more [twitter.com]
by Freek Van der Herten – 2 minute read – Edit
Imagine you're building that your app can notify your user, but you don't want to send more than one notification in a timeframe of five seconds. How are you going to test the time aspect? Do you have to create a test that takes five minutes?
Matthias Noback wrote down some thoughts on the Laravel container
Laravel's service container looks great. I like the idea that it can figure things out mostly by itself. I like that it's PHP-based, and that its syntax is quite compact. I think that most of the convenience functions (e.g. resolve()) and exotic options (like $this->app->resolving()) should be ignored. The best thing you can do for your application in the long term is to let all your services use dependency injection, and to inject only constructor arguments. This keeps things simple, but also portable to other frameworks with other dependency injection containers, or other architectural styles, when the time is there.
Read more [matthiasnoback.nl]
– stitcher.io – Edit
My colleague Brent wrote another excellent blog post, this time on tests and types.
So while strong types can help us to ensure program correctness, some tests will always be a necessity to ensure business correctness. It's a matter of "both and", not "either or".
Read more [stitcher.io]
by Freek Van der Herten – 6 minute read – Edit
– nunomaduro.com – Edit
Nuno Maduro, engineer at Algolia, explains what is the value of the @internal tag
The PHP @internal tag can be used to denote that the associated class/method is internal to the library. It's supported by PHPStorm and it warns people that those classes/methods are not meant to be used
Read more [nunomaduro.com]
– www.bram.us – Edit
Bram Van Damme explains how you can get autocompletion for most composer commands.
Read more [www.bram.us]
– Edit
Joe Watkins, core contributor and pthreads author, is working on a new threading API for PHP called parallel. It might be a while before it is released.
Recently, I set to work on a new threading API, named Parallel, it is not an exact clone of any existing threading API, it is an API focused on being simple and hiding the complexity inherent in utilising parallelism in your application, it is also focused on being forward compatible with the JIT, for that day when we can actually execute machine code in userland and in parallel.
https://blog.krakjoe.ninja/2019/02/parallel-php-next-chapter.html
EDIT: meanwhile a stable version has been released. You can find it in this repo on GitHub.
– twitter.com – Edit
?? Laravel Core Adventures - Did you know?
— Christoph Rumpel ? (@christophrumpel) May 17, 2019
Ever wondered what "hydrate" means? I've been there. Then I realized it's just a fancy word for filling an object with data.
In this Eloquent Builder example, Laravel fills a new collection object with models from an array. pic.twitter.com/D5t0EVnksM
Read more [twitter.com]
– twitter.com – Edit
You know `firstOrFail`, `firstOrCreate`, etc in @laravel
— Jeff Madsen (@codebyjeff) May 19, 2019
There's also a simple `firstOr` that will run a callback if not found pic.twitter.com/q7QmPR1y1S
Read more [twitter.com]
– reinink.ca – Edit
Jonathan Reinink wrote another awesome post on how to handle a complicated query.
I was asked recently how to calculate multiple totals (aggregates) in Laravel in the most efficient way. For example, maybe you have an email subscription service and want to display various totals based on your subscribers
Read more [reinink.ca]
At the Clarabridge Developers blog, Toon Daelman wrote a good post on how to improve your exceptions.
You've made it to this post thinking "Why do we still need to talk about Exceptions?". Well, they're used everywhere in OOP codebases, but sometimes they're used in a way that make debugging a bit difficult. Let's look at some ways to make debugging exceptions a bit more fun!
Read more [engagor.github.io]
– twitter.com – Edit
? Laravel quick tip
— Sebastian De Deyne (@sebdedeyne) May 21, 2019
Use ->map->only on Eloquent collections to pluck multiple attributes pic.twitter.com/z3c1sOox9J
Read more [twitter.com]
by Freek Van der Herten – 3 minute read – Edit
laravel-validation-rules is a package that contains handy custom validation rules that are being used in various client projects we made at Spatie. Last week I added a new validate rule called Delimited to the package.
In this blog post, I'd like to explain why we added it and how it can be used.
– stitcher.io – Edit
In an awesome post, my colleague Brent explains that PHP is in a very good state nowadays. If you dismissed the language previously, now is a good time to take another look.
PHP managed to evolve quite a bit since the 5.* days. Today I'm addressing the people who are either not programming in PHP anymore, or are stuck in legacy projects.
Read more [stitcher.io]
– mattallan.me – Edit
Matt Allan explains why using an offset is slow when used on large datasets.
It turns out it’s easy to page through results without using offset. All we have to do is keep track of the last ID we saw, then filter the results so we only fetch rows we haven’t seen.
Read more [mattallan.me]