efficiently/authority-controller

Ambiguous class resolution due to autoloading migrations

fnatte opened this issue · 6 comments

aa53d49#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780R39 added the migrations folder to the autoload in composer.json.

If the migrations are published as explained in the readme using

php artisan vendor:publish --provider="Efficiently\AuthorityController\AuthorityControllerServiceProvider" --tag="migrations"

then composer will contain multiple classmap entries for all migrations. This will result in warnings when running composer install:

Warning: Ambiguous class resolution, "CreateRolesTable" was found in both "$baseDir . '/database/migrations/2015_02_23_095033_create_roles_table.php" and "vendor/efficiently/authority-controller/src/migrations/2015_02_23_095033_create_roles_table.php", the first will be used.
Warning: Ambiguous class resolution, "CreateRoleUserTable" was found in both "$baseDir . '/database/migrations/2015_02_23_095152_create_role_user_table.php" and "vendor/efficiently/authority-controller/src/migrations/2015_02_23_095152_create_role_user_table.php", the first will be used.
Warning: Ambiguous class resolution, "CreatePermissionsTable" was found in both "$baseDir . '/database/migrations/2015_02_23_095107_create_permissions_table.php" and "vendor/efficiently/authority-controller/src/migrations/2015_02_23_095107_create_permissions_table.php", the first will be used.

Is there a reason the migrations folder was added to composer.json?

Hi @fnatte,

I need to dig into this autoloading stuff, for answering you.
Anyway, I plan to move some test related files from autoload option to autoload-dev one.

Cheers,
Tortue Torche

By the way, which version of authority-controller are you using: 2.0 or 2.1?

@fnatte I push a fix for both 2.0 or 2.1 versions of authority-controller.

So, can you update this package in your application and tell me if the error is gone, please?

For 2.0 version, ensure the package version constraint is like this one:

"efficiently/authority-controller": "2.0.x-dev",

Then run: composer update

Feel free to reopen this issue, if you still have some warnings in composer.

Have a good day,
Tortue Torche

@fnatte Can you confirm it's OK for you? Then I'll push a new tag release.

@tortuetorche The error is gone for me (tested with dev-master). Good job!