PHPackages                             giantpeach/blocks - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. giantpeach/blocks

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

giantpeach/blocks
=================

v2.0.2(11mo ago)01771MITPHP

Since Aug 17Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/Giant-Peach-Design/blocks)[ Packagist](https://packagist.org/packages/giantpeach/blocks)[ RSS](/packages/giantpeach-blocks/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (21)Used By (1)

giantpeach/blocks
=================

[](#giantpeachblocks)

[![Schnapps](https://camo.githubusercontent.com/f9e899e57e6cd376c96485d05f013c67919ee78827a9e9ccd3cfb6320b8c4250/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50656163682d5363686e617070732d2532336165613066643f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/f9e899e57e6cd376c96485d05f013c67919ee78827a9e9ccd3cfb6320b8c4250/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50656163682d5363686e617070732d2532336165613066643f7374796c653d666f722d7468652d6261646765)[![License](https://camo.githubusercontent.com/31e62e0eff03ce9ddfdf69d8476340d4f541990bfb152cb02a0f342965252997/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666f722d7468652d6261646765)](https://opensource.org/licenses/MIT)

2.0
---

[](#20)

2.0 introduces an improved Block class to make life simpler. As a result, it is not backwards compatible with blocks created using the 1.0 version of the package.

Updates include:

- Less boilerplate code
    - You no longer need a `__construct()` method in your blocks, instead you can use the `mount()` method for any property assignments you need to do
    - The `display()` method has been removed, block rendering is now all handled by the parent class
- `get_image_field('field_name')` helper method to return an image ID from an ACF field regardless of the ACF return value
- optional `$twigView` and `$phpView` properties to allow you to specify a different view file for your block

Using the `wp create-block` command will now scaffold a block using the 2.0 version of the package, but upgrading existing blocks will require some manual changes. Fortunately, the old Block class is still available under the `Giantpeach\Schnapps\Blocks\Compatability` namespace, so you don't need to migrate all your blocks at once.

To upgrade an existing block to 2.0 you will need to:

- move any existing `__construct()` and `display()` code into the `mount()` method
- remove the `display()` method
- update the block.json acf.renderCallback to point to the new block render function: `"Giantpeach\\Schnapps\\Theme\\Blocks\\Blocks::renderBlock"`

Description
-----------

[](#description)

This package aims to simplify block creation and usage in Wordpress. It is designed and included as part of the Peach Schnapps Framework.

It can be used independently, but is designed to work with the other packages in the framework.

Updates and changes to this package are dictated by the projects we work on and their needs, they may not necessarily be backwards compatible.

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

[](#installation)

`composer require giantpeach/blocks`

Usage
-----

[](#usage)

The package consists of a couple of classes that can be extended to create custom blocks.

The `Block` class provides a number of methods to simplify block creation and usage and hides away the complexity (block registration, template loading etc) so your extended class can focus on the block's functionality.

The `Blocks` class handles the actual registration of all your blocks and the traits they use. Typically, you would extend this class in your theme and add your blocks to it.

### Quickstart

[](#quickstart)

Once you've extended the `Blocks` class it registers a WP CLI command to create new blocks. You can use this to create a new block:

`wp giantpeach create-block MyBlock [--prose] [--spacing]`

This command will scaffold a new block within your theme, including the block controller class, the block json and the twig template.

Optionally you can specify whether the block should use the Prose or Spacing traits.

### Traits

[](#traits)

The package includes a number of traits that can be used to add functionality to your blocks. These are:

- `Prose` - adds a `prose` and creates a few ACF fields for use with the Block to modify `prose` styles
- `Spacing` - adds `spacing` classes to the block wrapper and creates a few ACF fields for use with the Block to modify `spacing` styles. The `spacing` classes are based on the Tailwind CSS spacing classes, and can be overwritten on the `Block` by setting the `$blockSpacing` array.

### Additional Classes

[](#additional-classes)

The package also include a few additional classes that can be helpful to use with your blocks:

- `Classes` - a class to handle the creation of classes for use with your blocks. This class is used to create classes for the `prose` and `spacing` traits, but can also be used to create classes for any other purpose.
- `Style` - a class to handle inline styles for use with your blocks. Style tags will automatically be added to the head of the document.

License
-------

[](#license)

This package is open source and is licensed under the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance51

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~39 days

Recently: every ~132 days

Total

19

Last Release

347d ago

Major Versions

v1.0.14 → v2.0.02024-09-17

v2.0.2 → 3.0.x-dev2025-07-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/e66b81ebd507f82992c477ab3e567933436d0a810a0886e6005b2e8b0fdf317a?d=identicon)[Giant Peach](/maintainers/Giant%20Peach)

---

Top Contributors

[![Bush95](https://avatars.githubusercontent.com/u/9116547?v=4)](https://github.com/Bush95 "Bush95 (4 commits)")[![tom-gurney](https://avatars.githubusercontent.com/u/6736496?v=4)](https://github.com/tom-gurney "tom-gurney (1 commits)")

### Embed Badge

![Health badge](/badges/giantpeach-blocks/health.svg)

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

###  Alternatives

[umanskyi31/opengraph

Created a new component for Yii2. The Open Graph component for your website

119.8k](/packages/umanskyi31-opengraph)

PHPackages © 2026

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