subsan/entity-generator

PHP entity generator

1.0.2 2018-11-06 10:41 UTC

This package is auto-updated.

Last update: 2024-09-15 17:31:28 UTC


README

Entity generator

Requirements

Installation

You can use Composer or simply Download the Release

Composer

The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

composer require subsan/entity-generator:"^1.0"

Finally, be sure to include the autoloader:

require_once '/path/to/your-project/vendor/autoload.php';

Download the Release

If you abhor using composer, you can download the package in its entirety. The Releases page lists all stable versions. Download any file with the name entity-generator-[RELEASE_NAME].zip for a package including this library and its dependencies.

Uncompress the zip file you download, and include the autoloader in your project:

require_once '/path/to/entity-generator/vendor/autoload.php';

Using

/vendor/bin/entityGenerator [YAML-file-path]

Basic Example

Example file vendor/subsan/entity-generator/example/GeneratorConfigField.yaml contains:

name: GeneratorConfigField
namespace: Subsan\EntityGenerator
fields:
  Name:
    type: string
    description: Name of field
  Type:
    type: string
    description: Type of field
  Description:
    type: string
    description: Description for field
    setNull: true

run in console:

vendor/bin/entityGenerator vendor/subsan/entity-generator/example/GeneratorConfigField.yaml > GeneratorConfigField.php

Generate file GeneratorConfigField.php contains:

<?php

namespace Subsan\EntityGenerator;

class GeneratorConfigField
{
    /**
     * @var string Name of field
     */
    private $name;

    /**
     * @var string Type of field
     */
    private $type;

    /**
     * @var string|null Description for field
     */
    private $description;

    public function getName(): string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getType(): string
    {
        return $this->type;
    }

    public function setType(string $type): self
    {
        $this->type = $type;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): self
    {
        $this->description = $description;

        return $this;
    }

}