0

我是 Zend2 的新手,我正在关注 Zend 上的专辑教程。我收到以下错误:

Fatal error: Uncaught Error: Class 'ArrayUtils' not found in E:\Temp\htdocs\zf-tutorial\public\index.php:43 Stack trace: #0 {main} thrown in E:\Temp\htdocs\zf-tutorial\public\index.php on line 43

我找不到什么问题,我做错了什么?我错过了一些代码吗?还是我错过了教程中的一些规则?这是我的 index.php 文件

   <?php

    use Zend\Mvc\Application;

    /**
     * Display all errors when APPLICATION_ENV is development.
     */
    if ($_SERVER['APPLICATION_ENV'] === 'development') {
        error_reporting(E_ALL);
        ini_set("display_errors", 1);
    }

    /**
     * This makes our life easier when dealing with paths. Everything is relative
     * to the application root now.
     */
    chdir(dirname(__DIR__));

    // Decline static file requests back to the PHP built-in webserver
    if (php_sapi_name() === 'cli-server') {
        $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
        if (__FILE__ !== $path && is_file($path)) {
            return false;
        }
        unset($path);
    }

    // Composer autoloading
    include __DIR__ . '/../vendor/autoload.php';

    if (! class_exists(Application::class)) {
        throw new RuntimeException(
            "Unable to load application.\n"
            . "- Type `composer install` if you are developing locally.\n"
            . "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n"
            . "- Type `docker-compose run zf composer install` if you are using Docker.\n"
        );
    }

    // Retrieve configuration
    $appConfig = require __DIR__ . '/../config/application.config.php';
    if (file_exists(__DIR__ . '/../config/development.config.php')) {
        $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');
    }

    // Run the application!
    Application::init($appConfig)->run();
4

1 回答 1

0

为了能够使用Zend\Stdlib\ArrayUtils该类,您必须:

  • use在文件顶部添加一条语句:use Zend\Stdlib\ArrayUtils;
  • 将您的ArrayUtils调用更改为Zend\Stdlib\ArrayUtils
于 2017-09-01T06:02:48.493 回答