https://github.com/itinance/doctrine-orm-conv
Doctrine-Converter from orm.yml-Files to @Annotations
https://github.com/itinance/doctrine-orm-conv
Last synced: 8 months ago
JSON representation
Doctrine-Converter from orm.yml-Files to @Annotations
- Host: GitHub
- URL: https://github.com/itinance/doctrine-orm-conv
- Owner: itinance
- Created: 2021-08-25T09:37:05.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-12-28T11:35:27.000Z (over 4 years ago)
- Last Synced: 2025-05-28T19:09:49.410Z (about 1 year ago)
- Language: TypeScript
- Size: 181 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
doctrine-orm-conv
======
[](https://oclif.io)
* [Usage](#usage)
* [Commands](#commands)
# Intro
## The story:
I had to convert a really big bunch of entities across many Symfony and Doctrine based projects from the `orm.yml`-Format into the `@Annotations` format and looked for an approach how to automate. Long story short: there was no proper way instead of migrating everything by myself.
Since the manual migration was very time-consuming and also very error-prone, I decided to automate this.
** DON'T JUDGE ME I AM FAMOUS **
This tool is just a one-shot-helper-tool. *No clean code*, *no tests*, just a single tool for *fire-and-forget*.
I decided to publish the tool in case someone else also has the need for it.
*Fun fact: although this tool helps to convert PHP code and was written for PHP projects, I ended up writing it with TypeScript as a NodeJS CLI.
The reason is quite funny: I started with PHP, but it was too time-consuming to find a suitable way to parse YML files without having to install any PECL extensions and without needing big frameworks that come with everything for that. NodeJS was the leaner and faster option here (although I am not a Node developer, as you might notice when looking at the code).*
# Usage
```sh-session
$ doctrine-orm-conv install -g doctrine-orm-conv
$ doctrine-orm-conv COMMAND
running command...
$ doctrine-orm-conv --help [COMMAND]
USAGE
$ doctrine-orm-conv COMMAND
...
```
# Commands
* [`doctrine-orm-conv hello [FILE]`](#doctrine-orm-conver-hello-file)
* [`doctrine-orm-conv help [COMMAND]`](#doctrine-orm-convicer-help-command)
## `doctrine-orm-conv hello [FILE]`
describe the command here
```
USAGE
$ doctrine-orm-conv hello [FILE]
OPTIONS
-c, --columns include columns
-h, --help show CLI help
-n, --name=name name to print
EXAMPLE
$ doctrine-orm-conv hello ./doctrine/customer.orm.yml
```
_See code: [src/commands/hello.ts](https://github.com/itinance/doctrine-orm-conv/blob/v0.0.0/src/commands/hello.ts)_
## `doctrine-orm-conv help [COMMAND]`
display help for doctrine-orm-conv
```
USAGE
$ doctrine-orm-conv help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
```
## Example Outout
Class Header:
```PHP
/*
* @ORM\Table(
* name="transaction",
* indexes={
* @ORM\Index(name="idx_state", columns={"state"}),
* @ORM\Index(name="idx_txid", columns={"txid"}),
* @ORM\Index(name="idx_created", columns={"created"}),
* @ORM\Index(name="idx_broadcasted", columns={"broadcasted"}),
* @ORM\Index(name="idx_finished", columns={"finished"}),
* @ORM\Index(name="idx_attempts", columns={"attempts"}),
* },
* uniqueConstraints={
* @ORM\UniqueConstraint(name="idx_hash", columns={"hash"}),
* },
* )
* */
```
Columns / Proprties:
```PHP
/** @ORM\Column( type="string", length=255, name="hash", nullable=false ) */
private string $hash ;
/** @ORM\Column( type="text", name="data", nullable=true ) */
private ?string $data ;
/**
* @ORM\ManyToOne(targetEntity="TransactionType")
* @ORM\JoinColumn(name="type_id", referencedColumnName="id", nullable=false)
*/
private TransactionType $type;
/**
* @ORM\ManyToOne(targetEntity="Customer")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", nullable=true)
*/
private ?Customer $customer;
```
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.2/src/commands/help.ts)_