Sevalla is the all-in-one PaaS for your web projects. Host and deploy your applications, databases, object storage, and static sites. Enjoy advanced deployment pipelines, a complete database studio, instant preview apps, and one-click templates. The pricing is simple: no hidden fees, no seat-based pricing, and you pay only for what you use. Get real human support from developers.

Get started now with a $50 credit at Sevalla.com.

Managing opening hours with PHP

Original – by Freek Van der Herten – 2 minute read

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…

Read more

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

You can follow me on these platforms:

On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.

Every month 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 Laravel package to store language lines in the database

Original – by Freek Van der Herten – 3 minute read

In a vanilla Laravel installation you can use language files to localize your app. The Laravel documentation refers to any string in a language file as a language line. You can fetch the value of any language line easily with Laravel's handy trans-function. trans('messages.welcome'); //…

Read more

A better dd() for your TDD

Link –

On the Tighten blog Keith Damiani wrote an article how you can mold the dd helper to your liking.

An important part of every Laravel developer's debugging arsenal is the humble dd() helper function—"dump and die"—to output the contents of a variable and terminate execution of your code. In the browser, dd() results in a structured, easy-to-read tree, complete with little arrow buttons that can be clicked to expand or hide children of nested structures. In the terminal, however, it's a different story. ... Fortunately, it's simple to build your very own customized version of dd() to help tame your unwieldly terminal output.

https://blog.tighten.co/a-better-dd-for-your-tdd

Read more

Game & Watch LCD Donkey Kong recreated with HTML and CSS

Link –

James Holderness recreated the Donkey Kong Game & Watch without JavaScript. Amazing work.

There are two things I’ve always wanted to try in HTML: generating a photorealistic image using CSS, and creating an interactive game without the need for JavaScript. HTML Kong is the end result of those two ambitions – a reproduction of the Game & Watch video game, Donkey Kong, using just HTML and CSS.

For those of you that haven’t heard of it, Game & Watch was a line of LCD handheld video games from the 1980s. The Donkey Kong title was probably one of the most popular in the series, selling more than a million units worldwide. The game was split over two screens and built into a distinctive clamshell casing.

https://www.xn--8ws00zhy3a.com/blog/2016/07/html-kong

If you want to skip reading the making of and go straight to the game, click here.

Read more

The Laracon EU 2016 videos are now available

Link –

This year's Laracon EU was an amazing conference. The venue was astonishing, there were lots of cool talks and interesting people to talk to. If you're using Laravel or PHP going to this conference really is a no brainer.

If you were unable to attend or want to see the talk you missed during the conference you can now do so. The organisers have uploaded video's of all talks to their YouTube channel.

I had the honor speaking there as well. My talk was about managing backups with Laravel. Here's the video of my first ever conference talk:

At one point during my talk I show this slide on future plans for the package:screen-shot-2016-10-07-at-10-04-54

I'm proud to say that all that work is already done: version 3 of laravel-backup was made Laravel 5.3 compatible. Version 4 of the package uses Laravel 5.3's native notifications and uses PHP 7 features to keep the code clear. The db-dumper package, which is used under the hood, was rewritten and is now easier to use.

I'll definitely go to the next Laracon EU conference and hope to see you there too.

Read more

A Sequel Pro bundle to generate Laravel migration files

Link –

Colin Viebrock, author of the well know laravel-sluggable package, created a new Sequel Pro bundle that can genenerate Laravel migration files.

Connect to a database, and select a table in the left-hand column. From the application menu, choose Bundles › Export › Export to Laravel Migration. The resulting Laravel migration file will be saved to your desktop. You can then move this file into your Laravel project (usually /database/migrations) and then run artisan migrate.

https://github.com/cviebrock/sequel-pro-laravel-export

Read more

Beyond Console Debugging Tricks

Link –

Daniel Reis shows some alternatives for the best known form of debugging JavaScript console.log.

I don’t consider myself a nitpicker. That’s only true, and it’s all fine and dandy… until I find a console.log() that someone forgot to remove from the JavaScript code. And if we’re talking about debugger statements… all hell breaks loose! ... I collected some of the most common examples I can present as proper alternatives for that process.

https://medium.com/outsystems-experts/beyond-console-debugging-tricks-f7d0d7f5df4

Read more

Lesser known git commands

Link –

Tim Pettersen shares some of his git aliases.

Git has a strong commitment to backwards compatibility: many powerful features are hidden behind options rather than exposed as default behaviour. Fortunately Git also supports aliases, so you can create your own commands that do all manner of Git magic. Here’s a selection of the more useful (or at least entertaining) aliases defined in my .gitconfig

https://hackernoon.com/lesser-known-git-commands-151a1918a60

Read more

Sending a welcome mail with Laravel 5.3

Original – by Freek Van der Herten – 7 minute read

Recently I was working an a project where, in order to use the webapp, users should first apply for an account. Potential users can fill in request form. After the request is approved by an admin they may use the app. Our client expected that the barrier to request an account should be very low.…

Read more

Laravel-fractal v2 has been released

Original – by Freek Van der Herten – 1 minute read

Last week v2 of laravel-fractal was released. This package is a developer friendly wrapper around the League's Fractal package. It a Laravel context it can be used to transform your Eloquent models to JSON output for an API. Think of it as toJson (or toArray) on steroids. This is how you can work…

Read more

Our packages have been downloaded one million times

Original – by Freek Van der Herten – 12 minute read

I'm very happy to announce that, as of today, our Laravel and PHP packages have been downloaded a million times. We now have more than 80 packages registered on Packagist. All combined they are downloaded around 150 000 times a month, and that number seems to be growing. Our GitHub organisation has…

Read more

Creating a mail driver in Laravel

Link –

Over at Sitepoint, Younes Rafie wrote a tutorial on how to create a custom mail driver in Laravel 5.3. In the post he shows some code that can log all email to the database.

One of the many goodies Laravel offers is mailing. You can easily configure and send emails through multiple popular services. ... Laravel also provides a good starting point for sending mails during the development phase using the log driver, and in production using smtp, sparkpost, mailgun, etc. This seems fine in most cases, but it can’t cover all the available services! In this tutorial, we’re going to learn how to extend the existing mail driver system to add our own.

https://www.sitepoint.com/mail-logging-in-laravel-5-3-extending-the-mail-driver/

Read more

The MIT License, Line by Line

Link –

Kyle E. Mitchell goes over the MIT License, line by line.

If you’re involved in open-source software and haven’t taken the time to read the license from top to bottom—it’s only 171 words—you need to do so now. Especially if licenses aren’t your day-to-day. Make a mental note of anything that seems off or unclear, and keep trucking. I’ll repeat every word again, in chunks and in order, with context and commentary. But it’s important to have the whole in mind.

https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html

Read more

Computer Vision Syndrome

Link –

Eric L. Barnes explains what Computer Vision Syndrome is, and what you can do to avoid it.

In no point in human history have people been staring at bright screens just a few feet from their face like they are today. Computer vision syndrome or CVS (not to be confused with Concurrent Versions System) is one side effect to this, and it’s affecting millions of people.

The National Institute of Occupational Safety and Health reports computer vision syndrome affects about 90% of the people who spend three hours or more a day at a computer, which means almost everyone in our industry is susceptible.

https://laravel-news.com/2016/09/computer-vision-syndrome/

Read more

A little library to deal with color conversions

Original – by Freek Van der Herten – 1 minute read

My colleague Seb needed to convert some color values in PHP. He looked around for some good packages, but there weren't any that fit the bill. So guess what he did? He just created a new package called spatie/color. Here's what it can do: $rgb = Rgb::fromString('rgb(55,155,255)'); echo…

Read more

Using class_alias to maintain BC while moving/renaming classes

Link –

I've been using PHP for quite some time now, and I had never heard of class_alias before reading this post by Fabian Schmengler.

Sometimes you want to rename a class or move it to a different namespace. But as soon as it is used anywhere outside the package, this is breaking backwards compatibility and should not be done lightheartedly.

Luckily there is a way in PHP to have both, the old class and the new class, while deprecating the old one: class_alias().

https://www.schmengler-se.de/en/2016/09/php-using-class_alias-to-maintain-bc-while-move-rename-classes/

Read more

Preventing API drift with contract tests

Link –

In an older post on his blog Adam Wathan shared an interesting approach on how to prevent API drift between a test mock and an actual implementation.

One of the risks of writing your own test doubles is that the API of the double can fall out of sync with the API of the real implementation.

In this screencast I walk through an example that explains:

  • How interfaces can provide a false sense of security
  • Why tests make better contracts than interfaces
  • How to run multiple implementations against a shared set of contract tests

If you’ve ever had issues with API drift, try this approach and let me know how it works for you.

https://adamwathan.me/2016/02/01/preventing-api-drift-with-contract-tests/

Read more