Kri*_*ris 4 cakephp cakephp-2.0 composer-php
我想通过Composer安装以下插件和帮助器:
https://github.com/cakephp/debug_kit
https://github.com/loadsys/twitter-bootstrap-helper
Run Code Online (Sandbox Code Playgroud)
这是我的composer.json:
{
"repositories": [
{
"type": "package",
"package": {
"name": "cakephp/debug_kit",
"version": "2.0",
"source": {
"url": "https://github.com/cakephp/debug_kit",
"type": "git",
"reference": "origin/2.0"
}
}
},
{
"type": "package",
"package": {
"name": "loadsys/twitter-bootstrap-helper",
"version": "2.1",
"source": {
"url": "https://github.com/loadsys/twitter-bootstrap-helper",
"type": "git",
"reference": "origin/2.1"
}
}
}
],
"require": {
"loadsys/twitter-bootstrap-helper": "2.1.*",
"cakephp/debug_kit": "2.0"
},
"config": {
"vendor-dir": "Vendor/"
},
"autoload": {
"psr-0": {
"DebugKit": "/cakephp/debug_kit/",
"TwitterBootstrap" : "/loadsys/twitter-bootstrap-helper"
}
}
}
Run Code Online (Sandbox Code Playgroud)
这些包已成功安装在Vendor/cakephp/debug_kit和Vendor/loadsys/twitter-bootstrap-helper中
我的问题在于如何在CakePHP中加载它们.我的bootstrap.php中有以下内容:
require APP . 'Vendor/autoload.php';
Run Code Online (Sandbox Code Playgroud)
当我在要求自动加载后尝试加载插件时:
CakePlugin::load('DebugKit');
Run Code Online (Sandbox Code Playgroud)
它无法找到.在我的AppController.php中加载帮助器的结果类似
public $helpers = array('TiwtterBootstrap');
Run Code Online (Sandbox Code Playgroud)
我是Composer的新手,可能会遗漏一些简单的东西或者只是没有理解如何从Vendors文件夹中正确加载它们.
Jos*_*uez 10
你所做的一切都是正确的,你只需要添加一个额外的部分来指导作曲家在哪里安装你的插件.请注意额外的"installer-paths"部分,它需要指向您希望安装插件的相对路径.
{
"minimum-stability": "dev",
"config": {
"vendor-dir": "vendors"
},
"extra": {
"installer-paths": {
"app/Plugin/DebugKit": ["cakephp/debug_kit"],
}
},
"require" : {
"php": ">=5.4",
"cakephp/debug_kit": "2.2.*"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4143 次 |
| 最近记录: |