Predis Autoloader 不加载
Predis Autoloader doesn't load
我使用 composer 将外部库添加到我的项目中 - 包括 Predis。
由于某种原因,可能没有生成 Predis,我总是收到:
Class 'Predis\Autoloader' not found
所以我深入研究了作曲家加载文件,发现了一些奇怪的东西如下:
这是我的 composer.json:
{
"require": {
"facebook/php-sdk": "@stable",
"everyman/neo4jphp": "dev-master",
"predis/predis": "1.1.*@dev",
"aws/aws-sdk-php": "2.*"
},
"autoload": {
"psr-0": {
"PicoCore\": "",
"PicoCore\Authentication\" : "PicoCore/authentication",
"PicoCore\Aws\" : "PicoCore/aws",
"PicoCore\Cache\" : "PicoCore/cache",
"PicoCore\Database\" : "PicoCore/database",
"PicoCore\Facebook\" : "PicoCore/facebook",
"PicoCore\Objects\" : "PicoCore/objects",
"PicoCore\Rest\" : "PicoCore/rest",
"PicoCore\Configuration\" : "PicoCore/configuration",
"PicoCore\Configuration\Api\" : "PicoCore/configuration/api",
"PicoCore\Scripts\" : "PicoCore/scripts",
"PicoCore\Times" : "PicoCore/times"
}
}
}
现在,我想看看为 Predis 生成的命名空间是什么样子的,所以我检查了 composer 文件夹中的 autoload_par4.php,它是这样的:
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Symfony\Component\EventDispatcher\' => array($vendorDir . '/symfony/event-dispatcher'),
'Predis\' => array($vendorDir . '/predis/predis/PicoCore'),
);
现在,如果您注意到,您会看到 Predis 命名空间路径是 /predis/predis/PicoCore
(PicoCore 是我的应用程序命名空间)当它应该是
/predis/predis/src
当我手动更改它时 - 它工作正常,但问题是每当我更新作曲家时,它都会再次执行..
知道它为什么或从哪里获取路径以及为什么添加我的项目名称吗?
对了,我看了下predis的composer.json,修改了一下,现在变成了这样:
{
"name": "predis/predis",
"type": "library",
"description": "Flexible and feature-complete PHP client library for Redis",
"keywords": ["nosql", "redis", "predis"],
"homepage": "http://github.com/nrk/predis",
"license": "MIT",
"support": {
"issues": "https://github.com/nrk/predis/issues"
},
"authors": [
{
"name": "Daniele Alessandri",
"email": "suppakilla@gmail.com",
"homepage": "http://clorophilla.net"
}
],
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"suggest": {
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol",
"ext-curl": "Allows access to Webdis when paired with phpiredis"
},
"autoload": {
"psr-4": {"Predis\": "src/"}
},
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
}
}
问题是我添加了以下依赖:
"predis/predis": "1.1.*@dev"
虽然我需要:
"predis/predis": "1.0.1"
我使用 composer 将外部库添加到我的项目中 - 包括 Predis。
由于某种原因,可能没有生成 Predis,我总是收到:
Class 'Predis\Autoloader' not found
所以我深入研究了作曲家加载文件,发现了一些奇怪的东西如下:
这是我的 composer.json:
{
"require": {
"facebook/php-sdk": "@stable",
"everyman/neo4jphp": "dev-master",
"predis/predis": "1.1.*@dev",
"aws/aws-sdk-php": "2.*"
},
"autoload": {
"psr-0": {
"PicoCore\": "",
"PicoCore\Authentication\" : "PicoCore/authentication",
"PicoCore\Aws\" : "PicoCore/aws",
"PicoCore\Cache\" : "PicoCore/cache",
"PicoCore\Database\" : "PicoCore/database",
"PicoCore\Facebook\" : "PicoCore/facebook",
"PicoCore\Objects\" : "PicoCore/objects",
"PicoCore\Rest\" : "PicoCore/rest",
"PicoCore\Configuration\" : "PicoCore/configuration",
"PicoCore\Configuration\Api\" : "PicoCore/configuration/api",
"PicoCore\Scripts\" : "PicoCore/scripts",
"PicoCore\Times" : "PicoCore/times"
}
}
}
现在,我想看看为 Predis 生成的命名空间是什么样子的,所以我检查了 composer 文件夹中的 autoload_par4.php,它是这样的:
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Symfony\Component\EventDispatcher\' => array($vendorDir . '/symfony/event-dispatcher'),
'Predis\' => array($vendorDir . '/predis/predis/PicoCore'),
);
现在,如果您注意到,您会看到 Predis 命名空间路径是 /predis/predis/PicoCore
(PicoCore 是我的应用程序命名空间)当它应该是
/predis/predis/src
当我手动更改它时 - 它工作正常,但问题是每当我更新作曲家时,它都会再次执行..
知道它为什么或从哪里获取路径以及为什么添加我的项目名称吗?
对了,我看了下predis的composer.json,修改了一下,现在变成了这样:
{
"name": "predis/predis",
"type": "library",
"description": "Flexible and feature-complete PHP client library for Redis",
"keywords": ["nosql", "redis", "predis"],
"homepage": "http://github.com/nrk/predis",
"license": "MIT",
"support": {
"issues": "https://github.com/nrk/predis/issues"
},
"authors": [
{
"name": "Daniele Alessandri",
"email": "suppakilla@gmail.com",
"homepage": "http://clorophilla.net"
}
],
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"suggest": {
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol",
"ext-curl": "Allows access to Webdis when paired with phpiredis"
},
"autoload": {
"psr-4": {"Predis\": "src/"}
},
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
}
}
问题是我添加了以下依赖:
"predis/predis": "1.1.*@dev"
虽然我需要:
"predis/predis": "1.0.1"