Oh Dear is the all-in-one monitoring tool for your entire website. We monitor uptime, SSL certificates, broken links, scheduled tasks and more. You'll get a notifications for us when something's wrong. All that paired with a developer friendly API and kick-ass documentation. O, and you'll also be able to create a public status page under a minute. Start monitoring using our free trial now.

Improving the performance of spatie/laravel-permission

Link –

Barry van Veen recently fixed an interesting performance issue at our permissions package.

Recently I was investigating the performance of an application we have built at SWIS. To my surprise, one of the most excellent costly methods was part of the spatie/laravel-permission package. After reading some more it was clearly a performance issue that could be improved upon. Since the solution was already clearly outlined it was quite easy to code it and submit a pull request.

https://barryvanveen.nl/blog/46-improving-the-performance-of-spatie-laravel-permission

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.

Automatically close stale issues and pull requests

Original – by Freek Van der Herten – 5 minute read

At Spatie we have over 180 public repositories. Some of our packages have become quite popular. We're very grateful that many of our users open up issues and PRs to ask questions, notify us of problems and try to solve those problems, ... Most of these issues and PRs are handled by our team. But…

Read more

Registering macro's in Laravel using a mixin

Link –

Rachid Laasri explains how to easily register multiple macros at once using the mixin function present on the Macroable trait.

Laravel Macros are a clean way to add pieces of functionality to classes you don’t own (core Laravel components) and re-use them in your projects. It was first introduced in the 4.2 version but it was only recently that I discovered the ability to define class-based macros. So, this is what this article is going to be about.

http://rachidlaasri.com/php/laravel/macro/2018/04/28/class-based-macros.html

Read more

The Future of Programming

Link –

Here's an amazing talk by "Uncle" Bob Martin where he gives an amazing overview of the history of programming and where he thinks it's headed.

How did our industry start, what paths did it take to get to where we are, and where is it going. What big problems did programmers encounter in the past? How were they solved? And how do those solutions impact our future? What mistakes have we made as a profession; and how are we going to correct them. In this talk, Uncle Bob describes the history of software, from it’s beginnings in 1948 up through the current day; and then beyond. By looking at our past trajectory, we try to plot out where our profession is headed, and what challenges we’ll face along the way.

Can't wait for his talk at this year's Laracon US.

Read more

Array destructuring in PHP

Link –

Frank de Jonge, author of the great EventSauce and Flysytem packages, wrote a blopost on how to use array destructuring in PHP.

In PHP 7.1 the array type has become even more powerful! An RFC was accepted (and implemented) to provide square bracket syntax for array destructuring assignment. This change to the language made it possible to extract values from array more easily.

https://blog.frankdejonge.nl/array-destructuring-in-php/

Not mentioned in Frank's excellent post is PHP's ability to destructure arrays in foreach loops.

$members = [
	[1, 'Seb'],
	[2, 'Alex'],
	[3, 'Brent'],
];

foreach ($members as [$id, $name]) {
   // do stuff with $id and $name
}

You can even specify in which variable a value of a specific key should go:

	$members = [
	['id' => 1, 'name'=> 'Seb', 'twitter' => '@sebdedeyne' ],
	['id' => 2, 'name'=> 'Alex', 'twitter' => '@alexvanderbist'],
	['id' => 3, 'name'=> 'Brent', 'twitter' => '@brendt_gd'],
];

foreach ($members as ['twitter' => $twitterHandle, 'name' => $firstName]) {
	// do stuff with $twitterHandle and $firstName
}

Very neat!

Read more

Make a clear distinction between different layers of validation

Link –

In an older, but still very interesting article, Mattias Verraes has some interesting thoughts on form, command and model validation.

Many of the frameworks I’ve worked with, promise to separate responsibilities with MVC. In practice, they end up coupling everything to everything. The forms are coupled to the models, and there’s a grand unified validation layer. This may be convenient at first, but it breaks down for larger systems, and creates headaches when having to support multiple clients. My approach is to clearly separate the validation for the form itself, from the Command validation and the model validation.

http://verraes.net/2015/02/form-command-model-validation/

Read more

What's new and changing in PHP 7.3

Link –

Ayesh Karunaratne made a good summary of the new stuff coming in PHP 7.3 which will be released by the end of the year.

This is a live document (until PHP 7.3 is released as generally available) on changes and new features to expect in PHP 7.3, with code examples, relevant RFCs, and the rationale behind them, in their chronological order.

https://ayesh.me/Upgrade-PHP-7.3

The trailing comma in function and method calls seems nice!

Read more

Combing legacy code string by string

Link –

Mattias Noback gives some good tips for refactoring legacy code.

"Combing" legacy code by untangling the strings is a good way to improve it and take back control over it. In existing legacy code, you should stop (re)using existing methods, making them ever more generic. Instead, you create new methods, and copy code from existing ones, allowing you to simplify this copied code and end up with a manageable class.

https://matthiasnoback.nl/2018/04/combing-legacy-code-string-by-string/

Read more

FP vs. OO

Link –

In a new post Uncle Bob explains that you shouldn't have to choose between functional programming and object orientation.

In this blog I will make the case that while OO and FP are orthogonal, they are not mutually exclusive. That a good functional program can (and should) be object oriented. And that a good object oriented program can (and should) be functional. But to accomplish this goal we are going to have to define our terms very carefully.

http://blog.cleancoder.com/uncle-bob/2018/04/13/FPvsOO.html

Read more

How CircleCI Improved Our Build Time

Link –

In a new post on his Medium Blog, Laravel.io maintainer Dries Vints wrote how he managed do drastically improved the build time of the popular forum.

CircleCI 2.0’s builds run with Docker which makes spinning up new instances super fast. If you use pre-built images which are customized to your needs, you don’t even need to do any provisioning during the build which saves you quite a bit time. Pulling various images and orchestrating them in a CircleCI 2.0 config allows for very rapid build times. If you add their new workflows to their mix you could easily enable parallelization and speed things up even more.

https://medium.com/laravelio/how-circleci-improved-our-build-time-8d5c40b8cc60

Read more

What PHP can be

Link –

My colleague Brent shares some interesting thoughts on which direction PHP could go forward.

Let's take, for example, the debate about strong types in PHP. A lot of people, including myself, would like a better type system. Strong types in PHP would definitely have an impact on my daily work. Not just strong types, I also want generics, better variance and variable types. Improvements to PHP's type system in general would have quite the impact on my programming life. So what's stopping us from reaching a solution?

https://www.stitcher.io/blog/what-php-can-be

Read more

How to use Laravel with Socket.IO

Link –

Most of the UI in my sideproject Oh Dear! is realtime. Because there is a vast amout of events being broadcasted using Pusher would be too expensive at this stage. So for our broadcasting we use socket.io and laravel-echo-server mentioned in the article below.

I had this challenge where I needed it to show a list of people who are currently viewing a specific URL in Laravel. So I started thinking. Part of me wanted to do a quick hack (luckily that’s not the strongest side of mine), whilst the other wanted to build something cool, reusable and long-lasting.

https://medium.com/@adnanxteam/how-to-use-laravel-with-socket-io-e7c7565cc19d

Read more

Creating custom stream filters in PHP

Link –

In this post we will see how to create a custom stream filter. Streams, first introduced in PHP 4.3, provide an abstration layer for file access. A number of different resources besides files – like network connections, compression protocols etc. can be regarded as “streams” of data which can be serially read and written to.

https://www.codediesel.com/php/creating-custom-stream-filters/

Read more