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.

Fetch: the new AJAX API

One of the worst kept secrets about AJAX on the web is that the underlying API for it, `XMLHttpRequest`, wasn't really made for what we've been using it for. We've done well to create elegant APIs around XHR but we know we can do better. Our effort to do better is the `fetch` API. Let's have a basic look at the new `window.fetch` method, available now in Firefox and Chrome Canary.
http://davidwalsh.name/fetch

Read more

The benefits of creating packages original

by Freek Van der Herten – 1 minute read

In the last few months various little parts of our custom built CMS were made available as composer installable packages. Though creating a package takes some time, there are many benefits: my colleagues and my future self can benefit from the same documentation that is written for the consumers of…

Read more

Manage newsletters in Laravel 5 original

by Freek Van der Herten – 1 minute read

A few hours ago I tagged version 1.0.0 of a my new package: laravel-newsletter. It provides a very easy way to interact with email marketing services. Or maybe I should simply say MailChimp, as it is currently the only supported supported service. After you install the package (un)subscribing an…

Read more

MailChimp API v3 is officially launched

V2.0 of the API was a weird hybrid of RESTful and RPC practices, which required everyone to learn our own special style of API design. With a few minor exceptions, API v3.0 is fully RESTful. This allows us to express in a couple dozen resources what it took the last version 120 distinct endpoints to accomplish.
http://devs.mailchimp.com/blog/api-v3-0-officially-launched/

Consuming this API doesn't seem to be that hard but I hope they'll release a PHP wrapper soon.

Read more

Modern PHP hosting

Over at the Fortrabbit-blog grown up graffiti kid Frank Lämmer provides an excellent overview of what your options are when looking for PHP-Hosting.

Let’s face it: web hosting is a market for lemons. There are so many providers. New categories are emerging. Borders blur. Microservices everywhere. It’s complex. It’s noisy. It’s hard.
http://blog.fortrabbit.com/php-hosting-possibilities

I used to work with providers that offered sharing hosting that could be administered with tools like Plesk and cPanel. The biggest drawbacks of shared hosting are that these environments don't get updated regularly and you can't really install all the tools you need. We've also had serious troubles with performance in some cases (presumably caused by other users on the same machine).

Thanks to all the excellent resources on server management (like serversforhackers.com and sysadmincasts.com) and tools to provision them (like Forge) I feel confident enough to administer my own boxes. A little over a year ago all new projects at Spatie are hosted on DigitalOcean. We have multiple droplets running and haven't run into any of the problems we faced with the old school hosting providers.

Read more

Sharing controller logic with traits

We've moved our logic into a trait, a trait can be shared between many controllers without inheritance and it's more reasonable to do things with views and redirects here (though still not ideal). This in my eyes is the best solution to the problem, it's what traits are good for and it's quite convenient.
http://tech.graze.com/2015/04/14/sharing-controller-logic-with-traits-in-php/

The article provides a good overview of how the people at Graze came to this solution.

Read more

Comparing the PHP 7 and Hack Type Systems

After writing a couple small programs in Hack I've realized that it's not types themselves that make writing Hack enjoyable: it's the tight feedback loop Hack creates between the machine and myself. Integrating the Hack type checker into my editor means that my entire codebase is analyzed in a split second as soon as I save a file. This immediately surfaces any dumb, or subtle mistakes I made. I find myself writing code fearlessly: when I forget what a function returns, I just write code that calls it with what I think it returns. If I'm wrong, the type checker will tell me immediately. I can fix it quickly, and move on.

PHP has always facilitated a tight feedback loop between the machine and the developer. Save the file, reload the browser, repeat. Hack's type checker makes this even faster. I look forward to being able to build similar tooling on top of PHP 7's strict mode.

http://www.dmiller.io/blog/2015/4/26/comparing-the-php7-and-hack-type-systems

Read more

Forty computer science concepts explained in layman’s terms

http://carlcheo.com/compsci

A handy list for when talking with your project manager. An example:

Asymmetric cryptography

Sharing identical keys works fine among 2 people. What if Alice want to exchange stuff with another guy named Carl, and Alice doesn’t want anybody to see their stuff too? Alice can’t use the same lock and key that she shared with Bob, else Bob can unlock the box easily!

Of course Alice can share a completely new and different lock and key with Carl, but what if Alice wants to exchange stuff with 10 different people? She will need to keep and manage 10 different keys!

So Alice come out with a brilliant solution. Now, she only maintains one key (private key). She distribute the same padlocks (public key) to her friends. Anyone can close the padlocks (encrypt), but only she has the key to open (decrypt) them. Now, anyone can send stuff to Alice using the padlock she distributed, and Alice no longer have to manage different keys for different people.

Read more

A medialibrary package for Laravel 5 original

by Freek Van der Herten – 3 minute read

At Spatie all our greenfield projects are powered by custom built CMS based on Laravel 5. An important part of the CMS is the medialibrary-component. It handles how uploaded files are associated with models. My intern and I recently took the time to release our medialibrary as a package on GitHub.…

Read more

Comparing the PHP 7 and Hack Type Systems

After writing a couple small programs in Hack I've realized that it's not types themselves that make writing Hack enjoyable: it's the tight feedback loop Hack creates between the machine and myself. Integrating the Hack type checker into my editor means that my entire codebase is analyzed in a split second as soon as I save a file. This immediately surfaces any dumb, or subtle mistakes I made. I find myself writing code fearlessly: when I forget what a function returns, I just write code that calls it with what I think it returns. If I'm wrong, the type checker will tell me immediately. I can fix it quickly, and move on.
http://www.dmiller.io/blog/2015/4/26/comparing-the-php7-and-hack-type-systems

Read more