简体   繁体   English

作曲家与Koseven(Kohana)

[英]Composer with Koseven (Kohana)

I'm developing an application where I started using Kohana and now Koseven, and I need to use an api that was available in the composer, I followed the steps to download the files I created a folder to sell inside the application, and put in the bootstrap.php code to call the autoload of the composer. 我正在开发一个应用程序,开始使用Kohana,现在使用Koseven,我需要使用作曲家中可用的api,我按照步骤下载了文件,并创建了一个文件夹出售给应用程序,然后放入bootstrap.php代码以调用作曲家的自动加载。 But after doing this when trying to use a class of this api error of "class not found" occurs. 但是在尝试使用此api的类进行此操作后,发生“找不到类”错误。 I do not know what else to do, can you help me? 我不知道该怎么办,您能帮我吗?

In order to use composer with Kohana or Koseven, you need to call composer 's autoloader from within bootstrap.php . 为了在Kohana或Koseven中使用composer ,您需要从bootstrap.php内调用composer的自动加载器。

After Kohana::modules($modules); Kohana::modules($modules); and before Route::set , insert the following code: Route::set之前,插入以下代码:

/**
 * Autoload composer libraries
 *
 */
require APPPATH . 'vendor/autoload.php';

This assumes your composer install command is run the from the root of your app, and it uses the default vendor directory. 假设您的composer install命令从应用程序的根目录运行,并且使用默认的vendor目录。

Probably you must add this to your composer.json . 可能您必须将其添加到composer.json (Check inc composer doc.) I don't know, because in modules directory I have second instance. (检查inc作曲家文档。)我不知道,因为在modules目录中,我有第二个实例。

"extra": {
    "installer-paths": {
        "modules/{$name}/": ["type:kohana-module"]
    }
},

And enable module composer as first: 并启用模块composer为先:

Kohana::modules(array(
    'composer'   => MODPATH.'composer',       // 
    'auth'       => MODPATH.'auth',       // Basic authentication
    'cache'      => MODPATH.'cache',      // Caching with multiple backends

It works for me ko3 它对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM