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.

Using non-breakable spaces in test method names

Link –

Mattieu Napoli shows how you can use non breaking spaces to make long test function names more readable.

Yes. This article is about using non-breakable spaces to name tests. And the fact that it’s awesome. And why you should use them too.

public function test a user can add a product to a wishlist() { // ... }

The code above is valid PHP code and works. Non-breaking spaces (aka   in HTML) look like spaces in editors but are actually interpreted like any other character by PHP.

http://mnapoli.fr/using-non-breakable-spaces-in-test-method-names/

It's cool that it works, but I'm not really a fan of this. I very much prefer how test runners like jest go about this by passing the name of the test to a function so you can use spaces.

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.

What is snapshot testing, and is it viable in PHP?

Link –

In a new blogpost at Sitepoint Christopher Pitt talks about snapshot testing. He first explains how snapshot testing can help test React components. Then he demonstrates how you can use our home grown package to use snapshot testing in PHP. Finally he shows pretty cool use cases for snapshot tests.

Ah-ha moments are beautiful and rare in programming. Every so often, we’re fortunate enough to discover some trick or facet of a system that forever changes how we think of it.

For me, that’s what snapshot testing is.

You probably write a lot of PHP code, but today I want to talk about something I learned in JavaScript. We’ll learn about what snapshot testing is and then see how it can help us write better PHP applications.

https://www.sitepoint.com/snapshot-testing-viable-php/

If you want know more about snapshot testing, check out this blogpost by my colleague Sebastian, or watch this video where I refactor some tests to use snapshots.

Read more

The broken windows theory or “Why some projects are just destined to suck”

Link –

In a new post on his blog, my favorite stalwart of the industry Frederick Vanbrabant, gives a explanation on why some projects turn into a big mess and how you can avoid it.

I truly believe that the broken window theory can be applied to software projects. In my personal experiences I’ve rarely seen a project start out as a total mess. If it ended up as a mess, it was gradually. I also believe that this is not necessary the fault of developers working on the project, think of it more as frogs in a pot with gradually increased temperature of water. One morning you just wake up and take a look at the project and realise that it has gotten really messy.

http://frederickvanbrabant.com/2017/06/12/broken-windows-theory.html

Read more

Performant Laravel

Link –

Chris Fideo, of Servers For Hackers and Shipping Docker, published a new free video serious on optimizing performance for Laravel apps. He shows how to use the built in artisan commands such as config:cache and route:cache,how to optimize queries, build up good indexes and how to add an object cache in a clean way.

There are some super common reasons your Laravel app might be slow. This course shows you how to avoid speed issues with simple changes you can implement immediately.

https://serversforhackers.com/laravel-perf

Chris is also a working on a paid course on how to scale Laravel apps. If you want to stay in the loop for that one, subscribe to his newsletter.

Read more

The status antipattern

Link –

In a new blogpost on vemv.net the author (I couldn't find his real name) argues against using a simple status field.

Dear programmer, do you ever use the name state for your variables? Like state = 42? “Hell no, that’s a terribly generic word. Better to use the domain-specific wording the variable refers to: is_invoiced, visit_count, shopping_cart, things like that.”

Sounds reasonable. But sometimes, you have a database column called status, and use it through your codebase, right? “Yes.”

Were you aware that status and state mean basically the same thing in English? “Uhm…”

https://blog.vemv.net/the-status-antipattern-479c26c7ddf7

Read more

How to build screens for users, permissions and roles in a Laravel app

Link –

One of our more popular packages is laravel-permission. It enables you to easily save roles and permissions in the database. It hooks into Laravel's native authorization capabilities. Allthough it's quite powerful, the package doesn't come with any UI out of the box.

If you do need a UI for this in your projects you're in luck. On Scotch.io Caleb Oki wrote down an extensive tutorial on how you can build screens to manage users, permissions and roles that use our package.

When building an application, we often need to set up an access control list (ACL). An ACL specifies the level of permission granted to a user of an application. For example a user John may have the permission to read and write to a resource while another user Smith may have the permission only to read the resource.

In this tutorial, I will teach you how to add access control to a Laravel app using laravel-permission package. For this tutorial we will build a simple blog application where users can be assigned different levels of permission.

https://scotch.io/tutorials/user-authorization-in-laravel-54-with-spatie-laravel-permission

Read more

What to expect from JavaScript ES2017

Link –

In a new blogpost André Neves, a React Native engineer at Big Human, introduces the new features that are coming with ES2017.

I think it is a fair assessment to say that a large portion of JavaScript developers seem to appreciate the new, the shiny, the bleeding-edge tools. Whether it is to completely embrace a new technology, or simply to test out a tool's functionality, we like to know what is out there to at least 'dip our toes in the water'.

If you're like me, keen on knowing about all of the new technology this incredible community has to offer, here is a breakdown of what ES2017 has in store.

https://medium.com/komenco/what-to-expect-from-javascript-es2017-the-async-edition-618e28819711

Read more

Make your app fly with PHP OPcache

Link –

Recently this button to optimize PHP's OPcache was added to Laravel Forge.

If you were wondering what PHP OPcache is all about and what pressing this button does with your application, read this article Olav van Schie wrote on the subject a while ago.

Every time you execute a PHP script, the script needs to be compiled to byte code. OPcache leverages a cache for this bytecode, so the next time the same script is requested, it doesn’t have to recompile it. This can save some precious execution time, and thus make your app faster (and maybe save some server costs).

https://medium.com/appstract/make-your-laravel-app-fly-with-php-opcache-9948db2a5f93

Read more

A straightforward Vue component to filter and sort tables

Original – by Freek Van der Herten – 3 minute read

Today we released our newest Vue component called vue-table-component. It aims to be a very easy to use component to make tables filterable and sortable. In this post I'd like to tell you all about it. Why creating yet another table component? Let's first touch upon why we created it. To make lists…

Read more

Classes, complexity, and functional programming

Link –

In this article Kent C. Dodds clearly explains what the downsides are of using Class in JavaScript.

Classes (and prototypes) have their place in JavaScript. But they’re an optimization. They don’t make your code simpler, they make it more complex. It’s better to narrow your focus on things that are not only simple to learn but simple to understand: functions and objects.

https://medium.com/@kentcdodds/classes-complexity-and-functional-programming-a8dd86903747

Read more

What the hell are generics and why would I want them in PHP?

Link –

Frederick Vanbrabant, developer at madewithlove and co-organiser of PHP Antwerp, explains on his blog what generics are.

So everyone is talking about this hip “new” kid on the block for PHP: Generics. The rfc is on the table and a lot of people are getting all excited about it, but you don’t fully see the excitement? Let’s explore what it’s all about!

http://frederickvanbrabant.com/2017/05/31/generics-in-php.html

Read more

Diving Laravel

Link –

Mohammed Said, Laravel employee number #1, recently announced that he published a new site where he shares stuff he learned while researching the Laravel code base. The site is called "Diving Laravel", which is kinda nice knowing that Mohammed is an incredible diver himself.

In this website I’m going to share notes on the internals of Laravel core, packages, as well as the technologies behind the different components. My goal is to help people understand how things work under the hood and also to be a reminder for me for when I need to look into something that I’ve already studied before.

https://divinglaravel.com/

Read more

How to Scan Fingerprints with Async PHP and React Native

Link –

In an amazing article on SitePoint, Christopher Pitt demonstrates how to create an async PHP server that can requests a fingerprint scan on the client side. He uses React Native, WebSocket, an async PHP server, PHP preprocessing, ... Really amazing stuff.

I’m going to describe the process of building custom multi-factor authentication for all transactions. I don’t want to do the usual (and boring on its own) SMS or push notification one-time-password stuff. I want to build a fingerprint scanner right into my phone.

In this tutorial, we’re going to look at how to set up a simple iOS app using React Native. We will also set up an asynchronous HTTP server, with a web socket connection to the app.

We will follow this up by adding fingerprint scanning capabilities to the app, and asking for these fingerprint scans from the HTTP server. Then we will build an endpoint through which GET requests can request a fingerprint scan and wait for one to occur.

https://www.sitepoint.com/scan-fingerprints-async-php-react-native/

Read more