Skip to content

Commit

Permalink
add sympony bundle (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronenlu authored Mar 27, 2024
1 parent dc161cc commit 29327e6
Show file tree
Hide file tree
Showing 13 changed files with 1,837 additions and 97 deletions.
48 changes: 45 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,52 @@ env "doctrine" {
}
```

#### As Symfony Bundle

If you are using a [Symfony](https://symfony.com/) project, you can use the provider as a Symfony [bundle](https://symfony.com/doc/current/bundles.html).

add the following bundle to your `config/bundles.php` file:

```diff
<?php

require "vendor/autoload.php";

return [
...
+ Ariga\AtlasDoctrineBundle::class => ['all' => true],
];

```

Then in your project directory, create a new file named `atlas.hcl` with the following contents:

```hcl
data "external_schema" "doctrine" {
program = [
"php",
"bin/console",
"atlas:dump-sql"
]
}
env "doctrine" {
src = data.external_schema.doctrine.url
dev = "docker://mysql/8/dev"
migration {
dir = "file://migrations"
}
format {
migrate {
diff = "{{ sql . \" \" }}"
}
}
}
```

#### As PHP Script

If you have multiple folders with Doctrine entities, or if you use a [Symfony](https://symfony.com/) project,
you might want to use the provider as a PHP script.
If you have multiple folders with Doctrine entities, you might want to use the provider as a PHP script.

create a new file named `atlas.php` with the following contents:

Expand All @@ -85,7 +127,7 @@ require "vendor/autoload.php";
require "vendor/ariga/atlas-provider-doctrine/src/LoadEntities.php";

// `DumpDDL` accepts an array of paths to your Doctrine entities and the database dialect(mysql | mariadb | postgres | sqlite | sqlserver).
print (DumpDDL(["./src/Entity"], "mysql"));
print (DumpDDL(["./path/to/first/entities", "./path/to/more/entities"], "mysql"));
```

Then in your project directory, create a new file named `atlas.hcl` with the following contents:
Expand Down
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
"require": {
"doctrine/orm": "^2.11.0|^3",
"doctrine/dbal": "^3.2",
"symfony/cache": "^5.4|^6|^7"
"symfony/cache": "^5.4|^6|^7",
"symfony/framework-bundle": "^5.4|^6|^7",
"doctrine/doctrine-bundle": "^2"
},
"require-dev": {
"phpunit/phpunit": "^11",
"squizlabs/php_codesniffer": "^3"
},
"autoload": {
"psr-4": {
"Ariga\\": "src/"
}
}
}
Loading

0 comments on commit 29327e6

Please sign in to comment.