MySQL behaviour you should be aware of

I've used MySQL over the years and it has served me well. I didn't know the default behaviour is a bit messed up. Look at this video for some examples:

Because there's a lot of validation being done by the php-applications I work on, I've yet to run into the problems described above.Though the default configuration has some problems I'm not migrating my current projects from MySQL to something else. But for fresh new projects, I'll consider using PostgreSQL.

If you are considering this as well here's a guide by Chris Fidao (I stumbled upon the video above when reading that guide). If you are in any way interested in running your own server you have to subscribe to his excellent newsletter, Servers for Hackers, and buy the book with the same name.

Read more

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.

Functional programming in PHP

Almost a year ago Igor Wiedler wrote three articles on his blog about the state of functional programming in PHP.

The first article explores iteration. You'll learn to turn this


$admins = [];
foreach ($users as $user) {
    if (is_admin($user)) {
        $admins[] = $user;
    }
}

into this


use function iter\filter;
$admins = filter('project\user\is_admin', $users);

In the second one he explains a very nice way to traverse an associative array. How you currently do it:


$baz = (isset($data['foo']['bar']['baz'])) ? $data['foo']['bar']['baz'] : null;

How you'll do it in the future:


use function igorw\get_in;
$baz = get_in($data, ['foo', 'bar', 'baz']);

The final article shows you a nice syntax to handle objects that return null-values.

All the articles mention libraries that you can use in your code today.

Read more

Inside Composer's speed boost

If you've been following the news, you'll have noticed that yesterday Composer got a bit of a speed boost. And by "bit of a speed boost", we're talking between 50% and 90% reduction in runtime depending on the complexity of the dependencies. But how did the fix work? And should you make the same sort of change to your projects? For those of you who want the TL/DR answer: the answer is no you shouldn't.
http://blog.ircmaxell.com/2014/12/what-about-garbage.html

Read more

Add Two-Factor authentication to your Laravel application

Authy makes it easy to integrate two-factor authentication into your existing Laravel application. It's user-end implementation is versitile, offering support for both smart-phones and standard phones. Furthermore, implmentation with its API is easy and seamless. Finally, its analytics and data tracking can you provide insights into your users and how they interact with your application's authentication system.

This tutorial assumes that you have an Authy developer account (which can be created here ), an application (either testing or production), and your application's API key.

http://blog.enge.me/post/installing-two-factor-authentication-with-authy

Read more