Skip to content

Commit

Permalink
Merge branch '3.4.x' into 4.0.x
Browse files Browse the repository at this point in the history
* 3.4.x:
  Update index.rst: Minor improvements at "Manual Tables" (#551)
  Add grammar constraint for phpcs.xml.dist (#572)
  Upgrade to PHPStan 2 (#565)
  • Loading branch information
derrabus committed Jan 12, 2025
2 parents f058784 + 7ad3df8 commit be118d8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"composer/semver": "^3.0",
"phpunit/phpunit": "^8.5|^9.5",
"doctrine/coding-standard": "^12",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-deprecation-rules": "^1",
"phpstan/phpstan-phpunit": "^1",
"phpstan/phpstan-strict-rules": "^1.1",
"phpstan/phpstan-symfony": "^1.3",
"phpstan/phpstan": "^1.4 || ^2",
"phpstan/phpstan-deprecation-rules": "^1 || ^2",
"phpstan/phpstan-phpunit": "^1 || ^2",
"phpstan/phpstan-strict-rules": "^1.1 || ^2",
"phpstan/phpstan-symfony": "^1.3 || ^2",
"doctrine/orm": "^2.6 || ^3",
"doctrine/persistence": "^2.0 || ^3 ",
"symfony/phpunit-bridge": "^6.3 || ^7",
Expand Down
37 changes: 23 additions & 14 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If you don't use `Symfony Flex`_, you must enable the bundle manually in the app
.. code-block:: php
// config/bundles.php
// in older Symfony apps, enable the bundle in app/AppKernel.php
return [
// ...
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Expand Down Expand Up @@ -245,11 +245,13 @@ Here is an example on how to inject the service container into your migrations:
.. code-block:: yaml
# config/packages/doctrine_migrations.yaml
doctrine_migrations:
services:
'Doctrine\Migrations\Version\MigrationFactory': 'App\Migrations\Factory\MigrationFactoryDecorator'
# config/services.yaml
services:
App\Migrations\Factory\MigrationFactoryDecorator:
decorates: 'doctrine.migrations.migrations_factory'
Expand Down Expand Up @@ -339,6 +341,7 @@ for Doctrine's ORM:
.. code-block:: php-annotations
// src/Entity/User.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
Expand All @@ -364,6 +367,7 @@ for Doctrine's ORM:
.. code-block:: yaml
# config/doctrine/User.orm.yaml
App\Entity\User:
type: entity
table: user
Expand All @@ -380,6 +384,7 @@ for Doctrine's ORM:
.. code-block:: xml
<!-- config/doctrine/User.orm.xml -->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
Expand Down Expand Up @@ -431,41 +436,45 @@ If you don't want to use this workflow and instead create your schema via
Otherwise Doctrine will try to run all migrations, which probably will not work.

Manual Tables
-------------
Manual Tables Not Managed by Doctrine
-------------------------------------

It is a common use case, that in addition to your generated database structure
based on your doctrine entities you might need custom tables. By default such
tables will be removed by the ``doctrine:migrations:diff`` command.
In addition to your generated database structure based on your doctrine entities you might need some custom tables.
By default such tables will be marked for removal by the ``doctrine:migrations:diff`` command.

If you follow a specific scheme you can configure doctrine/dbal to ignore those
tables. Let's say all custom tables will be prefixed by ``t_``. In this case you
just have to add the following configuration option to your doctrine configuration:
Here's how you can configure ``doctrine/dbal`` to ignore some tables:

.. configuration-block::

.. code-block:: yaml
# config/packages/doctrine.yaml
doctrine:
dbal:
schema_filter: ~^(?!t_)~
schema_filter: ~^(?!t_)~ # Ignore all tables prefixed by `t_`
.. code-block:: xml
<!-- config/packages/doctrine.xml -->
<!-- Ignore all tables prefixed by `t_` -->
<doctrine:dbal schema-filter="~^(?!t_)~" />
.. code-block:: php
// config/packages/doctrine.php
$container->loadFromExtension('doctrine', array(
'dbal' => array(
'schema_filter' => '~^(?!t_)~',
'dbal' => [
'schema_filter' => '~^(?!t_)~', // Ignore all tables prefixed by `t_`
// ...
),
],
// ...
));
This ignores the tables, and any named objects such as sequences, on the DBAL level and they will be ignored by the diff command.
This ignores the tables, and any named objects such as sequences, on the DBAL level and they will be ignored by the ``diff`` command.

Note that if you have multiple connections configured then the ``schema_filter`` configuration
will need to be placed per-connection.
Expand Down
5 changes: 4 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
<ruleset>
<ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
Expand Down

0 comments on commit be118d8

Please sign in to comment.