💾 Archived View for finn.lesueur.nz › posts › pyrocms-creating-themes › index.gmi captured on 2023-07-22 at 16:45:10. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-06-14)

-=-=-=-=-=-=-

Finn Le Sueur

Welcome to my Gemini capsule. I am a Science and Physics teacher from Christchurch, New Zealand who writes code in his spare time, but would really rather be outside doing almost any type of sport! 🏔 🏃‍♂️ 🎿 🛶 🚴‍♂️ 🧗 🧘‍♂️

Home

PyroCMS 3: Creating Themes

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

PHP's [Artisan][artisan]

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

Here is the base command:

`bash

php artisan

`

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

`bash

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:

`bash

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:

`bash

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

`

Debugging

If you get an error that looks something like this:

`php

In Container.php line 752:

Class Finnito\FinnitoTheme\FinnitoTheme does not exist

`

you will need to run the following command:

`bash

composer dump-autoload

`

This gets [Composer][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][pyro-3] using [Artisan][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][artisan] and [Composer][composer] for this, it is very simple and speedy!

[pyro-3]: https://pyrocms.com/

[pyro-2]: https://github.com/pyrocms/pyrocms/tree/2.2/master

[artisan]: https://pyrocms.com/help/developer-tools/cheatsheets/artisan-commands

[composer]: https://getcomposer.org/doc/01-basic-usage.md

References

- PryoCMS 3: <https://pyrocms.com/>

- PyroCMS 2: <https://github.com/pyrocms/pyrocms/tree/2.2/master>

- Artisan: <https://pyrocms.com/help/developer-tools/cheatsheets/artisan-commands>

- Composer: <https://getcomposer.org/doc/01-basic-usage.md>

---------------

View this page over HTTPS.