PHPackages                             toybox/theme - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. toybox/theme

ActiveProject[Framework](/categories/framework)

toybox/theme
============

Toybox is a simple block-based theme boilerplate for WordPress v6+ and PHP 8+.

v2.23.0(1y ago)067MITJavaScriptPHP ^8.2

Since Aug 11Pushed 2mo agoCompare

[ Source](https://github.com/maxweb-solutions/toybox)[ Packagist](https://packagist.org/packages/toybox/theme)[ RSS](/packages/toybox-theme/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (22)Used By (0)

Toybox
======

[](#toybox)

Toybox is a simple block-based theme boilerplate for WordPress v6+ and PHP 8+.

Features
--------

[](#features)

- Full support for Gutenberg.
- OOP-based theme engine.
- Support for deferred loading of images, background images, CSS and Javascript files.
- Simplified asset build system via Laravel Mix.
- Command line interface.

Installation
------------

[](#installation)

- Run the following command in your `wp-content/themes` directory to download and install the theme (and its dependencies):

```
composer create-project toybox/theme toybox --stability=dev --remove-vcs
```

- Run `npm i`.

Compiling Assets
----------------

[](#compiling-assets)

Toybox makes use of Laravel Mix for asset compilation.

To compile assets, run `npm run build`.

To compile a production build, run `npm run build:prod`. This will minify all output files and omit map files. (It will not remove existing map files by default).

To run the watcher script to recompile assets when their contents change, run `npm run watch`.

Deferred Loading
----------------

[](#deferred-loading)

Toybox includes built-in deferring systems to increase performance.

### Defer Images

[](#defer-images)

To defer load images, swap the `src` attribute on an `img` element with `data-lazy`:

```

```

### Defer Background Images

[](#defer-background-images)

To defer load background images, add the background image URL to the `data-lazy` attribute of any non-`img` element:

```

    Content

```

### Defer CSS

[](#defer-css)

To defer load CSS, add the stylesheet's URL to the `data-lazy-css` attribute of any element:

```

```

### Defer JS

[](#defer-js)

To defer load JS, add the script's URL to the `data-lazy-js` attribute of any element:

```

```

Helpers
-------

[](#helpers)

Toybox ships with some theme-wide helper functions:

### `mix(string $fileName, string|null $manifestPath = null)`

[](#mixstring-filename-stringnull-manifestpath--null)

The `mix()` function retrieves the path to a given CSS/JS file, relative to the base directory of the theme. This includes any cachebuster strings added by Mix.

### `uri(string $fileName)`

[](#uristring-filename)

The `uri()` function fetches the path to a given file, relative to the base directory of the theme.

### `slugify($title, $separator = '-')`

[](#slugifytitle-separator---)

The `slugify()` function retrieves a URL-friendly representation of a string.

### `singularize($value)`

[](#singularizevalue)

The `singularize()` function returns the singular form of a given word or phrase.

### `pluralize($value, $count)`

[](#pluralizevalue-count)

The `pluralize()` function returns the plural form of a given word or phrase, provided `$count` is not `1`.

### `matchCase($value, $comparison)`

[](#matchcasevalue-comparison)

The `matchCase()` function attempts to match the casing between two given strings.

### `field($fieldName, $postID)`

[](#fieldfieldname-postid)

A WordPress-friendly replacement for ACF's `get_field()` function.

### `repeater($fieldName, $postID, $subFields)`

[](#repeaterfieldname-postid-subfields)

A WordPress-friendly replacement for ACF's `get_field()` function that returns fields from a repeater.

### `group($fieldName, $postID, $subFields)`

[](#groupfieldname-postid-subfields)

A WordPress-friendly replacement for ACF's `get_field()` function that returns fields from a group.

### `image_url($imageID)`

[](#image_urlimageid)

A function to retrieve an attachment's URL from an attachment ID.

### `image_alt($imageID)`

[](#image_altimageid)

A function to retrieve an attachment's `alt` text from an attachment ID.

Command Line
------------

[](#command-line)

Toybox includes a command line interface. To access Toybox on the command line, enter the theme directory in your favourite terminal client and run the following:

```
php toybox
```

### Make Block

[](#make-block)

You can create a block with the `make:block` command.

```
php toybox make:block "My Block" --without-styles --without-js
```

Argument/OptionExampleRequiredDescriptionBlock Name"My Block"YesThe name of your block.--without-stylesNoSkip creating the block style and directory.--without-jsNoSkip creating the block script and directory.This will create your block under the `/blocks` directory.

Blocks now generate in the Blocks v2 format. Metadata is now added into a block.json file that is included as part of the generated block. [You can see the official WordPress documentation for this file here](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/). [Additional information about the ACF implementation can be found here](https://www.advancedcustomfields.com/resources/acf-blocks-with-block-json/).

### Make Shortcode

[](#make-shortcode)

You can create a shortcode with the `make:shortcode` command.

```
php toybox make:shortcode "My Shortcode" --with-styles --with-js
```

Argument/OptionExampleRequiredDescriptionShortcode Name"My Shortcode"YesThe name of your shortcode.--with-stylesNoCreates the shortcode style (and directory if required).--with-jsNoCreates the shortcode script (and directory if required).This will create your shortcode under the `/shortcodes` directory.

### Make Post Type

[](#make-post-type)

You can create a post type with the `make:post-type` command.

```
php toybox make:post-type "Services"
```

Argument/OptionExampleRequiredDescriptionPost Type Name"My Post Type"YesThe name of your post type.This will create your post type under the `/post-types

### WebP Conversion

[](#webp-conversion)

You can convert a single image, or a path containing images to WebP format with the `images:convert` command.

```
php toybox images:convert -p images/image.png
```

```
php toybox images:convert -p images
```

Note that this command will not overwrite the original image - it will create a new image from the original source and append the ".webp" extension to the end.

It will also only convert the following file types when processing a directory: .jpg, .jpeg, .png.

Argument/OptionExampleRequiredDescriptionPath"images"YesThe path to convert. You can either use a path relative to the theme root, or an absolute path. Additionally, if the path given is a directory, the command will recurse over all files and directories inside the given path and convert all supported filetypes to WebP.Quality75NoThe quality to use during conversion, 0-100. The closer to 100, the better quality (and larger filesize) the output will be.### Export Block

[](#export-block)

The `export:block` command exports any ACF field groups associated with a given block into the block's own `acf-json` folder. You must run this command if you are making the block redistributable.

```
php toybox export:block "My Block"
```

Argument/OptionExampleRequiredDescriptionBlock Name"My Block"YesThe name of the block to export settings for.--domain=mysite.commysite.comNo (Yes when on multisite WordPress)When using Toybox on a WordPress multisite, you must tell WordPress which domain you are using so that it can connect to the correct database.--fieldgroup / -g "Field Group Name""My Block Settings"No (prompts for the field group if not provided)The name of the field group to export.--location / -lNoExport all field groups that have been assigned to the block.Snippets
--------

[](#snippets)

Toybox ships with a built-in snippets feature. The idea of snippets is they are individual pieces of code that you want to load as part of the theme that don't need to be built into the theme core. As you may want these on different hooks or filters, they don't load on a particlar hook, and instead load during the theme's `boot()` method.

To create a snippet, put your code into a PHP file in the `snippets` directory. Be sure to use WordPress' `add_action` or `add_filter` (or another such function) with an appropriate priority to avoid adding unnecessary overhead to every page load.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance68

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~49 days

Recently: every ~123 days

Total

21

Last Release

388d ago

Major Versions

v1.1.1 → v2.0.02023-05-15

PHP version history (3 changes)v1.0.1PHP ^8.0

v2.0.0PHP ^8.1

v2.23.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b8693ec4ec2b6ea80c111befbf872c80a8c9ac2550c9ea43c661c38e64880e3?d=identicon)[mxrxdxn](/maintainers/mxrxdxn)

![](https://www.gravatar.com/avatar/3aa2d5eabe1f8e815969f9b49fb0f62bf977374524c8cb797066f85a7d2f9811?d=identicon)[maxweb](/maintainers/maxweb)

---

Top Contributors

[![mxrxdxn](https://avatars.githubusercontent.com/u/23401787?v=4)](https://github.com/mxrxdxn "mxrxdxn (6 commits)")

### Embed Badge

![Health badge](/badges/toybox-theme/health.svg)

```
[![Health](https://phpackages.com/badges/toybox-theme/health.svg)](https://phpackages.com/packages/toybox-theme)
```

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
