-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doctrine Migrations set up violates PSR-4 #343
Comments
To handle such case, I use the following "autoload": {
"psr-4": {
"App\\": "src/"
},
"exclude-from-classmap": [
"/src/Migrations/"
]
} |
That's done on purpose, because doctrine/migrations does not rely on autoloading at all either (and I think that having any migration class autoloaded before the library runs the command might even break its location of available migrations) |
The bundle documentation mentions nothing about changing the namespace. Without @fbourigault's changes this recipe won't work well out of the box. |
I do the same thing as @fbourigault, with this:
|
@jrobeson the recipe works fine out of the box, because doctrine/migrations does not expect migration classes to be autoloadable (quite the opposite) |
yep, it works. but it violates PSR by placing files in |
As a codebase that seems to follow so many formal guidelines and best practices, it seems bizarre that it's turning its eye to this issue. |
Closing as this is related to Doctrine migration, not Symfony. Nothing we can do here. |
The problem is that one will not be able to make migrations anymore... Better is to exclude it in the service.yaml so one doesn't get problems with tests etc either
add the "exclude" line and you're set and migrations still work and composer.json still calls for PSR-4 as it should. |
Just to make sure, this recipe and the use of migrations with their weird namespaces prevents any use of |
@adrianrudnik no it does not. the whole point of this is that migrations classes must not be autoloaded. the |
In a new flex project, i added migrations and generated a migration. The dir_name is set to
src/Migrations
, but the migrations are created with namespaceDoctrineMigrations
. The code style fixer wants to change that toApp\Migrations
. The migrate command finds the migration file, but then tries to instantiate the class with theDoctrineMigrations
namespace. The migration is also not runtime code but more of a configuration thing. I changed the configuration to place the migration in config/Migrations (without setting up autoloading) to make things work.I am not sure what the best solution is, but placing migrations in src/ but with a totally wrong namespace (no App prefix, folder Migrations vs namespace DoctrineMigrations) is counter-intuitive and leading to confusion.
The text was updated successfully, but these errors were encountered: