PHPackages                             strausmann/composerapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. strausmann/composerapi

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

strausmann/composerapi
======================

A wrapper for Composer to call its commands programmatically using a simple object oriented API

0.3.5(8y ago)0157MITPHPPHP ^7.0 || ^7.1 || ^7.2

Since Feb 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/strausmann/ComposerAPI)[ Packagist](https://packagist.org/packages/strausmann/composerapi)[ RSS](/packages/strausmann-composerapi/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/6b3e59728bf3f2f5994f64086ebe48ed4ec17bc12382b1eefff35fff36dd0e5e/68747470733a2f2f706f7365722e707567782e6f72672f7374726175736d616e6e2f636f6d706f7365726170692f762f737461626c65)](https://packagist.org/packages/strausmann/composerapi)[![Total Downloads](https://camo.githubusercontent.com/0598b7a714b66eaab8c30319918d8d4fcc01e109e6b47615b379345e038c7089/68747470733a2f2f706f7365722e707567782e6f72672f7374726175736d616e6e2f636f6d706f7365726170692f646f776e6c6f616473)](https://packagist.org/packages/strausmann/composerapi)[![Latest Unstable Version](https://camo.githubusercontent.com/c6f8fe1e03f6ef805b9c98a4318b37195b3e5bd05dc7f4d4b251a174cb8d9ef6/68747470733a2f2f706f7365722e707567782e6f72672f7374726175736d616e6e2f636f6d706f7365726170692f762f756e737461626c65)](https://packagist.org/packages/strausmann/composerapi)[![License](https://camo.githubusercontent.com/16395a2673868a4af289465631f50e70e6fe6268527206b263d0831d08d1583e/68747470733a2f2f706f7365722e707567782e6f72672f7374726175736d616e6e2f636f6d706f7365726170692f6c6963656e7365)](https://packagist.org/packages/strausmann/composerapi)

ComposerAPI
===========

[](#composerapi)

A wrapper for [Composer](http://getcomposer.org) to call it's commands from inside your code using a simple object oriented API: turns `php composer.phar require monolog/monolog` into `$composer->require(array('monolog/monolog:*'));`.

Installation
------------

[](#installation)

As always, the easiest (and the recommended) way to install is using composer:

```
composer require composer/composer:1.2 kabachello/composerapi:*

```

Note the explicit requirement for `composer/composer` in a fixed version: this is important to prevent automatic updates of this dependency when running the `update` command programmatically - see "Known limitations" section below for details.

There is no simple way to install composer an the API without using composer itself. Theoretically you could include ComposerAPI.php in your code manually, but you would need to make sure an installation of "composer/composer" is available under the namespace "\\Composer". The trouble is, however, that composer has lot's of dependencies itself, so you will probably end up needing the packaged version (composer.phar) anyway. If so, use the simple composer-install above.

Quick start
-----------

[](#quick-start)

Here is an example, that adds the monolog library to an existing composer.json manifest and installes it with all dependencies:

```
