Установка EasyAdmin на Symfony4

Я пытаюсь установить EasyAdminBundle при новой установке Symfony4 из этого документа https://symfony.com/doc/current/bundles/EasyAdminBundle/index.html.

Но у меня нет доступа к бэкэнду, я получаю 404 ...

Я просто набираю composer require easycorp/easyadmin-bundle и добавляю свою сущность (команду) в framework.yaml

framework:
    secret: '%env(APP_SECRET)%'
    #default_locale: en
    #csrf_protection: true
    #http_method_override: true

    # Enables session support. Note that the session will ONLY be started if you read or write from it.
    # Remove or comment this section to explicitly disable session support.
    session:
        handler_id: ~

    #esi: true
    #fragments: true
    php_errors:
        log: true

    cache:
        # Put the unique name of your app here: the prefix seed
        # is used to compute stable namespaces for cache keys.
        #prefix_seed: your_vendor_name/app_name

        # The app cache caches to the filesystem by default.
        # Other options include:

        # Redis
        #app: cache.adapter.redis
        #default_redis_provider: redis://localhost

        # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
        #app: cache.adapter.apcu

    easy_admin:
        entities:
            # change the following to the namespaces of your own entities
            - App\Entity\Command

Когда я проверяю свои маршруты с помощью php bin/console debug:router

-------------------------- -------- -------- ------ -----------------------------------
  Name                       Method   Scheme   Host   Path
 -------------------------- -------- -------- ------ -----------------------------------
  easyadmin                  ANY      ANY      ANY    /admin/
  admin                      ANY      ANY      ANY    /admin/
  _twig_error_test           ANY      ANY      ANY    /_error/{code}.{_format}
  _wdt                       ANY      ANY      ANY    /_wdt/{token}
  _profiler_home             ANY      ANY      ANY    /_profiler/
  _profiler_search           ANY      ANY      ANY    /_profiler/search
  _profiler_search_bar       ANY      ANY      ANY    /_profiler/search_bar
  _profiler_phpinfo          ANY      ANY      ANY    /_profiler/phpinfo
  _profiler_search_results   ANY      ANY      ANY    /_profiler/{token}/search/results
  _profiler_open_file        ANY      ANY      ANY    /_profiler/open
  _profiler                  ANY      ANY      ANY    /_profiler/{token}
  _profiler_router           ANY      ANY      ANY    /_profiler/{token}/router
  _profiler_exception        ANY      ANY      ANY    /_profiler/{token}/exception
  _profiler_exception_css    ANY      ANY      ANY    /_profiler/{token}/exception.css
 -------------------------- -------- -------- ------ -----------------------------------

Может ли кто-нибудь просветить меня? Ошибаться в первой строчке конфигурации так неприятно ...


person D. Schreier    schedule 25.05.2018    source источник


Ответы (2)


Что ж, без проблем установил easy-admin в один проект SF4. Попробуйте следующие шаги:

В config / routes / easy_admin.yaml:

easy_admin_bundle:
    resource: '@EasyAdminBundle/Controller/AdminController.php'
    prefix: /admin
    type: annotation

В config / packages / easy_admin.yaml напишите (и удалите из framework.yaml):

easy_admin:
    entities:
        - App\Entity\Command

При установке easy-admin в файле bundles.php должна быть такая строка:

EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],

С другой стороны, у вас есть синтаксическая ошибка yaml в вашем файле framework.yaml.

person M. Galardi    schedule 25.05.2018
comment
Извините, я не смог попробовать ваше решение, попробовал сегодня. Я просто заполняю config / packages / easy_admin.yaml вместо framework.yaml, и он работает, большое спасибо! - person D. Schreier; 27.05.2018

Может кому поможет. У меня такая же проблема в symfony 4, проверьте свой /public каталог, если он пропустил, .htaccess установите composer require symfony/apache-pack и попробуйте еще раз /admin

https://symfony.com/doc/current/setup/web_server_configuration.html

person Naskalin    schedule 09.02.2020