gustasva / databuilder-php
Creating Spryker databuilders from php files for better autocompletion
1.1.0
2022-11-17 12:06 UTC
Requires
- php: ^7.4 || ^8.0
- ext-dom: *
Requires (Dev)
- fzaninotto/faker: ^1.9
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
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
- First we need to add PHP databuilders autoloading as Spryker autoloads only PyzTest directory for testing.
"autoload-dev": { "psr-4": { "_data\\": "tests/_data/",
- Next we create databuilders directory in _data directory.
├── ... ├── tests ├── _data ├── Builders
- Next we create Databuilders. Naming convention here is SomethingDatabuilder
namespace _data\Builders; use Databuilder\Databuilder; class SomethingDatabuilder extends Databuilder
- Define builder:
- First level of array is transfer name
- Second level of array is the place where you define databuilder properties
- For faker parameters or methods use
$this->faker->method()
- For literal values use
=value
- For faker parameters or methods use
- In getName() method we're defining the name of xml databuilder. If we return
name
from this method the xml databuilder will be namedname.databuilder.xml
Example displayed below:
return [ 'Something' => [ 'name' => $this->faker->word(), 'value' => '=thisIsSomeValue',
- Run databuilder generator:
vendor/bin/databuilder