Download the PHP package mcstreetguy/composer-parser without Composer

On this page you can find all versions of the php package mcstreetguy/composer-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package composer-parser

Composer Parser

A dependency-free parser library for composer.json and composer.lock files.

Installation

Usage

Parsing

I recommend using the provided magic Factory method for parsing:

Even if this is the easiest way to retrieve an instance, it may be that you for some reason cannot rely on these automations (e.g. if you got a differing filename). In this case you can also call the parse methods directly:

Please note that ComposerParser will not complain about any missing fields, instead it fills all missing values with default ones to ensure integrity.

Exception Handling

During instatiation through the Factory, two exceptions may occur:

Doing it the manual way

If you can not rely on the Factory for any reason, you can also instantiate the class directly.
This is however not recommended and may lead to unexpected behaviour.

As you can see the constructor needs an array with the parsed json data. This applies to all constructor methods throughout the library.

Sub-components

You can also create sub-components directly. In this case you have to keep in mind, that their constructors only accept the isolated data from the composer manifest (e.g. the Author class expects you to pass only the contents of one of the objects in the author-field).

Data Retrieval

All class instances provide getters for their properties. The structure is directly adapted from the composer.json schema. The corresponding property names of wrapper classes have been converted to camelCase (see the PSR-1 standard for further information).

For any property you can use the provided getter methods.

It's also possible to directly access properties. Please note that this is read-only!

You may also call empty() or isset() on the class properties.
To check if the whole wrapper is empty (useful for nested classes) there is an isEmpty() method inherited:

Special Classes

ComposerParser uses some special classes for parts of the json schema.

PackageMap

The PackageMap class is used for the fields require, require-dev, conflict, replace, provide and suggest. It converts a json structure like this:

into an array structure like this:

Additionally it implements the Iterator and ArrayAccess interfaces, thus you may directly access it's contents or put it in a foreach loop:

If you for some reason need the original mapped data you can retrieve it as following:

NamespaceMap

The NamespaceMap is used for the fields autoload.psr-0 and autoload.psr-4. In fact this class is identical to the PackageMap. The only difference are the map keys:

Global Configuration

By default, the library tries to load your global configuration file, if there is any. It follows the location rules for the composer home directory as defined in the documentation. If there is no readable global configuration file present, this step is silently skipped.

Just as composer itself, the following precedence rule applies to global configuration files:

In case global configuration matches local configuration, the local configuration in the project's composer.json always wins. (source: https://getcomposer.org/doc/03-cli.md#composer-home-config-json)

You may suppress this behaviour by passing true as second parameter to the parse, parseComposerJson and parseLockfile methods.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Testing

If you contribute to this project, you have to ensure that your changes don't mess up the existing functionality. Therefore this repository comes with a PhpUnit testing configuration, that you can execute by running make test. See their documentation on more information on how to install the tool.

Authors

See also the list of contributors who participated in this project.

Acknowledgement

Special thanks go to antonkomarev who helped discovering and fixing several deeply nested bugs in the libraries architecture.

License

This project is licensed under the MIT License - see the LICENSE file for details


All versions of composer-parser with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mcstreetguy/composer-parser contains the following files

Loading the files please wait ....