Simplifying controllers original
In this blog post, I'd like to highlight two tips to make controllers in Laravel feel much lighter.
In this blog post, I'd like to highlight two tips to make controllers in Laravel feel much lighter.
Grégoire Pineau explains how you can find the source of a segfault in PHP.
Sometimes, a segfault happens, but you don’t know where, and your PHP installation does not have tools to find it. Or sometime, you think PHP is hanging, but you don’t know where. You may use xdebug, but you don’t want to click so many times on the « next call » button.
Read more [jolicode.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.
"Freek’s newsletter is one of the best ways to stay updated with the Laravel and PHP ecosystem. It consistently highlights useful packages, tools, and ideas from the community, especially the amazing work coming from Spatie. As a Laravel developer building SaaS and web platforms, I find it extremely helpful to discover practical tools and insights that improve my development workflow."
?? Laravel Core Adventures - Did you know?
— Christoph Rumpel ? (@christophrumpel) April 17, 2019
In Laravel, we can access related data as if we would call a class property. But in fact, this is just a shortcut/hack for using the relationship method we have defined.
The second approach has one advantage, your IDE can follow it. pic.twitter.com/OjL4zNqUnp
Read more [twitter.com]
It's a bit of a click baity title, but reading it I learning that all PHPUnit's asserts have a function equivalent.
During the preparation of TDD workshops, I began to think about how to write assertions. It turns out that there are several possibilities, but is there the only correct one?
Read more [arkadiuszkondas.com]
My colleague Brent offers some more details on the intricacies of Laravel's query builder.
I recently learned that not all query builder functionality in Laravel is "safe". This means that user input shouldn't be passed directly to it, as it might expose your application to SQL injection vulnerabilities.
Read more [stitcher.io]
Our laravel-query-builder package exposed a serious security issue: it allowed SQL injection attacks. Laravel Query Builder v1.17.1, which is now available, fixes the vulnerability. If you're using the package, stop reading now and upgrade to the latest version first. For Laravel 5.6, 5.7 and 5.8…
Laravel event projector is a package that aims to be the entry point for event sourcing in Laravel. It can help you setting up aggregates, projectors and reactors. Earlier today our team released v2. This version streamlines the projectors and reactors from v1 and adds support for aggregates.
In this blogpost I'd like to explain a potential problem with traditionally built applications. After that we'll take a look at what projectors and aggregates are. Finally we'll walk through an example how you can create an aggregate laravel-event-projector.
It's a minor thing but PHP's `isset` can accept multiple vars which will allow you to simplify your code. ? pic.twitter.com/GBgYEDSOya
— Eric L. Barnes (@ericlbarnes) April 4, 2019
Read more [twitter.com]
KH. Jebran Ali lists a few cool Laravel tricks
Laravel is full of hidden gems that I have discovered during working on different tasks. Some of these gems were less-known or un-documented features, functions parameters and hacks. In this blog post I will share those hidden gems with you, let’s get started.
Read more [meramustaqbil.com]
PHP UK is one of my favourite conferences. Unfortunately I couldn't make it this year, but I'll be sure to watch the videos that have been published a little while ago.
Here's a cool session on running PHP on AWS Lamba by Neal Brooks
You can watch all other talks in this playlist on YouTube.
? Here's an undocumented hidden @laravelphp gem. Did you know you there's a shorter way to retrieve models in a chunked way? ?https://t.co/Vj74GAfAAr#laravel #php pic.twitter.com/qcVr5bCqGZ
— Freek Van der Herten ? (@freekmurze) March 25, 2019
Read more [twitter.com]
Matt Allan took a deep dive learning about environment variables.
Laravel, Symfony, and other modern PHP frameworks use environment variables to store security credentials and configuration that changes from one machine to the next. ... Let’s break down what environment variables are, how they work, and how to correctly use them in your code.
Read more [mattallan.me]
How to test something you are pulling OUT of Storage.
— Jake Bennett (@JacobBennett) March 19, 2019
Typically Laravel Storage testing is comprised of asserting that you put something IN Storage. If you happen to be pulling something down from a Storage disk and doing some processing on it, this has been helpful. pic.twitter.com/VjSqo914US
Read more [twitter.com]
Anna Filina explains the handy platform option you can use in composer.json. It's a good idea to just use this in all of your projects.
Say you run the latest PHP version on your machine, but the server runs PHP 5.5. This means that when you decide to add a Composer package, it might propose a version that may not be installable on the server. The solution is surprisingly easy. You can instruct Composer to see the PHP version of your choosing.
Read more [afilina.com]
Over at the Tighten blog, Chris Trombley published a new post on how to use data providers in PHPUnit.
PHPUnit gives us a way to consolidate this common logic while varying our setup data, without losing the benefit of dedicated, smaller test methods. In this post, we'll explore PHPUnit's data providers. While data providers are available in any PHPUnit test suite, let's look at how they can help us tidy up our tests in a Laravel application.
Read more [tighten.co]
Exciting times in PHP land. Nikita Popov, Levi Morrison and Bob Weinand have officially proposed a concrete implementation for arrow functions.
Anonymous functions in PHP can be quite verbose, even when they only perform a simple operation. Partly this is due to a large amount of syntactic boilerplate, and party due to the need to manually import used variables. This makes code using simple closures hard to read and understand. This RFC proposes a more concise syntax for this pattern. ... Short closures are critically overdue, and at some point we'll have to make a compromise here, rather than shelving the topic for another few years.
Let's hope this one gets accepted!
Read more [wiki.php.net]
Our team at Spatie released new package called laravel-queuable-action. On his blog, my colleague Brent explains why we created it and how you can use it.
By introducing the concept of actions, we're able to separate responsibilities between classes better: jobs are used for data serialisation and executing tasks asynchronously; but they are not concerned with business logic anymore.
.
Read more [stitcher.io]
For the past few years, we've been using the laracasts/flash package to flash messages in all projects. In case you don't know: a flash message is a message that is being passed from a request to only the next request. The Laracasts package does its job pretty well. It has support for multiple flash messages, overlay messages. It comes with bootstrap styling out of the box and a few messaging levels preconfigured.
We've noticed that in our projects we only use a tiny bit of functionality from the laracasts/flash. That's why we whipped up our own lightweight package called spatie/laravel-flash. In this blog post, I'd like to introduce it to you.
One of the good things that GDPR brought us was the right to data portability. Shortly put, this means that an app should be able to export all data that it has for a user.
Because we have multiple apps at Spatie that need to create such an export, we decided to extract our solution to a package called laravel-personal-data-export. In this blog post, I'd like to introduce the package to you.
#Laravel tip of the day: if you want to find out which of your composer.json packages have released newer versions, just run "composer outdated". You will get a full list with all information. pic.twitter.com/2FOw39TBr4
— Laravel Daily (@DailyLaravel) March 6, 2019
Read more [twitter.com]