Optimize images in Laravel apps

A while ago we released image-optimizer. In short this package can make all kinds of images smaller by stripping out metadata and applying a little bit of compression. Read this blogpost to learn more about it. Although it’s pretty easy to work with the package, we felt that we could deliver a more seamless experience […]

Continue reading →

Easily optimize images using PHP (and some binaries)

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 Spatie\ImageOptimizer\OptimizerChainFactory; $optimizerChain = OptimizerChainFactory::create(); $optimizerChain->optimize($pathToImage); The […]

Continue reading →

Easily convert webpages to images using PHP

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: Browsershot::url(‘https://example.com’)->save($pathToImage); History About three […]

Continue reading →

A Vue component to display tabs

Last week my company released a vue-tabs-component, a quality Vue component to easily display tabs. You can view a demo of the component here. In this post I’d like to tell you all about it. Why we created it If you’re just want to know what the component does, skip to the next section. Nearly […]

Continue reading →

A conversation on laravel-html

Hi, how are you? I’m fine thanks! How are you? I saw you released another package last week. Yup yup, you mean laravel-html, right? It was actually coded up by my colleague Sebastian, who did an awesome job. But why put out yet another html generator? Html generation is a solved problem, right? Yes, it […]

Continue reading →

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 →