问题
Trying to make this command work while I'm getting the error :
php bin/console init:acl
Symfony init:acl command missing
I found this stack issue answering: Symfony init:acl command missing
Problem is, when I try to
composer require symfony/security-acl
I'm getting
[InvalidArgumentException] Could not find package symfony/security-acl in a version matching 4.3.*
Which seems to be normal as acl support were removed from Symfony 4 and even 3 I think. But still, it seems to be possible to use it according to the Symfony SonataAdminBundle.
I don't know how to fix this, thanks for your help
EDIT: ACL bundle install
$ composer require symfony/acl-bundle
Using version ^1.0 for symfony/acl-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.3.*"
Nothing to install or update
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [OK]
Executing script assets:install public [OK]
EDIT2:
chris@LAPTOP-JDR0HFFT MINGW64 ~/Desktop/projets/cav-php (acl_test)
$ git checkout -- .
chris@LAPTOP-JDR0HFFT MINGW64 ~/Desktop/projets/cav-php (acl_test)
$ git status
On branch acl_test
nothing to commit, working tree clean
chris@LAPTOP-JDR0HFFT MINGW64 ~/Desktop/projets/cav-php (acl_test)
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.3.*"
Package operations: 0 installs, 0 updates, 1 removal
**- Removing symfony/acl-bundle (v1.0.1)**
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [OK]
Executing script assets:install public [OK]
chris@LAPTOP-JDR0HFFT MINGW64 ~/Desktop/projets/cav-php (acl_test)
$ php bin/console cache:clear
// Clearing the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
chris@LAPTOP-JDR0HFFT MINGW64 ~/Desktop/projets/cav-php (acl_test)
$ composer require symfony/acl-bundle
Using version ^1.0 for symfony/acl-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.3.*"
Package operations: 1 install, 0 updates, 0 removals
**- Installing symfony/acl-bundle (v1.0.1): Loading from cache**
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (a8cc43db8a7843044a16dd2afc8ce860)
- Configuring symfony/acl-bundle (>=v1.0.1): From auto-generated recipe
Executing script cache:clear [OK]
Executing script assets:install public [OK]
Some files may have been created or updated to configure your new packages.
Please review, edit and commit them: these files are yours.
chris@LAPTOP-JDR0HFFT MINGW64 ~/Desktop/projets/cav-php (acl_test)
$ php bin/console cache:clear
// Clearing the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
chris@LAPTOP-JDR0HFFT MINGW64 ~/Desktop/projets/cav-php (acl_test)
$ php bin/console init:acl
**There are no commands defined in the "init" namespace.**
回答1:
The Sonata documentation isn't always fully up to date due to being maintained by a relatively small number of people.
You should still be able to use use https://github.com/symfony/acl-bundle according to https://symfony.com/doc/current/security/acl.html
composer require symfony/acl-bundle
Details for using that are here: https://github.com/symfony/acl-bundle/blob/master/src/Resources/doc/index.rst
回答2:
Ok, so looks like the command isn't
php bin/console init:acl
but
php bin/console acl:init
Which isn't said in the doc :(
来源:https://stackoverflow.com/questions/58113469/install-security-acl-inside-symfony-4