gustasva/databuilder-php

Creating Spryker databuilders from php files for better autocompletion

1.1.0 2022-11-17 12:06 UTC

This package is auto-updated.

Last update: 2024-04-17 15:02:12 UTC


README

Databuilder-php is a simple library that allows to define Spryker databuilders in PHP classes. This greatly improves readability and type hinting.

Installation

To install Databuilder-php, run the command below and you will get the latest version

composer require --dev gustasva/databuilder-php

Documentation

  1. First we need to add PHP databuilders autoloading as Spryker autoloads only PyzTest directory for testing.
"autoload-dev": {
        "psr-4": {
            "_data\\": "tests/_data/",
  1. Next we create databuilders directory in _data directory.
├── ...
├── tests
      ├── _data
            ├── Builders
  1. Next we create Databuilders. Naming convention here is SomethingDatabuilder
namespace _data\Builders;

use Databuilder\Databuilder;

class SomethingDatabuilder extends Databuilder
  1. Define builder:
    1. First level of array is transfer name
    2. Second level of array is the place where you define databuilder properties
      1. For faker parameters or methods use $this->faker->method()
      2. For literal values use =value
    3. In getName() method we're defining the name of xml databuilder. If we return name from this method the xml databuilder will be named name.databuilder.xml

Example displayed below:

return [
    'Something' => [
        'name' => $this->faker->word(),
        'value' => '=thisIsSomeValue',
  1. Run databuilder generator:
vendor/bin/databuilder