当供应商在 Symfony 2.1 中不受作曲家管理时,在哪里注册自动加载? [英] Where to register autoload when the vendor is not managed with composer in Symfony 2.1?

查看:19
本文介绍了当供应商在 Symfony 2.1 中不受作曲家管理时,在哪里注册自动加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 symfony 2.1,我想向供应商添加一个库.packagegist 中不存在该库.我无法用作曲家来管理它.当我通过 Composer 安装捆绑包或其他供应商时,它会为我管理自动加载.但是当供应商不使用composer管理时,在哪里注册自动加载呢?

I'm using symfony 2.1 and I want to add a library to vendors. The library do not exists in packagist. I can't manage it with composer. When I install bundles or others vendors through composer, it manage autoload for me. But where to register autoload when the vendor is not managed with composer?

推荐答案

您可以将不在packagist 中的库添加到composer.您必须将它们添加到 composer.json 文件的 repositories 数组中.

You can add libraries to composer that are not in packagist. You must add them in the repositories array of your composer.json file.

这里是如何加载一个包含 composer.json 文件的 github 存储库,即使它不在 packagist 上(例如,你会为修复存储库所做的一个分叉):http://getcomposer.org/doc/02-libraries.md#publishing-to-a-vcs

Here's how to load a github repository that has a composer.json file, even though it's not on packagist (for example a fork you would have done to fix a repository) : http://getcomposer.org/doc/02-libraries.md#publishing-to-a-vcs

以下是如何加载 git/svn 存储库或 zip 文件中的库:http://getcomposer.org/doc/05-repositories.md#types

And here's how to load a library that's on a git/svn repository, or a zip file : http://getcomposer.org/doc/05-repositories.md#types

使用各种可能性的示例:

An example using various possibilities:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "http://github.com/igorw/monolog"
    },
    {
      "type": "package",
      "package": {
        "name": "smarty/smarty",
        "version": "3.1.7",
        "dist": {
          "url": "http://www.smarty.net/files/Smarty-3.1.7.zip",
          "type": "zip"
        },
        "source": {
          "url": "http://smarty-php.googlecode.com/svn/",
          "type": "svn",
          "reference": "tags/Smarty_3_1_7/distribution/"
        },
        "autoload": {
          "classmap": [
            "libs/"
          ]
        }
      }
    }
  ],
  "require": {
    "monolog/monolog": "dev-bugfix",
    "smarty/smarty": "3.1.*"
  }
}

这篇关于当供应商在 Symfony 2.1 中不受作曲家管理时,在哪里注册自动加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆