1. Go to this page and download the library: Download codebuds/generate-ts-bundle 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/ */
codebuds / generate-ts-bundle example snippets
namespace App\Test;
use App\Repository\RootRepository;
use App\Test\Sub1\SubEntity1;
use App\Test\Sub1\SubSub1\SubSubEntity1;
use App\Test\Sub1\SubSub1\SubSubEntity2;
use App\Test\Sub2\SubEntity2;
use DateTimeInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RootRepository::class)]
class Root
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne]
private ?SubSubEntity1 $subSubEntity1 = null;
#[ORM\OneToMany(mappedBy: 'root', targetEntity: SubSubEntity2::class)]
private Collection $subSubEntity2;
#[ORM\ManyToMany(targetEntity: SubEntity1::class, inversedBy: 'roots')]
private Collection $subEntity1;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
private ?SubEntity2 $subEntity2 = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?DateTimeInterface $datetime = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $text = null;
}
namespace App\Test\Enum;
enum NotBacked
{
case First;
case Second;
}
namespace App\Test\Enum;
enum BackedString: string
{
case String = 'String';
case Another = 'Something';
}
bash
Generate TypeScript Interfaces
==============================
0/3 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%
[INFO] /srv/app/assets/interfaces/Sub1/SubSub1/SubSubEntity2.ts generated for /srv/app/src/Entity/Sub1/SubSub1/SubSubEntity2.php
[INFO] /srv/app/assets/interfaces/Sub2/SubEntity2.ts generated for /srv/app/src/Entity/Sub2/SubEntity2.php
[INFO] /srv/app/assets/interfaces/Root.ts generated for /srv/app/src/Entity/Root.php
3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.