Search code examples
symfony-2.1composer-phppackagistsatis

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


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?


Solution

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