Internal classes in PHP
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]
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."
Sharing learning via code
Konstantin Kudryashov, one of the speakers at the upcoming Full Stack Europe conference, makes the case for sharing new insights early.
When you build new feature as a team, and it requires a lot of new learning, do not hoard new knowledge in your head. Instead, incrementally commit each unit of learning into working code. Hide that partial logic behind a feature flag. The feature would be incomplete, but work-in-progress outputs will expose meaningful and demonstrable progress. To increase team’s awareness of outputs, add links into the feature tracker or documentation.
Read more [stakeholderwhisperer.com]
A new coat of paint for freek.dev original
It's funny that even something as simple as a blog app is never finished. One and a half years ago, I did a significant update my moving my blog from WordPress to a Laravel app. In August of last year, I also ditched my custom admin section in favor of Nova. Even though not that much time has passed, it was time for a refresh of the entire blog.
A project at Spatie
My colleague Brent offers some insights on a big project we're currently working on at Spatie.
The month May marks the first year anniversary of a client project I've been working on at Spatie. I thought it useful to share some statistics with the community, and give you a feeling of what a "real life web project" might look like.
Read more [stitcher.io]
Bash/Shell Autocompletion for Composer
Bram Van Damme explains how you can get autocompletion for most composer commands.
Read more [www.bram.us]
Functional architecture: the pits of success
Here's a talk by Mark Seeman that explains the differences between object oriented and functional programming.
Parallel PHP: The Next Chapter
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.
Ever wondered what "hydrate" means?
?? 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]
A lot of html tags, like "body" and "head" are optional
I always knew the browser was pretty smart about dealing with what I thought was incomplete HTML, but I didn't know the HTML5 spec actually defined a bunch of tags as optional ?
— Adam Wathan (@adamwathan) May 18, 2019
Google actually recommends writing your HTML this way:https://t.co/t3fu98s5IM pic.twitter.com/v2RAr5Whl9
Read more [twitter.com]
Using Eloquent's firstOr
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]
Calculating totals in Laravel using conditional aggregates
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]
Exceptional Exceptions
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]
Improving title tags
? PSA: <title> tags matter (especially for people browsing the web with screen readers)
— Caleb Porzio (@calebporzio) May 28, 2019
ICYMI: https://t.co/g7IdUkEjiQ pic.twitter.com/ANIjMZUMDN
Read more [twitter.com]
Plucking multiple attributes
? 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]
Live refactor: contributing to open source
In this video Jason McCreary creates a PR that adds a null driver to our laravel-newsletter package.
React for Vue developers
In a new blogpost, Sebastian De Deyne compares Vue syntax with React syntax.
This post is a succinct rundown of most Vue features, and how I would write them with React in 2019 with hooks.
Read more [sebastiandedeyne.com]
Caching the entire response of a Laravel app original
When a request comes in your app will return a response. To create that response, your application has to do some work. Most likely queries will execute. This all takes some time. Wouldn't it be nice if the same request comes in, we can return the response the application has constructed previously?
A rule to validate delimited data original
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.