1. Go to this page and download the library: Download milpa/devtools library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
milpa / devtools example snippets
use Milpa\DevTools\Make\GenerationContext;
use Milpa\DevTools\Make\Generators\EntityGenerator;
$context = new GenerationContext(
plugin: 'InventoryPlugin',
name: 'Product',
options: ['fields' => 'name:string:120,price:decimal:10,2,active:bool'],
root: '/path/to/host-app',
);
$result = (new EntityGenerator())->generate($context);
echo $result->files[0]->path;
// -> /path/to/host-app/plugins/InventoryPlugin/Entities/Product.php
echo $result->files[0]->contents;
declare(strict_types=1);
namespace Milpa\Plugins\InventoryPlugin\Entities;
use Doctrine\ORM\Mapping as ORM;
use Milpa\Support\UuidGenerator;
#[ORM\Entity]
#[ORM\Table(name: 'products')]
class Product
{
use UuidGenerator;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 36, unique: true)]
private string $uuid;
#[ORM\Column(type: 'string', length: 120)]
private string $name;
#[ORM\Column(type: 'decimal', precision: 10, scale: 2)]
private string $price;
#[ORM\Column(type: 'boolean')]
private bool $active;
public function __construct()
{
$this->uuid = self::generateUuid();
}
// ... getId()/getUuid(), plus a get*()/set*() pair per field (elided here — see the
// generated file above for the full, real output).
}