Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Content fixtures

113 sites Security covered Drupal 8–11
View on drupal.org

This module provides an API to programmatically generate and load content into your Drupal site, useful for development or presentation. It allows you to define custom content generators and run them with a single command, including options to purge existing content before loading new fixtures.

Introduction

Do you want to build a running website straight from your repository, but you realized that you have to get some dummy content from somewhere? Search no more. This module will give you an API to program your own content generators, that you will be able to run with one command, and fill your website with content required either for development or presentation.

This module is different from data_fixtures in that it aims to mimic as much as it's reasonably possible DoctrineFixturesBundle.

It was made with a workflow of programmatically building your website from scratch in mind, and tries to avoid any ambiguous states, that's why it deletes all content before loading any fixtures (don't worry, it will warn you :) ).

Great match with Docker, if you are looking for ultimate automation.

How to

This module has API very similar to DoctrineFixturesBundle, with some Drupal-specific differences/simplifications.

Basics

Minimally, your fixture class has to implement FixtureInterface, and be registered as a service tagged with a content_fixture tag.

Sharing objects between fixtures.

The easiest way of achieving this is to extend AbstractFixture class, that will provide you with some additional sugar - this abstract class implements SharedFixtureInterface that will give you a way of sharing created objects between fixtures.

Order of execution of fixtures

For this to work, you have to be able to decide on the order of execution of fixtures, and you can do this in two ways:

1. By implementing OrderedFixtureInterface - this will allow you to assign a value to each fixture, that will be used for ordering.
2. By implementing DependentFixtureInterface, that will allow you to declare dependencies between fixtures, and order of execution will be calculated by using this information.

Groups

You can also implement FixtureGroupInterface in your fixture, to assign it to some custom groups. It will allow you to run fixtures by groups they belong to. This way you can have different set of fixtures for presentation, different for development etc.

Execution

You need drush to run your fixtures. Module provides you with three commands:

  • content-fixtures:list
  • content-fixtures:load
  • content-fixtures:purge

See: drush help content-fixtures:list, drush help content-fixtures:load, and drush help content-fixtures:purge.

Other

If you like code quality of this module but you would rather like to have exportable hand-made content, then you may consider content_snapshot module.

Happy coding!

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Jan 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
3.2.0 Stable 8–11 Jan 17, 2025