我正在尝试在Debian服务器上部署使用您的库的php API。
我完成了php,composer和库的安装,但是我得到了
”错误:在/app/app/controllers/AuthController.php中找不到类'Lcobucci \ JWT \ Signer \ Hmac \ Sha256',好像use子句没有在寻找正确的存储库。
我的项目如下:
使用AuthController.php类中的导入:
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Parser;
use Lcobucci\JWT\ValidationData;
我必须对自动装带器做些什么,以便它在正确的目录中查找您的类吗?
我的composer.json中确实有需求
"require": {
"lcobucci/jwt": "^3.2",
}
我的autoloader.php
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit284b1942c0e74e39634354f520984117::getLoader();
我的autoloader_real.php
class ComposerAutoloaderInit284b1942c0e74e39634354f520984117
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit284b1942c0e74e39634354f520984117', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit284b1942c0e74e39634354f520984117', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit284b1942c0e74e39634354f520984117::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit284b1942c0e74e39634354f520984117::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire284b1942c0e74e39634354f520984117($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire284b1942c0e74e39634354f520984117($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}
我的autoload_namespaces.php
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Twig_' => array($vendorDir . '/twig/twig/lib'),
'Pimple' => array($vendorDir . '/pimple/pimple/src'),
'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib'),
'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'),
);
答案 0 :(得分:0)
使用require_once __ DIR __。 '/../../vendor/autoload.php';在AuthController中有效,但require_once'/home/$user/api-v3/api/conf/vendor/autoload.php';