PyroCMS 3: Creating Themes

Posted:
Updated:

The start of my journey with PryoCMS 3 was learning how to make custom themes. I originally learned how to develop with PyroCMS 2.2 where I did not need to use the command line to create themes; it was entirely file-based. PyroCMS 3 was entirely different!

PHP’s Artisan

Theme creation is done using Artisan in the command line. Ensure you are in your base PryoCMS 3 directory where a file called artisan should be visible.

Here is the base command:

php artisan

If you have a single-site installation of PryoCMS 3 then you can use the command:

php artisan make:addon {vendor}.theme.{slug}

and if you are using the Sites Module and want to create a theme for a particular site, the command looks like this:

php artisan make:addon {vendor}.theme.{slug} --app={reference}

Now, let’s break down the placeholders I have left in these commands.

If you need to find your site slug, navigate to /admin/sites and each entry should have a unique reference. You do not need to encase any of the variables in quote marks.

Putting it Together

Putting this together, to create a theme with slug test for a site with reference finnito using my vendor slug finnito we have:

php artisan make:addon finnito.theme.test --app=finnito

Debugging

If you get an error that looks something like this:

In Container.php line 752:  
  Class Finnito\FinnitoTheme\FinnitoTheme does not exist

you will need to run the following command:

composer dump-autoload

This gets Composer to optimise its autoload files and will fix this error.

Installing Themes

You can now install the theme by navigating to /admin/settings and setting the theme.

It was quite a journey for me to learn how to make a theme in PryoCMS 3 using Artisan. I was originally trying to create individual files and to replicate the file structure of a test theme, and this was a disaster. Now that I have internalised the usage of Artisan and Composer for this, it is very simple and speedy!

References