A magic memoization function

Last friday Taylor Otwell tweeted an easy to use memoization function called once: Wanted a slick way to generalize class method memoization. Y'all don't even want to know how it works. 😈 🤘 pic.twitter.com/xRJAY1C14y — Taylor Otwell (@taylorotwell) November 4, 2016 Taylor was kind enough to share the source code behind the function. Because I’d […]

Continue reading →

A class to parse, build and manipulate URLs

For several projects and other packages we need to manipulate URL’s. Instead of coding the same URL class over and over again, we extracted URL manipulation to it’s own package. Here are some code examples on how you can use it. $url = Url::fromString(‘https://spatie.be/opensource’); echo $url->withHost(‘github.com’)->withPath(‘spatie’); // ‘https://github.com/spatie’ Query parameters can be retrieved and transformed: […]

Continue reading →

Managing opening hours with PHP

For several different clients we needed to display a schedule of opening hours on their websites. They also wanted to display if a department / store / … is open on the moment you visit the site. My colleague Seb extracted all the functionality around opening hours to the newly released opening-hours package. You create […]

Continue reading →

Taking care of backups with Laravel

A new major version of laravel-backup was recently tagged. This package can backup files and databases of your Laravel app (or any PHP application really). The backup consists of a zipfile containing a dump of the databases and all files that are selected for backup. The package will copy over the zipfile to external storage […]

Continue reading →

A package to easily work with regex in PHP

PHP offers some functions to work with regular expressions, most notably preg_match, preg_match_all and preg_replace. Unfortunately those functions are a bit hard to use. Take preg_match_all for example, it requires you to pass in an array by reference to get all the matches. When something goes wrong some of those preg_ functions return false, while […]

Continue reading →

Building a Laravel powered Slack bot

At Spatie we’ve recently introduced a bot to our Slack chat. We’ve named him Paolo (after the waiter in our favourite Italian restaurant in Antwerp: La Fontanella Da Enzo). Here’s a demo of Paolo (the bot) in action. Behind the scenes Paolo is powered by a Laravel application that responds to all requests Slack is […]

Continue reading →

Laravel Analytics v2 has been released

One of our more popular packages is laravel-analytics. The package makes it easy to fetch information such as pageviews, top referrers, etc… from the Google Analytics API. In our Blender-based projects we use the fetched data to display a nice chart in the admin section: Laravel-analytics is one of the first packages we ever created. […]

Continue reading →

Find out where a query is executed in a Laravel app

The Query Tracer package can help you find out where a specific database query is being called. It works with both Clockwork and the Laravel Debugbar. Here’s a screenshot taken from the readme: https://github.com/fitztrev/query-tracer EDIT: turns out that Laravel Debugbar can do this out of the box: https://twitter.com/barryvdh/status/732570607058046977 Freek Van der Herten Freek Van der Herten […]

Continue reading →