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.

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.

Open-sourcing our guidelines

Original – by Freek Van der Herten – 7 minute read

At Spatie we recently launched a new site: guidelines.spatie.be. It contains articles on how we go about setting things up at Spatie and a collection of styleguides. The source code of the site is available on GitHub. In this blogpost I'd like to share why and how we created our guidelines site. Why…

Read more

Use your Laravel named routes in JavaScript

Link –

Daniel Coulbourne, an engineer at Tighten Co and co-host of the amazing Twenty Percent Time podcast, recently released Ziggy, a tool to share your Laravel named routes with JavaScript.

Ziggy creates a Blade directive which you can include in your views. This will export a JavaScript object of your application's named routes, keyed by their names (aliases), as well as a global route() helper function which you can use to access your routes in your JavaScript.

https://github.com/tightenco/ziggy

Read more

Laravel/MySQL JSON documents faster lookup using generated columns

Link –

In an older post on his blog Mohamed Said demonstrates how you can leverage virtual columns to speed up queries on data stored as JSON.

Laravel 5.3 is shipped with built-in support for updating and querying JSON type database fields, the support currently fully covers MySQL 5.7 JSON type fields updates and lookups,

...

Let's see how we may create a generated column to store users favorite color for later indexing.

https://themsaid.com/laravel-mysql-json-colum-fast-lookup-20160709

Read more

Using global mixins in Vue.js

Original – by Freek Van der Herten – 2 minute read

Recently I needed to add some global functionality to nearly all Vue components in an app. My colleague Seb told me a good way to achieve this: global mixins. In this post I'd like share that knowledge. In Vue a mixin is some functionality bundled in a file that can be added to one or more Vue…

Read more

What's in our .babelrc?

Link –

Sebastian De Deyne, my colleague and all round wizard at Spatie, wrote a new blogpost on how we use Babel.

A lot has been going in in JavaScript the past few years. One of my favorite things has been the usage of babel, which allows us to write future JavaScript syntax today. The babel ecosystem has tons of plugins and configuration options, I'd like to elaborate on our usage at Spatie.

https://sebastiandedeyne.com/posts/2017/whats-in-our-babelrc

Read more

CSS Utility Classes and "Separation of Concerns"

Link –

In my day to day work I don't write any css at all, but I still very much enjoyed this blogpost by Adam Wathan where he shares some interesting things about how css should be structured and he makes the case for using utility classes to make visual tweaks.

When you think about the relationship between HTML and CSS in terms of "separation of concerns", it's very black and white.

You either have separation of concerns (good!), or you don't (bad!). This is not the right way to think about HTML and CSS. Instead, think about dependency direction.

...

One of the biggest benefits of using small, composable utilities is that every developer on your team is always choosing values from a fixed set of options.

https://adamwathan.me/css-utility-classes-and-separation-of-concerns/

Read more

The disadvantages of single page applications

Link –

Adam Silver lists a bunch of problems you need to solve if you opt to build a single page application.

Ironically, SPAs are harder to design and harder to build. And yet, they typically produce slow, disagreeable experiences for users. ... Javascript is never going to beat the browser at what it does best—browsing. We can still give users rich and enhanced experiences without cramming an entire site into one document.

We should let the browser manage the browsing experience, and spend our time solving real user problems.

https://adamsilver.io/articles/the-disadvantages-of-single-page-applications/

Read more

Precision Through Imprecision: Improving Time Objects

Link –

Ross Tuck is probably one of my favourite bloggers. He doesn't publish something often (his previous post is from 2015), but when he does it's very much worth your time.

The important takeaway here isn’t “value objects, yay, inline juggling, boo!” It’s that we were able to remove several classes of errors by reducing the precision of the DateTime we were handling. If we hadn’t done that, the value object would still be handling all of these edges cases and probably failing at some of them too.

Reducing the quality of data to get a correct answer might seem counter-intuitive but it’s actually a more realistic view of the system we’re trying to model. Our computers might run in picoseconds but our business (probably) doesn’t. Plus, the computer is probably lying anyways.

http://rosstuck.com/precision-through-imprecision-improving-time-objects

Read more

Calculating distance using MySQL

Link –

Logan Henson, a developer at Tighten, wrote a new post on the company blog about MySQL's cool ST_Distance_Sphere function.

On a client project recently, we had to make it easy to filter database query results based on the distance between a user and an entity in our database. It's easy to get overwhelmed in that context, worrying about the crazy amount of PHP calculations you're going to have to run. ... If you need to calculate this, you can actually get surprisingly far by just using MySQL!

https://tighten.co/blog/a-mysql-distance-function-you-should-know-about

Read more

Language features and code properties

Link –

Josh Justice gives some solid advice on how to pick the right language for your next projects.

So to ask the question “should I use an OO or FP language (or style)” is to skip several steps. I think a better series of questions are: First, what properties would be beneficial for your application to have: concurrency? Immutability? Encapsulation? There are a lot of things you won’t know about your application at first, but you can at least know if it will be a backend app, JavaScript browser app, or native mobile app; if it will be CPU-bound or IO-bound; and if it will process data inputted by humans or automatically generated by machines. All of those factors can influence which properties you need.

Once that’s decided, the next question is, in a given language, are those properties guaranteed, easy, difficult, or not realistically achievable?

http://codingitwrong.com/2017/07/27/language-features-and-code-properties.html

Read more

Why using Yoda conditions you should probably not be

Link –

Grégoire Paris wrote down his opinion on why he dislikes Yoda conditions.

So how do Yoda conditions work? Well it is basically a knee-jerk reaction you have to develop: whenever you write a condition, put the operand that cannot be assigned on the left. This should give you an error message if you make an assignment when you actually meant to make a comparison.

https://dev.to/greg0ire/why-using-yoda-conditions-you-should-probably-not

Personally, I'm not a big fan of Yoda conditions either. My feeling is the the cost of decreased readability is just too high for the small value that Yoda conditions bring to the table.

Read more

Cruddy by design

Link –

At this year's Laracon US Adam Wathan gave a talk titled "Cruddy By Design" on how to structure your controllers better. After the conference he published a new GitHub repo that contains the demo app he refactored on stage. The 4 main tips to improve your code come as PRs on the repo with a full description on why the change is valuable. Very cool stuff.

Using this convention as a "rule" is a good way to force yourself to keep your controllers from becoming bloated, and can often lead to learning interesting new things about your domain.

For the presentation, I put together a demo app called "CastHacker" that showcases podcasts about software development. It's not a "real" app by any means (lots of imaginary features, no tests, etc.); it's just enough code to demonstrate the concepts from the presentation. Feel free to clone it and play with it locally if you like though.

I've written up each refactoring I shared in the presentation as a detailed pull request.

https://github.com/adamwathan/laracon2017

Read more

How to write JavaScript-style test watchers in PHP

Link –

Christoper Pitt published another excellent piece over at Sitepoint. This time he describes how he built a watcher to automatically recompile his preprocessed code and rerun the tests.

In order to reduce the burden of invoking the transformation scripts, boilerplate projects have started to include scripts to automatically watch for file changes; and thereafter invoke these scripts.

These projects I’ve worked on have used a similar approach to re-run unit tests. When I change the JavaScript files, these files are transformed and the unit tests are re-run. This way, I can immediately see if I’ve broken anything.

https://www.sitepoint.com/write-javascript-style-test-watchers-php/

Read more

Diving into Laravel Horizon

Link –

Laravel Horizon is a kickass dashboard for viewing queued jobs. Co-creator Mohammed Said published two posts about the inner working of the tool. The first one on the Diving Laravel site highlights the overall configuration and how the master supervisor works.

Laravel Horizon is a queue manager that gives you full control over your queues, it provides means to configure how your jobs are processed, generate analytics, and perform different queue-related tasks from within a nice dashboard.

In this dive we're going to learn how Horizon boots up and handles processing jobs using different workers as well as how it collects useful metrics for you to have the full picture of how your application dispatches and runs jobs.

https://divinglaravel.com/horizon/before-the-dive

The second one, published on his own blog, shows how queued jobs can get tagged.

Laravel Horizon is shipped with many amazing features that help you understand what goes on with your queue workers, my personal favorite feature is the ability to tag jobs for further investigation.

https://themsaid.com/tagging-jobs-in-laravel-horizon-20170731

Read more

A recap of Laracon US 2017

Link –

Laracon US 2017 was an amazing conference. Sid published this excellent recap that contains many links to slides and related content.

I attended my first Laracon in person and I have to say I really enjoyed the experience — maybe more than I expected to. It was well organised and the talks were diverse, informative and actionable. Day 1 was all technical and mostly revolved around Laravel. Day 2 had a different mix of talks and the non-technical ones were thought-provoking and entertaining.

https://medium.com/koomai/laracon-2017-a-recap-and-links-galore-c233be2de670

Read more