Custom Entity Example for Drupal 9.3 to 10

A generator that writes a complete, working custom entity module for you, and a reference for developers learning how Drupal's entity layer fits together.

Kind
Module
Status
Release 1.0.1 for Drupal 9.3 to 10

About Custom Entity Example

A generator for custom Drupal entities. Rather than only demonstrating the Entity API, it writes a complete, working entity module for you (storage handler, forms, list builder, permissions and routes) from a single Drush command or a clone form in the admin UI. The generated module behaves like any core entity: its content appears under Administration → Content and its fields under Administration → Structure. WeebPal wrote it to skip the boilerplate at the start of a project, and as a reference for developers learning how Drupal's entity layer fits together.

Features

  • Generates a complete entity module
  • Drush command or clone form
  • Storage, forms, list builder, permissions, routes
  • Reference for the Entity API

Install it

Requires: Drupal 9.3 to 10

Install with Composer, then enable it:

composer require drupal/custom_entity_example
drush en custom_entity_example

Issues, releases and documentation live on Drupal.org. The current release runs on Drupal 9.3 to 10, and there is no Drupal 11 release yet. Porting a module to Drupal 11 or 12 is our Drupal module development work.

Setting it up

Requirements: Drupal core only.

  1. Enable the module at Administration → Extend.
  2. Generate a new entity module with Drush: drush cee-ge, passing the source module, the new entity id, the route base, the class names and the human-readable labels.
  3. Or use the clone form at Administration → Content → Custom entity example types → Clone form, and make sure the destination folder is writable.
  4. You get a complete module: the entity, its storage, forms, list builder, permissions and routes.
  5. Manage its content at Administration → Content and its fields at Administration → Structure, like any core entity.

Permission: administer custom_entity_example_type. Administer at /admin/content/custom-entity-example-types/clone-form.

Releases and Drupal compatibility

ReleaseRuns onNotes
1.0.1Drupal 9.3 to 10Current release
1.0.0Drupal 9 to 10

No Drupal 11 release yet.

Further reading

Need a change to this module?

The Drupal.org release runs on Drupal 9.3 to 10. Tell us what your site needs from it.