I would like to add library to my drupal 7 custom module. Library can be installed via composer, but i can't find a solution for install? How can i install this library? I have installed "composer manager" but i still can't get it running.
To get started, add a
composer.json file to your module. The only thing you need here is the
require section that includes your external library.
Composer manager is one way to combine all of your dependencies together, but there are other options to get Drupal to load your autoload.php file. The technique I prefer is to create a project-level
composer.json file in your Drupal root, and use the module composer_vendor to include your autoload.php file.
The easiest way to get started is to use the composer_generate Drush extension to build your project-level
$ drush dl composer_generate
$ cd /path/to/drupalroot
$ drush composer-generate > composer.json
$ composer install
Composer-generate will add all of the projects currently used in your Drupal site, plus composer_vendor, so
composer install should just work for you. The main magic here is in the custom autoloaders added to the template; take a look at the output to see what was included.
Some caution needs to be used here, of course; the default template will put all of your modules in sites/all/modules/contrib. You can edit the template prior to running composer install if this isn't what you want.
You'll also have to be careful if you have any modified modules; there are a number of ways to deal with any hacked content, but that's a bit beyond the scope of this one question.
If you don't want to run Drush, you can also hand-type your own composer.json file using the project https://github.com/drupal-composer/drupal-project. This is the template that composer-generate is based on.