Combining query scopes with explicit model names
?Combining query scopes with explicit model names will help keep code cleaner and easier to understand #laravel pic.twitter.com/ixzDdrZcRT
— Chris Gmyr (@cmgmyr) July 12, 2017
?Combining query scopes with explicit model names will help keep code cleaner and easier to understand #laravel pic.twitter.com/ixzDdrZcRT
— Chris Gmyr (@cmgmyr) July 12, 2017
I love this little “owns” trait/method that @michaeldyrynda & I came up with for Confomo.
— Matt Stauffer (@stauffermatt) July 7, 2017
Look at that expressiveness. :kisses fingers: pic.twitter.com/dE731Ko1Zw
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."
Marty Cagan, who held jobs at eBay, AOL, Netscape and HP, describes the most important differences between good and bad product teams.
What I’ve learned is that there is a profound difference between how the very best product companies create technology products, and the rest. And I don’t mean minor differences. Everything from how the leaders behave, to the level of empowerment of teams, to how the organization thinks about funding, staffing and producing products, down to how product, design and engineering collaborate to discover effective solutions for their customers.
Let's have a little fun! Yitzchok Willroth, better know as Coderabbi, created a new package that can improve the output of PHPUnit.
Here's what the output of a testrun looks like with his package installed.
David Négrier, CTO of the CodingMachine, wrote a nice article on why he likes and how his team uses typehints.
As a developer consuming thisfunction, I know how to use it. And if I’m using it wrong, I’ll know right away because PHP will crash with a nice error message when the function is called rather than with a cryptic error some time later.
https://www.thecodingmachine.com/type-hint-all-the-things/
Personally I like typehints too, because the potential readability improvement the article touches upon.
Note: (I only include this paragraph because it's mentioned in the intro of the article, don't want to stir up a discussion) the fuzz about that "Visual Debt" video was overblown. Even though I didn't agree with all of it, it was nice to hear Jeffrey's way of thinking.
Testing @spatie_be 's media library with the new #laravel upload fakes ? Trust, but verify ? #testing pic.twitter.com/Ss98rGloRf
— Christoph Rumpel (@christophrumpel) July 3, 2017
Read more [twitter.com]
Our recently released image-optimizer package can shave off some kilobyes of PNGs, JPGs, SVGs and GIFs by running them through a chain of various image optimization tools. In this blog post I'll tell you all about it. First, here's a quick example on how you can use it: use…
Curl is not your only tool when creating or testing out APIs. On her blog Lorna Jane Mitchell made a nice list of alternatives.
At a conference a few days ago, I put up a slide with a few of my favourite tools on it. I got some brilliant additional recommendations in return from twitter so I thought I'd collect them all in one place in case anyone is interested - all these tools are excellent for anyone working APIs (so that's everyone!).
On his blog Left On The Web, Stefan Koopmanschap lists the podcasts he's listening to. His selection contains both tech and non-tech podcasts.
Brent Roose wrote down his thoughts around how things like fonts, spacing, docblock, ... can influence the cognitive load of a programmer.
As a professional programmer, I'm reading and writing code on a daily basis. I'm working on new projects, doing code reviews, working with legacy code, learning documentation etc. Based on my own experience and that of colleagues, being a programmer often involves a lot more reading than actually writing code. Whether it's your own code or that of others, when you open a file, you have to take it all in. You need to wrap your head around what's going on, before you're able to write your code. Doing this day by day, it's important to find ways to make this process easy. To try and reduce this cognitive load as much as possible. Streamlining the way you take in code, will allow you to not only work faster and better; but also improve your mental state and mood.
https://www.stitcher.io/blog/a-programmers-cognitive-load
Visual debt is real.
Browsershot is a package that can easily convert any webpage into a image. Under the hood the conversion is made possible new headless options in Chrome 59. In this post I'd like to show you how you can use Browsershot v2. Here's a quick example of how it can be used:…
At this year's WWDC Apple announced a new framework called ARKit, which makes it easy to build augmented reality type of apps. The framework will be released as part of iOS 11, but developers can already toy with it. There's a site called Made With ARKit that shows some pretty impressive demos that they've already built.
Here are a few of my favorites:
More demos on http://www.madewitharkit.com/
In a new post on his blog Sebastian De Deyne, JavaScript (and all-round) wizard at Spatie, describes a technique to expose Vue components as a plugin.
We recently published a tabs package. Initially, users needed to register two components in order to create a tabular interface: Tabs, which acts as a container, and Tab, which defines a single tab and its contents in the interface.Since developers are most likely going to use both components together, and there's a fair chance that they'd want to register them globally like in the example, it made sense to provide some sort of auto-install option.
https://sebastiandedeyne.com/posts/2017/exposing-multiple-vue-components-as-a-plugin
Like this simple new addition coming in Laravel 5.4.28, it's handy for when you need to eager-load related models of a collection on the go. pic.twitter.com/0W3hqG97BR
— Mohamed Said (@themsaid) June 21, 2017
Read more [twitter.com]
On the Bugsnag blog, Graham Campbell, wrote a guest post on the basics of creating a Laravel package. If you've ever wanted to create a package, this is a good starting point.
Laravel is a massively influential PHP framework, and its simple but powerful design means that it’s easy to utilize packages in your application. In this blog post we will look at the basics of creating and installing Laravel packages.
? Go crazy with Blade directives. The simplest things can abstract away tons of visual noise from your templates. pic.twitter.com/p5udGWJkhd
— David Hemphill (@davidhemphill) June 22, 2017
Read more [twitter.com]
Mattieu Napoli shows how you can use non breaking spaces to make long test function names more readable.
Yes. This article is about using non-breakable spaces to name tests. And the fact that it’s awesome. And why you should use them too.public function test a user can add a product to a wishlist() { // ... }
The code above is valid PHP code and works. Non-breaking spaces (aka in HTML) look like spaces in editors but are actually interpreted like any other character by PHP.
http://mnapoli.fr/using-non-breakable-spaces-in-test-method-names/
It's cool that it works, but I'm not really a fan of this. I very much prefer how test runners like jest go about this by passing the name of the test to a function so you can use spaces.
Cool little Laravel 5.5 Eloquent Collection macro to assert two model collections are the same ?? pic.twitter.com/zzbkr1fL9T
— Adam Wathan (@adamwathan) June 14, 2017
Read more [twitter.com]
In a new blogpost at Sitepoint Christopher Pitt talks about snapshot testing. He first explains how snapshot testing can help test React components. Then he demonstrates how you can use our home grown package to use snapshot testing in PHP. Finally he shows pretty cool use cases for snapshot tests.
Ah-ha moments are beautiful and rare in programming. Every so often, we’re fortunate enough to discover some trick or facet of a system that forever changes how we think of it.For me, that’s what snapshot testing is.
You probably write a lot of PHP code, but today I want to talk about something I learned in JavaScript. We’ll learn about what snapshot testing is and then see how it can help us write better PHP applications.
https://www.sitepoint.com/snapshot-testing-viable-php/
If you want know more about snapshot testing, check out this blogpost by my colleague Sebastian, or watch this video where I refactor some tests to use snapshots.
On Twitter I see a bunch of people regularly tweeting very nice code snippets. Instead of only retweeting those, I'm going to add them to my blog. I'll tag them with tweet.
Here's the first one:
request()->query() is a life saver when dealing with tables that store "sorts" and "filters" in a query string. pic.twitter.com/84P6xvTvSz
— Caleb Porzio (@calebporzio) June 21, 2017
Read more [twitter.com]