The magic behind Laravel's new defer() helper
Here's how Laravel's defer() function, which was introduced a few months ago, works behind the scenes.
Read more [www.amitmerchant.com]
Posts tagged with helpers
Here's how Laravel's defer() function, which was introduced a few months ago, works behind the scenes.
Read more [www.amitmerchant.com]
– flareapp.io - submitted by Spatie
Read more [flareapp.io]
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.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
No spam. Unsubscribe anytime. You can also follow me on X.
If you're using Ignition (and you probably are if you're on Laravel 6), you know have access to a new helper function that help you debug code.
We now give you ddd - a globally available helper function that does everything that you love about dd and sprinkles everything that Ignition has to offer on top of it.
Read more [flareapp.io]
Liam Hammett created a cool package to easily create Blade Helpers in Laravel.
I put together a package that attempts to help make these helper functions that little bit easier to define without the boilerplate of returning the string or having to consider what an expression may be when creating a Blade directive.
Read more [liamhammett.com]
Caleb Porzio created a new Laravel package with a couple of very usefull functions.
I packaged up all the helper functions I use in my projects. They are cool. You can install it by running composer require calebporzio/awesome-helpers.
Read more [calebporzio.com]
? Tip: the `abort` helper in @laravelphp can take any `Response` object!
— Joseph Silber (@joseph_silber) 19 juli 2018
Especially useful for redirection, since the `redirect` & `back` helpers only work in top-level controller methods.
When in a supporting method from which you can't `return`, use the `abort` helper ? pic.twitter.com/dFwhhXz211
Read more [twitter.com]
?? Who knew, Laravel's string helper class can generate uuids - woot!
— Caleb Porzio (@calebporzio) July 5, 2018
If you care, here's my UUID model trait I use (the packages are too heavy handed for me) https://t.co/L8Il1sH5VA pic.twitter.com/K6OwkHKQBD
Read more [twitter.com]
A little known helper function, called tap was added to Laravel 5.3. In this short post I'll explain how this function can be used. Let's first take a look at the tap function itself. It's actually a very short one. function tap($value, $callback) { $callback($value); return $value; } So you give it…
Miklós Galicz posted a short article on how he managed to override Laravel's str_slug helper function.
Long story short, until this is resolved one way or another... A really obscure but powerful tool can be a temporary solution for this. It's called Helper Overloading. Laravel's helpers are created in a way that checks if the method already exists. ... This is really great, the only thing remaining is to actually add our own method before Laravel creates it own version.
https://blackfyre.ninja/blog/fixing-slug-generation-problems
When working on projects I found myself, over time, needing the same string functions over and over again. Things like how to shorten a string but still let it end on entire word, replace the last occurrence of string in a string, ...
Instead of keeping these functions in a helper file locally in the project, I made a package out of it. It was a good opportunity to spice it up with bit of OO to make them chainable. An example:
[code] // outputs "MIDDLE" echo string('StartMiddleEnd')->between('Start', 'End')->toUpper();
In addition to it's own methods, the package provides <a href="https://github.com/spatie/string#integration-with-underscorephp">an integration</a> with <a href="https://github.com/Anahkiasen/underscore-php">Maxime Fabre's underscore package</a>.
You are very welcome to submit pull requests to add functions that you feel are missing. Be sure to include some unit tests to ensure everything working as intended.
Granted, it isn't the most sexy package in the world, but it sure is handy.
<a href="https://github.com/spatie/string">https://github.com/spatie/string</a>