我试图安装这个github repo到我的项目(在codeigniter上运行)。我所做的步骤非常简单:
{
"name": "project",
"description": "",
"license": "MIT",
"require": {
"php" : ">=5.3.0",
"blockchain/blockchain" : "1.*",
"ext-curl": "*"
},
"require-dev": {
}
} // composer.json
,运行php composer.phar update
。所以这个包安装了,但是我不能在我的项目中使用它——我不认为它是自动加载的。/vendor/autoload.php
是需要在我的index.php。当我用不同的软件包(kriswallsmith/buzz)进行测试时,它可以工作。我做错了什么?
我也检查了我的vendor/composer/installed.json
,我看到这个:
[
{
"name": "blockchain/blockchain",
"version": "v1.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/blockchain/api-v1-client-php.git",
"reference": "c219b9b00778cf6c025628bd34fd6543922fe81b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/blockchain/api-v1-client-php/zipball/c219b9b00778cf6c025628bd34fd6543$
"reference": "c219b9b00778cf6c025628bd34fd6543922fe81b",
"shasum": ""
},
"require": {
"ext-curl": "*",
"php": ">=5.3.0"
},
"time": "2015-02-03 18:34:11",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Blockchain\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Blockchain API client library",
"homepage": "https://github.com/blockchain/api-v1-client-php",
"keywords": [
"bitcoin",
"blockchain"
]
}
]
和我的函数,我试图使用这个lib:
private function __check_btc_balance()
{
error_reporting(E_ALL);
$Blockchain = new BlockchainBlockchain(PAYMENTS_BTC_API_CODE);
}
您是否遵循了安装步骤?
基本上与普通的编写器包有一些区别。这里写着下载源代码并从自己的文件夹
中运行composer install
然后从下载文件的文件夹中包含自动加载文件,这样你就会有一个文件夹Blockchain/vendor/autoload.php
来包含
下载源代码或克隆存储库。这个php库可以工作使用Composer包管理器。的根目录存储库并运行
$ composer install
这将在存储库根目录下创建/vendor文件夹。在php中源,简单:
//从供应商目录中包含autolload .php"供应商/autoload.php"
//创建区块链基类实例
我见过…
"autoload": {
"psr-4": {
"Blockchain\": "src/"
}
},
我总是把我所有的代码保存在srcVendorProjectFilename.php和composer自动加载器中。尝试添加以下代码行:
"autoload": {
"psr-0": {
"": "src/"
}
},