简体   繁体   English

Composer自动加载与EzPublish之间的冲突

[英]Conflict between Composer autoload and EzPublish one

First sorry for my bad English, I'm a French speaker ^^. 首先,抱歉我的英语不好,我是说法语的人^^。 I'm working with Restler as webservice in my eZpublish framework. 我正在使用eZpublish框架中的Restler作为Web服务。

When I have installed Restler, I have installed Composer too. 安装Restler后,我也安装了Composer。

In the index file in witch I use Restler methods, and API classes, I include both ezpublish autoload en restler one, but i have a conflict. 在女巫的索引文件中,我使用Restler方法和API类,我同时包括ezpublish autoload和restler一个,但是我有冲突。 When I remove the ezpublish autoload, API classes are not recognized. 当我删除ezpublish自动加载时,无法识别API类。 I want to know how I can, in the composer.json, add all classes of my application. 我想知道如何在composer.json中添加应用程序的所有类。

in the Composer.json file, i have 在Composer.json文件中,我有

 "autoload":{
        "psr-0":{
            "Luracast\\Restler": "vendor/"
        }

` I want to change vendor/ by extension/ because all classes are in extension, Restler classes too. 我想按扩展名更改供应商/,因为所有类都在扩展中,Restler类也是如此。 I just want to have all classes with one namespace. 我只想让所有类具有一个名称空间。 Could you help me please. 请问你能帮帮我吗。 Thanks in advance. 提前致谢。

Assuming that you are using eZ Publish Legacy (4.x), you don't need to add the autoload settings for restler in your root composer.json, just add it as a requirement and let composer handle the rest: 假设您使用的是eZ Publish Legacy(4.x),则无需在根composer.json中添加restler的autoload设置,只需将其添加为要求,然后让composer处理其余部分:

{
    "require": {
        "luracast/restler": "~3.0"
    }
}

In your index.php you should then be able to use index.php您应该可以使用

include __DIR__ . '/vendor/autoload.php';

in addition to the eZ Publish autoloads. 除了eZ Publish自动加载。

For your custom classes inside your extension, you have to execute 对于扩展中的自定义类,您必须执行

php bin/php/ezpgenerateautoloads.php -e

so that they will be found by the eZ Publish autoloader. 以便eZ Publish自动加载器可以找到它们。

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

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