【问题标题】:Installation EasyAdmin on Symfony4在 Symfony4 上安装 EasyAdmin
【发布时间】:2018-11-05 08:01:28
【问题描述】:

我尝试在此文档 https://symfony.com/doc/current/bundles/EasyAdminBundle/index.html 全新安装 Symfony4 时安装 EasyAdminBundle

但我无法访问后端,我得到 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
 -------------------------- -------- -------- ------ -----------------------------------

有人可以启发我吗? 第一行配置错了好郁闷...

【问题讨论】:

    标签: symfony configuration symfony4 easyadmin


    【解决方案1】:

    嗯,我在一个 SF4 项目中安装了 easy-admin 没有问题。试试这些步骤:

    在 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],
    

    另一方面,您的 framework.yaml 文件中有一些 yaml 语法错误。

    【讨论】:

    • 对不起,我无法尝试您的解决方案,我今天尝试了。我只需填写 config/packages/easy_admin.yaml 而不是 framework.yaml 就可以了,非常感谢!
    【解决方案2】:

    也许它可以帮助某人。我在 symfony 4 中遇到了同样的问题,检查你的 /public 目录,如果错过了 .htaccess 安装 composer require symfony/apache-pack 并重试 /admin

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

    【讨论】:

      猜你喜欢
      • 2018-09-03
      • 1970-01-01
      • 2018-06-26
      • 2020-12-14
      • 2018-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-25
      相关资源
      最近更新 更多