这是我的Module.php:
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonModule for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Users;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\Mvc\ModuleRouteListener;
class Module implements AutoloaderProviderInterface
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
// if we're in a namespace deeper than one level we need to fix the \ in the path
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function onBootstrap($e)
{
// You may not need to do this if you're doing it elsewhere in your
// application
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
}
这是我的module.config.php:
<?php
return array(
'controllers' => array(
'invokables' => array(
'Users\Controller\Index' => 'Users\Controller\IndexController',
),
),
'router' => array(
'routes' => array(
'users' => array(
'type' => 'Literal',
'options' => array(
// Change this to something specific to your module
'route' => '/users',
'defaults' => array(
// Change this value to reflect the namespace in which
// the controllers for your module are found
'__NAMESPACE__' => 'Users\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
// This route is a sane default when developing a module;
// as you solidify the routes for your module, however,
// you may want to remove it and replace it with more
// specific routes.
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'users' => __DIR__ . '/../view',
),
),
);
但是当我尝试查看索引页面时,我得到了这个:
(!)致命错误:未捕获 Zend \ ModuleManager \ Exception \ RuntimeException:模块(用户)可以 没有被初始化。在 /var/www/html/communicationapp/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php 在线195
(!)Zend \ ModuleManager \ Exception \ RuntimeException:无法初始化模块(用户)。在/var/www/html/communicationapp/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php 在第195行
任何人都知道这段代码有什么问题吗?
答案 0 :(得分:0)
要检查的几件事情:
let arr = [1,1,1,2,2,3,3,4,4,4,5,5,6,7,8,16]
const group = (arr, groups) => {
// if input array `.length` is `0`
// or `groups` is less than 2, throw `TypeError`
if (!arr.length) {
throw new TypeError("input array does not have valid `.length`")
}
// declare resulting array `res`,
// `singles` array to group values of arrays having `.length` of `1`
// to single array
// `s` array of groups of same element from input array
// `len` whole number to `.splice()` `s` into `groups` by
// `t` array of single elements from `s`, if they exist
let [res, singles] = [[], []];
const [s
, len = Math.floor(s.length / groups -1)
, t = s.filter(el => el.length === 1)] = [
[...new Set(arr)].map(el => arr.filter(n => n === el))
];
if (t.length) {
for (const g of t) {
// collect our single element arrays to `singles` array
singles = [...singles, ...g];
// remove singles element arrays from `s`
s.splice(s.indexOf(g), 1);
}
// `.push()` `singles` to `s`
s.push(singles);
}
do {
// `.splice()` our groups
const curr = s.splice(0, len);
// `.push()` current group to `res`
if (res.length < groups) {
res.push([])
};
// push elements of arrays to current array in `res`
for (const g of curr) {
res[res.length - 1] = [...res[res.length - 1], ...g]
}
} while (s.length);
// return result `res` array
return res;
}
let g2 = group(arr, 2);
let g3 = group(arr, 3);
let g4 = group(arr, 4);
console.log(g2, g3, g4);
- 确切的情况。Module.php
位于Module.php
(即不在module/Users
中)答案 1 :(得分:0)
我使用了php的内部服务器,我没有启用xdebug它得到了这个:
127.0.0.1:48908 [500]:/ public / - 未捕获的Zend \ ModuleManager \ Listener \ Exception \ InvalidArgumentException:要合并的配置必须是数组,实现Traversable接口,或者是Zend \ Config \ Config的实例。给定布尔值。在/var/www/html/communicationapp/vendor/zendframework/zendframework/library/Zend/ModuleManager/Listener/ConfigListener.php:342 堆栈跟踪: