【问题标题】:A plugin by the name "Album\Segment" was not found in the plugin manager在插件管理器中找不到名为“Album\Segment”的插件
【发布时间】:2017-04-24 15:03:12
【问题描述】:

我正在关注zend 3关于如何创建模块的教程(他们以专辑博客为例)creating a blog

但是我在创建模块时遇到了以下错误;

在插件管理器中找不到名为“Album\Segment”的插件
致命错误:未捕获的异常 Zend\ServiceManager\Exception\ServiceNotFoundException'
带有消息“在插件管理器中找不到名为“Album\Segment”的插件
Zend\Router\RoutePluginManager' 在 C:\xampp\htdocs\zf- tutorial\vendor\zendframework\zend-servicemanager\src\AbstractPluginManager.php:131`

似乎缺少一个插件。我不是唯一遇到这个问题的人。

lean438 raised the same problem at the zend forumn

【问题讨论】:

    标签: zend-framework


    【解决方案1】:

    将此行放入album模块目录下的module.config.php文件中:

    use Zend\Router\Http\Segment;
    

    【讨论】:

      【解决方案2】:

      只需将以下代码添加到模块/相册/config/module.config.php 中

      以下是整个代码文件

      namespace Album; 
      use Zend\Router\Http\Segment;
      use Zend\ServiceManager\Factory\InvokableFactory;
      return [
      'router' => [ 
          'routes' => [
              'album' => [
                  'type'    => Segment::class,
                  'options' => [
                      'route' => '/album[/:action[/:id]]',
                      'constraints' => [
                          'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                          'id'     => '[0-9]+',
                      ],
                      'defaults' => [
                          'controller' => Controller\AlbumController::class,
                          'action'     => 'index',
                      ],
                  ],
              ],
          ],
      ],
      
       'view_manager' => [
          'template_path_stack' => [
              'album' => __DIR__ . '/../view',
          ],
      ],
      ];
      

      【讨论】:

      • 这绝对解决了这个问题,但我想知道为什么?上一步明确删除了修复它所需的一行...use Zend\ServiceManager\Factory\InvokableFactory;
      【解决方案3】:

      只需添加 使用 Zend\Router\Http\Segment; 似乎不需要另一行来解决此问题。

      【讨论】:

        【解决方案4】:

        如果您使用的是 Laminas,请在相册模块目录中的 module.config.php 文件中使用以下代码

        使用 Laminas\Router\Http\Segment;

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-06-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-09-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多