Kenny
Kenny

Reputation: 1

PHP Fatal error: Uncaught Error: Class 'cake\\lib\\Dispatcher' not found

I am running Apache 2.4.29 with php 7.2 on Ubuntu 18.04 LTS. My datafile (/var/www/cake/prod/webroot/) is migrated from Apache 2.2.20 with php 5 running on Ubuntu 11.10.

My apache service runs normal but when I try to access the website (https://my_ip:8080/users/login), it shows: my_ip is currently unable to handle this request.

I check the Apache error log with the following error message:

[Fri Dec 20 05:52:47.177805 2019] [php7:error] [pid 10916] [client ip:19466] PHP Fatal error: Uncaught Error: Class 'Dispatcher' not found in /var/www/cake/prod/webroot/index.php:82\nStack trace:\n#0 {main}\n thrown in /var/www/cake/prod/webroot/index.php on line 82

Conten of /var/www/cake/prod/webroot/index.php

<?php
/**
 * Index
 *
 * The Front Controller for handling every request
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.app.webroot
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
/**
 * Use the DS to separate the directories in other defines
 */
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
/**
 * These defines should only be edited if you have cake installed in
 * a directory layout other than the way it is distributed.
 * When using custom settings be sure to use the DS and do not add a trailing DS.
 */

/**
 * The full path to the directory which holds "app", WITHOUT a trailing DS.
 *
 */
if (!defined('ROOT')) {
    define('ROOT', dirname(dirname(dirname(__FILE__))));
}
/**
 * The actual directory name for the "app".
 *
 */
if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
/**
 * The absolute path to the "cake" directory, WITHOUT a trailing DS.
 *
 */
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
    define('CAKE_CORE_INCLUDE_PATH', ROOT);
}

/**
 * Editing below this line should NOT be necessary.
 * Change at your own risk.

*/
if (!defined('WEBROOT_DIR')) {
    define('WEBROOT_DIR', basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
    define('WWW_ROOT', dirname(__FILE__) . DS);
}
if (!defined('CORE_PATH')) {
    if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'))) {
      define('APP_PATH', null);
      define('CORE_PATH', null);
    } else {
        define('APP_PATH', ROOT . DS . APP_DIR . DS);
        define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
    }
}
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'prod' . DS . 'config' . DS . 'bootstrap.php')) {
    trigger_error("CakePHP core could not be found.  Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php.  It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vend$
}
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
    return;
} else {
    $Dispatcher = new Dispatcher();
    $Dispatcher->dispatch();
}

Content of /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:8080>
    ServerAdmin webmaster@localhost

    SSLEngine on
    <FilesMatch ".(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
    SSLOptions +StdEnvVars
    </Directory>

    DocumentRoot /var/www/cake/prod/webroot

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/cake/prod/webroot>
        SSLRequireSSL
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key

    SSLVerifyClient none
    SSLProxyEngine off

    Include /var/www/foswiki/foswiki_httpd_conf.txt
    <IfModule mime.c>
    AddType application/x-x509-ca-cert      .crt
    AddType application/x-pkcs7-crl         .crl
    </IfModule>

</VirtualHost>

Upvotes: 0

Views: 1443

Answers (1)

RoseHosting
RoseHosting

Reputation: 376

According to the index.php file this version of CakePHP is compatible with PHP versions 4 and 5 and you have PHP 7.2 installed on the server.

You should update CakePHP to the latest available version, compatible with PHP 7.2.

Upvotes: 0

Related Questions