Highlighting code blocks with league/commonmark

sebastiandedeyne.com

My colleague Seb wrote a cool package that adds tags and classes to code blocks in html, so they can be highlighted with css.

I created a spatie/commonmark-highlighter package that supports higlighting with CommonMark. After you register two custom renderers, all code blocks will receive a set of tags and classes, so they're already prepped to be highlighted by CSS when your content arrives in the browser.

Read more [sebastiandedeyne.com]

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Giving collections a voice

timacdonald.me

Tim MacDonald demonstrates how you can add logic to a custom collection.

Laravel collections have become an essential part of my codebases and I couldn't imagine working without them. I have found giving collections the voice of the problem domain makes for a much nicer API when compared to the generic collection methods.

Read more [timacdonald.me]

? Four years of murze.be ?

4 years ago I started this blog as a tool to share interesting blogposts I found around the web. On each anniversary of my blog I published some interesting stats on the blog. This year is no different.

Between November 2017 and november 2018 this blog served 728 243 pages, a good increase compared to the 591 113 pageview from the previous period. There are 1 217 published posts, of which 195 I've written myself. The others ones are links to other blogs.

Last year in November I moved this blog from WordPress to a custom made Laravel app. A few months ago I removed the handcrafted admin section in favor of Laravel Nova. I'm really glad that I now have full control over my blog and not tied to WordPress anymore. I also opensourced the Laravel app. You can find the source code in this repo on GitHub.

These were the ten most visited posts of the past 12 months:

  1. My current setup (2018 edition)
  2. How to upgrade from PHP 7.1 to 7.2 on MacOS
  3. Introducing our Nova packages
  4. Handling CORS in a Laravel application
  5. laravel-medialibrary v7 has been released
  6. Breaking Laravel's firstOrCreate using race conditions
  7. When empty is not empty
  8. Doing less
  9. A better way to register routes in Laravel
  10. Using Content Security Policy headers in a Laravel app

I do hope you still enjoy reading this blog!

Read more

Dynamic relationships in Laravel using subqueries

reinink.ca

Jonathan Reininck wrote a cool article on how you can create dynamic releationships. This technique will keep the number of queries and the memory used to a minimum.

I hope that gives you a good overview of how you can use subqueries to create dynamic relationships in Laravel. This is a powerful technique that allows you to push more work into the database layer of your app. This can have a huge impact on performance by allowing you to drastically reduce the number of database queries executed and overall memory used.

Read more [reinink.ca]

Configuring PhpStorms code generation

by Freek Van der Herten – 4 minute read

I've been using PhpStorm for quite some time now, but never took the effort to fix a few minor annoyances I had with it. Getting rid of the default comment for new PHP files First up, when creating a new PHP file or class you PhpStorm will add this comment block like this by default: /** * Created…

Read more

Failing gracefully on stage

by Freek Van der Herten – 1 minute read

Here's a video of Surma having technical problems while presenting his State of Houdini talk. Luckily Jake Archibald and others "help" him out ? No matter how well you prepare a talk, you can always have technical difficulties. If you handle the failure gracefully, the public won't mind.…

Read more

A better way to register routes in Laravel

by Freek Van der Herten – 3 minute read

Let's take a look at how you can define routes to controllers in Laravel. By default you can do it like this: Route::get('my-route', 'MyController@index'); This will look for the MyController class in the App\Http\Controllers namespace. This default namespace is set up in Laravel's…

Read more

How PHP conferences can be improved

by Freek Van der Herten – 10 minute read

The past few years I visited and spoke at a lot of PHP conferences. PHP Benelux, Laracon EU and US, PHP UK Conference, PHP World are only a few of the conferences I thoroughly enjoyed. Visiting those conferences can be recommended to anyone interested in PHP. Regardless of which level you're at…

Read more

Loading Eloquent relationship counts

timacdonald.me

There are three ways of loading relationships in Laravel. Tim MacDonald, a freelance dev based in Sydney, explains them all.

It is often useful to show the number of related models a given instance has, but not actually need any specific information about the related models, just how many exist. In this scenario you do not want to load all of the related models into memory to count them, we want our database to do the heavy lifting for us. Laravel offers a number of ways to retrieve relationship counts.

Read more [timacdonald.me]