Where to register autoload when the vendor is not managed with composer in Symfony 2.1?

smoreno picture smoreno · Jul 16, 2012 · Viewed 9.3k times · Source

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?

Answer

AdrienBrault picture AdrienBrault · Jul 16, 2012

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

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

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.*"
  }
}