The Mijingo Blog

Latest news, updates, free tutorials, and more from Mijingo.

How to Install Craft 3

by Ryan Irelan

Now that Craft 3 is available (as of this writing it is still in public beta), it’s time to learn how to install it.

There is one pre-requisite to installing Craft 3:

  • Install and configure Composer

What’s Composer? It’s a dependency management tool for PHP that helps manage software needed for individual projects (as opposed to traditional package managers that let you install software on your computer or server globally.)

Don’t have it installed yet? Watch my video install Composer.

After that you’re ready to install Craft 3. Here’s how:

 



What is the Element API in Craft CMS?

by Ryan Irelan

The Element API is a first-party plugin by Pixel & Tonic that allows you to create an API for sharing your data from Craft CMS. The responses are formatted as JSON (what is JSON?).

Using the plugin you can create an API that exposes Craft Elements via a JSON-formatted responses. The API only is read-only. You cannot write to Craft using this API and there’s no authentication built in. Be careful what you share!

The Element API is made up of the following pieces:

  • The plugin package itself
  • The elementapi.php file you have to create
  • The code in the file that defines the endpoints and the exposed data

To use the Element API plugin you need to meet these requirements:

  • Craft CMS installed and populated with data you want to expose via the API
  • PHP 5.4 or later (different than the current requirement for Craft CMS)

Installing the Element API plugin is like installing any other Craft plugin: drag the plugin file to the plugins directory and then install the plugin via the Craft Control Panel.

Watch the Free Lesson

How to Create an API with Craft CMS

by Ryan Irelan

In a recent lesson, I walked through how to use the Element API Plugin from Pixel & Tonic to create a JSON API that shares your website’s data (only that data which you choose, of course) for consumption by another website or service.

The free lesson is a fundamental approach to building a read-only API using the default ElementTypes (entry, category, asset, etc) in Craft. As long as you follow my steps, you can get an API up and running quickly.

Toward the end of the lesson, we also learn how to expose your Craft Commerce order data via an API so you can have an outside tool (like a Goole Spreadsheet or reporting tool) ingest it and use it create some sort of report.

Watch the Lesson

Learn Craft Commerce

by Ryan Irelan

It used to be that doing e-commerce work was something I would talk a client out of or offload to another company or a hosted platform. I didn’t want to touch it. At all. Too much risk. But this caused me to lose business and it usually meant a less-than-ideal solution for my clients or customers. Thankfully, the e-commerce solutions have gotten a lot better.

One those solutions is Craft Commerce, a first party plugin for the Craft CMS.

With tools like Craft Commerce, most web developers can put together a powerful and flexible e-commerce system for any website. And the store is hosted right on the website, not on some third party platform you can’t control.

In my full-length course Fundamentals of Craft Commerce I teach you everything you need to know to get started using Craft Commerce.

 

This new course follows the same proven learning process you expect from my Mijingo courses. By the end of the course you will be ready to implement your first e-commerce website!

Start the Course for Free

New Course: Flexible Twig Templates in Craft

by Ryan Irelan

A new course is now available for the Craft CMS series: Flexible Twig Templates in Craft.

In this course Ryan teaches the Flexible Template Stack, an approach put together by developer Anthony Colangelo. The Flexible Template Stack in Twig and Craft allows you to have reusable templates that can render content from any section of the site. This is a setup you can use over and over again on your Craft-powered projects.

Start the Course for Free

New Lesson: Installing Craft

by Ryan Irelan

I posted a new lesson on installing the Craft CMS. This lesson is an excerpt from my Up and Running with Craft course.

Watch the Lesson

New Course: Up and Running with Craft

by Ryan Irelan

Today I released a brand new course: Up and Running with Craft. This is a complete redo of its predecessor: Learning Craft.

The new course has the same goal: to help you learn the skills you need to start building websites with the Craft CMS. It does this over the course of nearly 4 hours and 21 videos.

Get Started Learning Craft

Craft Plugin Development Workbook

by Ryan Irelan

Ben Croker, the author of Craft Plugin Development, created a follow-up to his video course in the form of a workbook.

The digital workbook that builds on the plugin development course by gently guiding you along as you build another plugin on your own. Ben set up this workbook to build on and reinforce what you learned with him in the video course.

Let me take a moment to explain why a follow-up like this is important (for those of you who’d rather skip the explanation, you can go right to the workbook page).

When you learn something new, like plugin development for Craft, there are three stages that help the information you learn stay stored in your long term memory.

The first stage is watching and taking in the new material, like you would with a video course.

The second stage is watching again and engaging with the new material by, for example, coding along with the video and applying what’s being taught.

The final stage, and the one so many people skip, is applying the material you just learned again but on your own, using your own information and research to work around problems or challenges. It’s in this third and final step that real mastery starts and your brain stores the information in long term memory.

It’s the difference between understanding how Craft plugins are developed and knowing how to do it without hesitation.

Ben’s new workbook is the third step. He guides you a bit but the workbook nudges you toward solving problems on your own (with helpful links off to documentation) so you can loosen the training wheels and let them fall to the side.

The workbook is available now. Watch Ben’s introduction video to learn more.

 

Get the Workbook

Special Sale: Craft Starter Pack 50% off

by Ryan Irelan

This sale has ended. But you can still get both courses in the Starter Pack for 10% off!

In conjunction with my friends at Pixel & Tonic, I am celebrating the release of Craft 2.5 by temporarily marking down the price of the Craft CMS Starter Pack by 50%.

Yes, you heard that right. 50% off. Get started learning Craft for only $49.99.

I like to call this Starter Pack the one-two punch for learning Craft. Now you get more punch for your money.

Wait, maybe I should put it another way.

Regardless, the Craft Starter Pack is on sale starting now.

Here’s what you’ll get:

  • About 5 ½ hours of professional training videos
  • 21 separate videos
  • Code downloads so you can follow along
  • Streaming or download access to all videos (forever)
  • The knowledge you need to get started building websites with Craft.

Important Note: The next update to the Learning Craft course (the first course in the Starter Pack) will be free for everyone. What I am saying is you should get this now because it’s a helluva deal.

I want to save $50

New Lesson: Craft 2.5 Quick Look

by Ryan Irelan

Today the new version of Craft came out and I recorded a short lesson to run through the 3 major features of the latest release from Pixel & Tonic. There’s lots more to Craft 2.5 than what I covered but this is certainly the highlights, especially for content authors. Watch the Lesson

New Lesson: Creating a Contact Form in Craft

by Ryan Irelan

There’s a new free lesson available over in Lessons area that covers how to build a contact form in Craft.

In the lesson, we add the form to our Crafty Brewery sample site so customers can contact us with questions about our brew products and recipes.

We’ve been building the Crafty Brewery site over the course of several videos in the Learning Craft video course. If you want to learn more about Craft, I encourage you to check out that series of videos.

During this lesson, here’s what we’ll learn:

  • How to install and configure the Craft first party Contact Form plugin.
  • How to code the Contact form template
  • How to add a honeypot CAPTCHA to the form.

Watch the Free Lesson

Filters in Twig and Craft

by Ryan Irelan

Filters in Twig and Craft allow you to alter the contents of a variable.

This could be a variable you set right in the template or one that is part of the data output provided by Craft (like when retrieving and looping through section entries).

Filters are applied right in the output tag, like this:


{{ variable | filter }}

and separated using the pipe character.

Here’s an example where we want to title case the string that is assigned to the variable.


{% set page_title = "an important news story" %}
{{ page_title | title }}

When outputting the contents of the page_title variable, we are running it through the title filter in Twig. This filter adjusts the string to title case, so every word starts with a capital letter.

It will output:

An Important News Story

Another very practical filter that you might use frequently is trim. This filter strips out whitespace at the beginning and end of a string.


{% set page_title = " an important news story " %}
{{ page_title | trim }}

That will remove the whitespace at the beginning and end of the string.

You can also trim specific characters by specifying them in parentheses.


{{ page_title | trim('.') }}

The previous example outputs:

an important news story

which is missing the title casing we did before.

Let’s add in both filters together. We do that by chaining together them with pipes.


{{ page_title | trim | title }}

That outputs:

An Important News Story

Craft-specific Filters

Pixel & Tonic created some special filters just to use in Craft. These filters won’t be listed in the Twig documentation, and, similarly, the Craft documentation won’t list all of the Twig filters. This is a situation where you’l need to refer to two different sets of documentation.

Here are a couple Craft filters that I find interesting:

  • markdown - processes the string passed to it using the Markdown library.
  • group - allows you to group array items together based on a common property that you define. The Craft docs have a great example of sorting the entries returned from a Craft section by the year of the entry.

Ready to learn more about the Craft CMS?

My Craft Starter Pack is 4 ½ hours of premium learning that will get you started building sites with Craft for yourself, your company, or your clients.

Get Immediate Access

Learning Craft: New Video on Categories Added

by Ryan Irelan

Today I added a new video to the Learning Craft course. The new video covers how to use categories in Craft and it’s a free update for everyone that has the Learning Craft course in their library.

In the Matrix videos I added to the course earlier this year, I started using the Crafty Brewery sample site. The categories video adds to this sample site.

During the 21 minute video we add the ability to organize beer brewing recipes by beer style, using Craft categories to manage the styles.

If you already purchased the course the new video is waiting for you in your Course Library. If not, you can grab the course now or the Craft Starter Pack.

Using Categories in Craft CMS

by Ryan Irelan

Let’s say you have a website that displays recipes for beer brewing and you want to assign a category to each recipe to note the beer style (IPA, Stout, etc). Doing so will make it easier for visitors to sort through the recipes and find a recipe they would like to make.

Lucky for us this site exists. It’s called Crafty Brewery. If you followed the Craft video course then you recognize this from the Matrix videos.

Crafty Brewery Sample Site

If you’ve worked with other CMSes, Craft’s category setup is similar but, I think, a lot better.

During this tutorial we’re going to cover:

  • Creating a Category Group
  • Creating Category Fields
  • Displaying and linking to categories in Craft.entries loop
  • Creating a category page that lists all categories in a group

Let’s jump in.

The video version of the tutorial is available as part of the Learning Craft course. 3 ½ hours of learning over 11 videos. Download or stream right here on the site.

Preparations

While going through the tutorial, please follow along with your own copy of the Crafty Brewery website. All of the files you need are available for download.

Start with the download for Craft Categories Begin, which contains the starter templates and database. The download Craft Categories End contains the complete project as it would be if you completed this tutorial.

Don’t forget to import the database beforehand and adjusting the config file per your local environment.

The sample project does not include the Craft app directory. You’ll need to provide that yourself by downloading it from the Craft website.

If you don’t want to set up your own copy of Craft, you can spin up a free demo at the Craft website. You won’t be able to do everything in the tutorial using the Craft demo but will be able to follow along with the control panel sections.

Creating a Craft Category Group

First, we need a place to store our categories. We use a Category Group to do this. This is a similar setup as most other CMSes you’ve worked on.

Navigate to Settings > Categories in the Craft control panel. Create a new Category Group.

Creating a new Craft Category Group

In the Category Group setting, we give the group a name, a handle (how we can refer to the group in our template), and then define the URL format and the template we want to use.

For our category group we will give it the name of “Beer Styles” and the handle will be populated automatically for us based on that name. The name and handle should be descriptive of what the category group is. If you find your name is long and the handle is also long, you can manually trim the handle so you don’t have to type a Tolstoy novel into your template just to access the field.

Some important settings for our new Category Group:

  • We want to enable categories to have their own URLs via the checkbox. This is going to be key for us because we want the visitors to Crafty Brewery to be able to view recipes by style (e.g. show all Ale recipes or all Stout recipes). We know this is important because we have a solid understanding of how our target audience searches for beer recipes.

  • For the category URL formats we need to set the URL to exactly how we want that category page URL to structured when somebody clicks on a category link. For beer styles, I want the category URL structure to be recipes/styles/{slug}. If I was accessing the IPA category, this will give me the URL of http:/craft.dev/recipes/styles/ipa. That’s nice and clean and makes sense structurally.

  • For nested categories, we can leave the default behavior of using the parent URI, which is the one we just set, and then the slug of the category.

  • For the Category Template field we need to tell Craft which template to use when viewing the category page. Because this is a category that is for the brewing recipes, I’ll assume I want to place it in my recipes template directory (although I haven’t created that template yet). Let’s call it category.html.

We still need to create the category template and will do that in just a minute. But first let’s create the fields we need to store information about each category.

Creating Category Fields

Craft gives us the option to define our Field Layout (via the “Field Layout” tab at the top of the form) when creating the category group. However, we don’t yet have the fields we need created. Let’s do that first and then come back and set the Field Layout.

Next, navigate to Settings > Fields.

The category name (or the style name in this implementation) we will input using the Title field that we get automatically. But I’d like to also have a description of the beer style to display on the category page.

Let’s create a new field to store that style description.

We will save it in a group called Recipes (which already exists in my implementation of the site), and give it the name of Style Description (the handle is created automatically as styleDescription) and the Field Type of Plain Text.

Now that we have the field created we can then add it to the category group field layout.

Creating the Category Field Layout

Navigate back to the Category Group we created (Settings > Categories).

At the top of the Category Group form, tap/click the Field Layout tab.

Just like we do with Sections in Craft, we can create a Field Layout for a Category Group.

If we don’t define any fields for our Category Group Field Layout, the only field that will be available to us is the Title field. Just having the title field–where you store the name of the category–may be all you need sometimes. But we need to store a little extra information for our beer styles categories via the Style Description field.

Create a new tab under “Design Your Field Layout” and name it “Beer Style.” From the Recipes group below it, drag the Style Description field into the new layout tab.

It should look something like this:

Field Layout for Categories in Craft

At the top of the Control Panel is a new navigation items named Categories. Click on that navigation item and use the New Category button to create some categories for the group.

Alongside each category, you will see the URI for the category, which tells you exactly how someone can access this category on the front end of the website. In fact, you can even click on that URI and Craft will take you to the front-end of the site to preview how the category page will look.

But it won’t work yet! We first have to implement the template so we can see the category pages.

Adding Category Field to an Entry Form

Before we can output our new categories, we need to assign a Beer Style category to existing recipes. There are two steps to do this:

  1. Add a category field to the Recipes Field Layout.
  2. Assign a category to each Recipes entry.

Adding a Category Field

The great part about Craft versus other CMSes is that category fields aren’t special fields. They’re just like any other field, meaning you’re not tied to some pre-defined naming convention or paradigm that harkens back to a day when many of the CMSes were used just for blogging.

Navigate to the Fields area in Settings (Settings > Fields) and select the Recipes group.

Create a new field called “Style” with the Field Type of Categories.

The Categories field type in Craft gives us access to the categories one category group. We select that category group under Source (choose “Beer Styles”).

We’ll input 1 in to the Limit field blank (we want to restrict the field to only allowing one category to be selected) and give the select field a label of “Add Beer Style.”

Adding a category field in Craft

Save that new field and we’re almost there! Next step is to add the new field to the Recipes Field Layout.

Go to Setting > Sections and then tap/click on the Entry Types link at the far end of the row for the Recipes section. Next, click on the Recipes entry type (it should be the only one there). You can also use the upside down triangle to access the entry type directly.

Now we have access to the Field Layout for the Recipes section (and entry type). Drag the new Style field up into the Recipes tab in the layout. Save your changes.

Adding a Style field to assign a category

The final step is to go through each entry in the Recipes section and add a style. Once you’ve done that you are ready to move on to creating the templates and code to display our new categories.

Implementing the Template & Code

To add the categories to the front-end of our site the first thing we need to do is create the template Craft will use to display the category listing page.

In the case of our sample site Craft Brewery, we will have a page that will list all of the recipes for a particular style.

Back when we created the category group, we specified the template recipes/category.html as the location of the template we want Craft to use. Let’s create that now.

In your IDE or code editor, create a new file inside of the recipes directory (if you don’t have the recipes directory, create that, too) called category.html.

Paste in the starter template (get it here, called category-static.html) and let’s bring it to life with some Twig code.

Let’s review the overall structure before we move forward.

At the top of the template, we already have our layout tag, which inherits the base layout for this site. That’s going to give us everything we need to render a styled page.

Because we defined this URI as being a category page, Craft gives us some category data automatically. It’s available to using the category object and we can access its properties (the fields) easily, like this: {{ category.title }}.

We’ll first fill out the h2 for the title:


<h2>{{ category.title }}</h2>

And then add in the description:


<p>{{ category.styleDescription }}</p>

Now we need to populate the table with the brew recipes that are categorized with the style we’re viewing.

To do that we’ll use a for-loop to loop over entries returned by Craft. But in order to make sure we only have entries that are categorized under the current category page, we have to use the relatedTo() method and pass in the category.


{% for entry in craft.entries.section('recipes').relatedTo(category) %}

{% endfor %}

We are requesting from Craft the entries in the Recipes section but limiting it to those that are categorized as the style we’re viewing. We do that by passing category to the relatedTo() method.

Craft returns an array of entries that we then loop over and print out in our table.

We link to the entry using entry.url and print the title using entry.title. All standard stuff for returning entry data in Craft.


<tr>  
    <td><a href="{{ entry.url }}">{{ entry.title }}</a></td>  
    <td>{{ entry.originalBrewDate | date('F Y') }}</td>  
    <td>{%  for category in entry.style %}{{ category.title }} {% endfor %}</td>  
</tr>

Getting and printing the category (the style of brew) is a bit trickier. This is because categories in Craft are a collection (like an array), and even if we only have on category assigned, we have to iterate over that collection to get.

The table cell in the row has another for-loop. It loops over entry.style, which contains our collection of categories. We then print the category name out using style.title.


<tr>  
    <td><a href="{{ entry.url }}">{{ entry.title }}</a></td>  
    <td>{{ entry.originalBrewDate | date('F Y') }}</td>  
    <td>{% for style in entry.style %}{{ style.title }} {% endfor %}</td>  
</tr>

An alternative to this is to set entry.style to a variable and then iterate over that. There’s no real advantage there other than code clarity.


{% set styles = entry.style %}
<tr>  
    <td><a href="{{ entry.url }}">{{ entry.title }}</a></td>  
    <td>{{ entry.originalBrewDate | date('F Y') }}</td>  
    <td>{%  for style in styles %}{{ style.title }} {% endfor %}</td>  
</tr>

The Twig code is certainly now more readable but not any more functional that what we had before. It’s up to you on how to approach it for your projects.

Having the category listed on a category page is probably redundant and unnecessary but now you know how to output categories, right? Totally worth it.

Okay, I’m getting thirsty, so let’s finish up.

Linking to Category Pages

Speaking of outputting categories, let’s update the other recipe listing to include a link to the category, so visitors can access the category listing page.

We’ll do this on the Recipes page where we list out all of the brewing recipes: http://craft.dev/recipes

Navigate to the recipes/index.html template in your IDE or code editor.

In the template is the same table markup we just used in the recipes/category.html template. Add a table header column called “Style” and td for the style name right below the brew date cell. Use the same code as before but wrap it in an anchor tag and then link it up.


<tr>  
    <td><a href="{{ entry.url }}">{{ entry.title }}</a></td>  
    <td>{{ entry.originalBrewDate | date('F Y') }}</td>  
    <td>{%  for style in entry.style %}<a href="{{ style.url }}">{{ style.title }}</a>{% endfor %}</td>  
</tr>

We automatically get the URL to the category page via style.url. Add that as the value of the href property and we’re done!

Load the page http://craft.dev/recipes and you should see the style names linked up for each recipe. Click on the style and you’re brought to the Style (category) page.

Creating a Category Listing

What is missing from our beer styles implementation on Crafty Brewery is a page listing all of the styles, with links of to each style page.

This a practical implementation for visitors of the site. Many home brewers have an idea of which style beer they want to brew and need an easy way to drill down to a particular style.

The page will be similar to the others we created: a table with a list of styles and the descriptions. The new page will be located at http://craft.dev/recipes/styles. This will go nicely with our category page, which is located at: http://craft.dev/recipes/styles/lager.

Here are the steps needed to get that up and running:

  • Create a new template in the recipes template directory called styles.html. Paste in the starter template located at public/recipes.html.
  • Around the sample table row, add a for-loop that iterates over the categories returned from Craft and outputs the title and description.

{% for style in craft.categories.group('beerStyles') %}
    <tr>
        <td><a href="{{ style.url }}">{{ style.title }}</a></td>
        <td>{{ style.styleDescription }}</td>
    </tr>
{% endfor %}

To access the categories we use craft.categories.group() and pass in the group we want to retrieve. In this case it’s beerStyles, which is the handle of the Beer Styles category group we created earlier.

We iterate over the return object, and for each category returned we print out the URL, title, and description.

The result is a two-column table that lists the available styles and then a link (by clicking on the title) to access the individual style page, which is the category page we set up earlier.

With this final addition our category work for Crafty Brewery is complete.

Sit back, take a sip, and admire your work.

Get the Video of this Tutorial

A video version of this tutorial is available as part of the Learning Craft course.

It’s more than 3 hours of training over 11 videos. When you go through the course you learn everything you need to know to get started building websites with Craft–for yourself or for your clients. It’s an investment that will pay for itself over and over again.

Get Immediate Access

Ryan on ALA: On Air Panel

by Ryan Irelan

This coming Tuesday, August 25, 2015, I will be on the ALA: On Air panel all about content management systems.

CMSes help and hinder; they inspire rapture and incite table-flipping. I’m thrilled to moderate the next ALA: On Air event, where Karen McGrane, Jeff Eaton, and Ryan Irelan will join me to discuss what they love about working in CMSes (administrative UX!), what drives them to frustration (decoupling!), and what meaty problems (integration with design systems!) they hope to dive into next.

The panel will cover a handful of topics, including decoupling systems and headless CMSes.

If you work with CMSes at all, this is the must see panel. It’s free, online, and if I do my job, fun and informative.

Learn more about the event and then register to attend.

See you there!

Craft Plugins in Craft 3

by Ryan Irelan

Ben Croker, the author of Craft Plugin Development, recorded a free bonus update to his course. The update covers some initial considerations for making your plugin Craft 3 compatible.

First, a side note: Craft 3 is in developer preview and still a ways off. You don’t need to build or ship Craft 3 plugins just yet.

In the short video Ben walks through the changes he needs to make to the Entry Count plugin (that’s the plugin he builds in the course) so it will work with Craft 3.

If you already purchased the course then this bonus video will appear in your Course Library inside the Craft Plugin Development course.

But we also wanted to make the video available for everyone. Here it is:


Ready to develop your first Craft plugin?

Ben’s Craft Plugin Development course is 90+ minutes, broken up into several videos for easier learning and reference. Ben will get you from not knowing how to develop plugins to having your first plugin done and working!

Get Immediate Access

Learn Craft’s Matrix Field

by Ryan Irelan

The Learning Craft course now has new videos covering the Matrix field type.

I broke the new tutorial up into 7 short videos so you can easily reference back to just the topic you want (like coding templates for Matrix or using the switch tag).

If you already purchased the course then you’ll have the videos in your Course Library as part of the course.

Inspiration for Your First Craft Plugin

by Ryan Irelan

This is a part of an interview with Craft Plugin Development author Ben Croker. Ben had a lot of great stuff to share; this is the third part. Read Part 1 and Part 2.

Can you recommend a couple existing Craft plugins that someone could look at to get inspired as to what’s possible?

For a beautiful UI and wonderful use of dashboard widgets take a look at Dukt’s Analytics plugin.

For a feature packed maps plugin check out Smart Map by Double Secret Agency.

For a solution to simple payments in Craft check out Charge by SquareBit.

For a plugin that you can learn plugin development from, check out the free Entry Count plugin that accompanies the Craft Plugin Development video course.

You can find a full list of Craft plugins on StraightUpCraft.

Is anyone creating plugins to sell?

Yes, there are many commercial plugins already available, including two of my own. Here are just a few sites that are selling plugins:

Ready to develop your first Craft plugin?

Ben’s Craft Plugin Development course is 90+ minutes, broken up into several videos for easier learning and reference. Ben will get you from not knowing how to develop plugins to having your first plugin done and working!

Get Immediate Access

3 Things to Know About Craft Plugin Development

by Ryan Irelan

This is a part of an interview with Craft Plugin Development author Ben Croker. Ben had a lot of great stuff to share; this is the second part. Read Part 1 on getting started with Craft plugin development.

What are three things someone starting out with Craft plugin development should know?

Ben Croker: Plugins in Craft can be very, very simple. Literally, with a single file and several lines of code you can create a plugin that actually does something. Obviously things can get much more complex, but with a little knowledge you can certainly go a long way!!

Mastery is a journey. When I first started plugin development in Craft there were no docs. I ripped open the core and learned through persistence. And I am still learning. Come at this from a place of curiosity and experimentation and you will come a long way!!

You are not alone. There are many other people out there who are learning Craft plugin development, as well as many who are already building their own plugins. Get involved in the Craft Slack Group and use them, in my experience they are all very welcoming and happy to help.

Ready to develop your first Craft plugin?

Ben’s Craft Plugin Development course is 90+ minutes, broken up into several videos for easier learning and reference. Ben will get you from not knowing how to develop plugins to having your first plugin done and working!

Get Immediate Access

Getting Started with Craft Plugin Development with Ben Croker

by Ryan Irelan

This is a part of an interview with Craft Plugin Development author Ben Croker. Ben had a lot of great stuff to share; this is the first part.

What made you learn Craft plugin development?

Ben Croker: By nature I’m someone who likes to tinker with things and figure out how they work. That’s why I can often be found in my garage replacing parts on my motorcycle or tweaking my bicycle.

When Pixel & Tonic first released Craft (initially codenamed “Blocks”) I was very keen to take a look at the UI and the underlying code and I absolutely loved what I saw. It was obvious that they had put a huge amount of thought into building the CMS they wish they had had when they were developing their ExpressionEngine add-ons.

What resulted was a purely content focused CMS with a gorgeously minimalistic UI, as well as a framework for plugin development. Once I saw what this framework looked like and what I could do with it, I was hooked (excuse the pun).

Craft is built on the Yii framework. If I want to create a plugin, how much Yii do I need to know?

BC: You don’t need any knowledge or experience of Yii to create a plugin, although by developing plugins in Craft you will be inadvertently learning Yii’s coding conventions. As you start working with ActiveRecord and the database you’ll want to do some reading up on Yii’s docs, but it is certainly not a prerequisite.

How easy will it be to update plugins based on the changes in future versions of Craft?

BC: Craft 3 is bringing some changes to how plugins will work, however the update process for plugin developers is very simple and I am actually working on a bonus video that will cover this. There is already some documentation on how to do this as well as a recording of Brandon Kelly’s workshop at Peers 2015.

Thanks, Ben!

We’ll have two more installments of this interview coming in the next couple of days.

Ready to develop your first Craft plugin?

Ben’s Craft Plugin Development course is 90+ minutes, broken up into several videos for easier learning and reference. Ben will get you from not knowing how to develop Craft plugins to having your first plugin done and working!

Get Immediate Access

Next Page

What are our customers saying?


"Just purchased your Flexible Twig course. Love it!"
Tyler Morrison
"Been enjoying @mijingo 's Learning Craft video tutorials. Feeling like I've got a good basic understanding of #craftcms Very impressive"
Laura Montgomery
"I bought your Craft Starter Pack a year and a half ago. Worth every dollar. In fact, I would've paid twice as much for it, because you saved me so much time."
Timothy Ingram
"Ben's knowledge of Craft combined with his relaxed and informal teaching style makes for a great learning experience."
Steve Abraham
"Ben puts a lot of thought into his teaching approach and has the ability to explain complex concepts in a way that just make sense"
Gareth Redfern
"Ben is great at taking a complex subject and breaking it down in a way that you can wrap your mind around. I thought that plugin development was something I would never understand, and happily Ben proved me wrong!"
Jonathan Melville
"I really appreciate all the videos and writing you have done. Your work has given me a jump start on my front end development business."
Shan Ricciardi

Perfect for Small Teams & Companies


Mijingo's courses are perfect as the training curriculum for both small teams and entire companies.

Our courses are offered in Team Packs (up to 5 people) and Company Packs (up to 25 people), so you can make one simple, fast purchase to train your entire staff.

Prices are listed with each course. Need more than 25 or something custom?

Send Your Requirements
Team Pack2-5 People
Company Pack6-25 People
Custom Pack25+ People