Scout APM is PHP application performance monitoring designed for developers. With tracing logic that ties issues back to the line of code causing them, you can pinpoint n+1 queries, memory leaks, and other abnormalities in real time so you can knock them out and get back to building a great product. Start your free 14-day trial today and get the performance insight you need in less than 4 minutes.

A package to fluently generate markup

Original – by Freek Van der Herten – 2 minute read is a vocabulary of microdata markup that aims to make it easer for search crawlers to understand what's on a webpage. The vocabulary is very extensive: here's the official list of things that can be described with This article on Tutsplus explains and structured data in depth. It's kinda impossible to know the whole vocabulary by heart. That's why we created a package called spatie/schema-org that can greatly help you generate markup.

Let's take a look at some microdata that uses the vocubulary. This an example (taken from the Google documentation on structured data) that describes an organization.

<script type="application/ld+json">
  "@context": "",
  "@type": "Organization",
  "url": "",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+1-401-555-1212",
    "email": ""

Here how that markup can be generated using our package:


In our package every type in the vocabulary is it's own class, helping IDEs understand which types exist. So when you need to build up some microdata, code completion can help you immensely. Here's a demo recorded in PhpStorm.

Converting the whole vocabulary manually to PHP classes would take a lot of time. That's why my colleague Sebastian built a generator that reads the specification and converts it to almost 600 separate classes. All classes contain helpful docblocks. When the vocubulary changes in the future, all we need to do is run the generator again to bring our package up to date.

Take a look at the readme on GitHub to learn all the options of our schema-org package. Be sure to also check these framework agnostic and Laravel packages our team has made in the past.

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

Follow me on Twitter. I regularly tweet out programming tips, and what I myself have learned in ongoing projects.

Every two weeks 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.