首页 > 解决方案 > 无法使用作曲家启动我自己的捆绑包

问题描述

我正在使用 symfony4,我想创建和使用我自己的包。

我按照教程创建了自己的包:https ://symfonycasts.com/screencast/symfony-bundle

我在第 09 章遇到了一个问题:正确的捆绑 composer.json 文件

我已遵循本章的所有步骤。我已尝试composer require bon-coin-bundle:*@dev按照指示启动命令,但这是我的错误:

因此,我尝试在没有更好结果的情况下启动其他命令:composer require ../bon-coin-bundle:*, composer require ../bon-coin-bundle:*@dev ...

我已经像这样编辑了 composer.json:

{
    "name": "bon-coin-bundle",
    "description": "Bon Coin",
    "type": "symfony-bundle",
    "license": "MIT",
    "authors": [
        {
            "name": "matodo",
            "email": "matodo@xxx.com"
        }
    ],
    "require": {
        "php": "^7.1.3"
    },
    "autoload": {
        "psr-4": {
            "bonCoinBundle\\": "bonCoinBundle"
        }
    }
}

(我不太确定我为自动加载部分做了什么,但我不认为问题来自那里)

我的文件夹排列如下:一个 bonCoinBundle 文件夹包含我的捆绑包的 DependencyInjections、资源和服务。文件夹 bonCoinBundle 不在我当前的项目 symfony 中。

bonCoinBundle
|- DependencyInjection
   Resources
   ...
symfonyProject
|- src 
   ...

标签: phpservicebundlesymfony4

解决方案


我不知道将捆绑包发布到 packagist 意味着什么,但我已将此路径放在项目的 composer.json 中:

"repositories": [
        {
            "type": "path",
            "url": "../bonCoinBundle"
        }
    ]


推荐阅读