Классы PHP не найдены в Java Bridge

Для проекта мне нужно использовать JavaBridge 7.0.1 на TomcatServer 7. Все работало хорошо (например, test.php), но после того, как я поместил свой проект внутрь, у меня появляется следующая ошибка:

Etat HTTP 500 - java.lang.RuntimeException: PHP Fatal error: Class 'Presenter' not found in C:\Developpements\eclipse\workspace\neon_2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\JavaBridge\index.php on line 85

Я вижу, что некоторые классы PHP не загружаются, когда некоторые...

Index.php

<?php
session_start();

// error reporting
ini_set('display_errors', true);
error_reporting(1);


// autoload dependencies automatically via magical composer autoload
require_once 'vendor/autoload.php';

// website configuration file
require_once 'boot.php';

// db configuration file
require_once 'config.php';

// flight framework
require 'core/flight/Flight.php';

// custom functions
require_once 'func.php';

// autoload classes
require_once('autoload.php');

// error logging
if ($config['log_errors']) {
    Flight::set('flight.log_errors', true);
    $logFile = fopen($config['log_path'] . 'applog.log', 'a+');

    Flight::map(
       'error',
       function (Exception $ex) use ($logFile) {
           $message = date('d-m-Y h:i:s') . PHP_EOL . $ex->getTraceAsString() . PHP_EOL . str_repeat(
                 '-',
                 80
              ) . PHP_EOL . PHP_EOL;

           fwrite($logFile, $message);
           fclose($logFile);
       }
    );
}

// set config
Flight::set('config', $config);

// view path
Flight::set('flight.views.path', 'app/views/');

// set base path variable to be used in setting css js files in views
$request = (array) Flight::request();
Flight::set('base', $request['base']);
Flight::set('controller', $request['url']);
Flight::set('lastSegment', end(explode('/', $request['url'])));

// connect configuration
$database = $_SESSION['db'] ? $_SESSION['db'] : $config['database_dbname'];

ORM::configure('pgsql:host=' . $config['database_host'] . ';port=5432;dbname=' . $database);
ORM::configure('username', $config['database_user']);
ORM::configure('password', $config['database_password']);
$db = ORM::get_db();

// enable query logging
ORM::configure('logging', true);

Flight::set('db', $db);
Flight::set('dbname', $database);

$stmt = $db->query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'");
$data = $stmt->fetchAll(PDO::FETCH_NUM);
$data = arrayFlatten($data);

// create table names json file
$json = array();
foreach ($data as $datakey => $datavalue) {
    $json[]['word'] = $datavalue;
}

@file_put_contents('tables.json', json_encode($json));

$tables = Presenter::listTables($data);
Flight::set('tables', $tables);

if (false !== strpos($_SERVER['REQUEST_URI'], '/table')) {
    $currentTableKey = array_search(Flight::get('lastSegment'), $data, true);
    unset($data[$currentTableKey]); // remove current table

    // make dropdown options
    Flight::set('tablesOptions', getOptions($data));
}

// get an array of databases
$stmt = $db->query("SHOW DATABASES");
$data = $stmt->fetchAll(PDO::FETCH_NUM);
$data = arrayFlatten($data);
Flight::set('databaseOptions', getOptions($data, true, null, $database));

// setup custom 404 page
Flight::map(
   'notFound',
   function () {
       //include 'errors/404.html';
       header("HTTP/1.0 404 Not Found");
       exit('404 Not Found');
   }
);

// set global variables
Flight::set('appname', $config['appname']);

///////// setup routes /////////////
require_once 'routes.php';

// auto-logout after inactivity for 10 minutes
timeoutLogout(60);

// flight now
Flight::start();

Здесь, например, Flight.php хорошо загружен, а Presenter.php - нет (загружается с помощью require_once ('autoload.php'))

autoload.php

<?php

// autoload classes from controllers/classes/presenters folders
function autoloadController($className) {
    if (false !== strpos($className, 'flight')) return;

    $className = strtolower($className);
    $filename = "app/controllers/" . $className . ".php";

    if (is_readable($filename)) {
        require $filename;
    }
}

function autoloadClass($className) {
    if (false !== strpos($className, 'flight')) return;

    $className = strtolower($className);
    $filename = "app/classes/" . $className . ".php";

    if (is_readable($filename)) {
        require $filename;
    }
}

function autoloadPresenter($className) {
    if (false !== strpos($className, 'flight')) return;

    $className = strtolower($className);
    $filename = "app/presenters/" . $className . ".php";

    if (is_readable($filename)) {
        require $filename;
    }
}

spl_autoload_register('autoloadController');
spl_autoload_register('autoloadPresenter');
spl_autoload_register('autoloadClass');

Это странно, потому что Presenter.php хорошо расположен:

presenter.php

<?php

class Presenter
{
    public static function listTables(array $array)
    {
        $html = '';

        $base = Flight::get('base');

        $counter = 0;
        foreach ($array as $arrayitem) {
            $counter ++;

            $html .= <<< HTML
            <li><a href="$base/table/$arrayitem">$arrayitem</a></li>
HTML;
        }

        return $html;
    }

    public static function listTableData(array $array, $fieldTypes = array())
    {
        //$fieldTypes = convertFieldTypesEditable($fieldTypes);

        $html = '<table class="table table-striped table-bordered table-hover">' . "\n";
        $html .= '<thead>' . "\n";

        // build headings
        foreach ($array[0] as $head => $value) {
            $html .= "<th>$head</th>" . "\n";
        }

        $html .= '</thead>' . "\n";

        // build body
        $html .= '<tbody>' . "\n";

        //pretty_print($array);

        foreach ($array as $subArray) {
            $html .= '<tr>' . "\n";

            foreach ($subArray as $value) {
                $html .= '<td style="white-space: nowrap !important;">' . $value . '</td>' . "\n";
            }

            $html .= '</tr>' . "\n";
        }

        $html .= '</tbody>' . "\n";
        $html .= '</table>' . "\n";

        return $html;
    }
}

Наконец, если попробовать это в Wamp, все работает отлично

0 ответов

Другие вопросы по тегам