Download the PHP package empaphy/composer-yaml without Composer
On this page you can find all versions of the php package empaphy/composer-yaml. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download empaphy/composer-yaml
More information about empaphy/composer-yaml
Files in empaphy/composer-yaml
Package composer-yaml
Short Description composer.yaml support for Composer
License MIT
Informations about the package composer-yaml
composer.yaml support for Composer
This Composer plugin will make your composer project use composer.yaml
as it's
Composer config instead of composer.json
. It does so fully transparently
without the need to run additional commands.
composer.json
is still required, (to bootstrap this plugin, among other
things) however it is now generated automatically when a change in
composer.yaml
is detected. Think of this similarly to how composer.lock
is generated.
Installation
Usage
Just use composer as you usually would! The first time you run any Composer CLI command after installing this plugin, it will generate a composer.yaml based on your existing composer.json.
Just remember to modify composer.yaml from now on, and to not modify composer.json, since any changes in that file will be overridden.
Why YAML? What's wrong with JSON?
JSON was never designed to be a human-readable format. It's intended use is for computers to exchange information with one another. Hence, it misses essential features which one would need from a file that is manipulated by humans, like comments.
YAML allows for comments and a lot more, making expressive Composer configuration possible.
- Comments allow you to clarify your configuration.
- Quotes are not required, which makes the file much more readable.
- No trailing commas are required, which reduces the risk of syntax errors.
- Support for multiline strings allows you to split string over multiple rows. YAML allows you to fold or retain newlines in multiline strings.
- YAML anchors let you reference and use the same data multiple times.
YAML vs JSON
For example, if you take a typical composer.json like this:
You can turn it into something like this:
Known Issues / Roadmap
-
Using Composer CLI commands that would previously modify the composer.json will still work and properly modify the
composer.yaml
, but they will remove any custom formatting changes and comments you have made to yourcomposer.yaml
file.I plan to fix this in a future version, but it involves writing a custom YAML Manipulator, so it might take a while. For now, just refrain from using the CLI commands to modify the composer config. I mean, why even would you, when you can now use fancy YAML markup to pimp up your composer.yaml? ;-)
-
Handle first-time install of a composer.yaml project properly. Especially in the edge case where composer.yaml was modified, but composer-yaml has not yet been installed.
-
Warn about changes made to composer.json
- Add config option to choose default behaviours, for example for overwriting an existing YAML file.
All versions of composer-yaml with dependencies
ext-json Version *
composer-plugin-api Version >=1.0
symfony/yaml Version >=5.0