Laravel event projector v2 has been released

Original – by Freek Van der Herten – 18 minute read

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.

Read more

A Laravel package to flash messages

Original – by Freek Van der Herten – 3 minute read

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.

Read more

Stay up to date with all things Laravel, PHP, and JavaScript.

Follow me on Twitter. I regularly tweet out programming tips, and what I myself have learned in ongoing projects.

Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

A package to create personal data exports

Original – by Freek Van der Herten – 4 minute read

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.

Read more

A package to use Artisan Tinker in your browser

Original – by Freek Van der Herten – 2 minute read

Laravel comes with a very handy tinker command out of the box. Unfortunately running multiple lines of code on the command line, or editing the code you just executed, can be a bit bothersome. That's why we created a new package called laravel-web-tinker that allows you to run arbitrary code in your…

Read more

Tools to automatically format PHP, JavaScript and CSS files

Original – by Freek Van der Herten – 2 minute read

When working on a project with other people, it's important to pick a coding standard. A coding standard like PSR-2 in the PHP world specifies rules on where certain characters, like braces of an if statement, or comma's should be put. Agreeing on a coding standard makes the code more readable for…

Read more

laravel-backup v6 has been released

Original – by Freek Van der Herten – 4 minute read

laravel-backup is a Laravel package that can backup your application. It can create a zip containing a dump of your database together with other files that you can select. Using the power of Laravel's filesystem abstraction this zip can than be uploaded to one or more remote filesystems. The package…

Read more

Preventing spam submitted through forms

Original – by Freek Van der Herten – 2 minute read

When adding a form to a public site, there's a risk that spam bots will try to submit it with fake values. We recently released a new package, called laravel-honeypot, that can detect these spammy requests. How honeypots work # The majority of spam bots are pretty dumb. You can thwart most of them…

Read more

A recap of 2018

Original – by Freek Van der Herten – 9 minute read

Now that 2018 is coming to a close, a lot of awesome people have written a recap post. Here's mine! The most significant change on a personal level is that my girlfriend an I bought a house in Ghent. Together with our two kids, we moved this summer, and we now live in an awesome house that's very…

Read more

Handcrafting mocks

Original – by Freek Van der Herten – 7 minute read

In an application I was working on I wanted to implement automated tweets. Of course, this logic should also be tested. In this blogpost I'd like to show you how you can easily handcraft your own mocks. Setting things up # Let's first take a look at how you can tweet something in PHP. We're going to…

Read more

Configuring PhpStorms code generation

Original – by Freek Van der Herten – 4 minute read

I've been using PhpStorm for quite some time now, but never took the effort to fix a few minor annoyances I had with it. Getting rid of the default comment for new PHP files # First up, when creating a new PHP file or class you PhpStorm will add this comment block like this by default: /** * Created…

Read more

Failing gracefully on stage

Original – by Freek Van der Herten – 1 minute read

Here's a video of Surma having technical problems while presenting his State of Houdini talk. Luckily Jake Archibald and others "help" him out ? No matter how well you prepare a talk, you can always have technical difficulties. If you handle the failure gracefully, the public won't mind.…

Read more

A better way to register routes in Laravel

Original – by Freek Van der Herten – 3 minute read

Let's take a look at how you can define routes to controllers in Laravel. By default you can do it like this: Route::get('my-route', 'MyController@index'); This will look for the MyController class in the App\Http\Controllers namespace. This default namespace is set up in Laravel's…

Read more

How PHP conferences can be improved

Original – by Freek Van der Herten – 10 minute read

The past few years I visited and spoke at a lot of PHP conferences. PHP Benelux, Laracon EU and US, PHP UK Conference, PHP World are only a few of the conferences I thoroughly enjoyed. Visiting those conferences can be recommended to anyone interested in PHP. Regardless of which level you're at…

Read more

Calling an invokable in an instance variable

Original – by Freek Van der Herten – 2 minute read

Invokables in PHP are classes that you can use as a function. They have been around since PHP 5.3 and have many interesting use cases. Here's a quick example. class Invokable { public function __invoke() { echo 'I have been invoked'; } } You can use it like this: // outputs 'I have been invoked'…

Read more

Making Nova fields translatable

Original – by Freek Van der Herten – 5 minute read

Laravel Nova is cool package to quickly create admin interfaces in a Laravel app. Unfortunately there's no support for multiple locales out of the box. A while ago we published a package called nova-translatable that makes any of the built in field types translatable. Using the package # In order to…

Read more

Our packages have been downloaded 20 million times

Original – by Freek Van der Herten – 3 minute read

At Spatie we do a lot of open source work. You can find a list of our packages on the open source section of our website. I'm proud to share that, according to Packagist, the Spatie packages have now been downloaded over 20 million times. The rate at which they are being downloaded is growing too.…

Read more

Easily switch PHP versions in Laravel Valet

Original – by Freek Van der Herten – 2 minute read

Besides enjoying some greenfield work, we often have to work on legacy projects at Spatie too. Sometimes those projects don't run on the latest PHP version. I this blogpost I'd like to show you a way to switch PHP version easily when using Laravel Valet. (I know you could also use Docker or…

Read more