Composer: Unterschied zwischen den Versionen
Die Seite wurde neu angelegt: „= Composer - The PHP dependency manager = The Drupal community is changing to use Composer to install and update Drupal. Drush has no idea about dependencies…“ |
Keine Bearbeitungszusammenfassung |
||
| Zeile 12: | Zeile 12: | ||
For more information about the Lightning Distribution see its [https://www.drupal.org/project/lightning Drupal.org project page] or [https://github.com/acquia/lightning-project Github page]. | For more information about the Lightning Distribution see its [https://www.drupal.org/project/lightning Drupal.org project page] or [https://github.com/acquia/lightning-project Github page]. | ||
== Composer Configuration == | |||
List configuration from the composer.json file in the current folder. | |||
composer config --list | |||
=== Modifying Repositories === | |||
The '''composer config''' command also supports making changes to the repositories section by using it the following way: | |||
composer config repositories.foo vcs https://github.com/foo/bar | |||
If your repository requires more configuration options, you can instead pass its JSON representation : | |||
composer config repositories.foo '{"type": "vcs", "url": "http://svn.example.org/my-project/", "trunk-path": "master"}' | |||
More info on [https://getcomposer.org/doc/03-cli.md#config '''composer config''' commands]. | |||
More info on [https://getcomposer.org/doc/04-schema.md#repositories '''composer config repositories''' commands]. | |||
== Creating your very own Composer Package == | |||
([http://knpuniversity.com/screencast/question-answer-day/create-composer-package Info from KNP University]) | |||
# Put your Composer package project in a git repository (example repository https://github.com/weaverryan/derp-dangerzone used in examples) | |||
# Give your Library a composer.json File | |||
Add a '''composer.json''' file in the library itself. This is really easy. Created a new '''composer.json''' file at the root of the git project. Composer will look at your branches and tags to get the version and source keys. | |||
In other words, create a composer.json file in your git repository root that looks similar to this: | |||
{ | |||
"name": "'''weaverryan/derp-dangerzone'''", | |||
"autoload": { | |||
"psr-0" : { | |||
"'''Weaverryan\\DangerZone'''" : "src" | |||
} | |||
} | |||
} | |||
Where '''weaverryan/derp-dangerzone''' is the name of the git repository and | |||
where '''Weaverryan\\DangerZone''' is the [https://getcomposer.org/doc/04-schema.md#psr-0 PSR-0 namespace]. This namespace is directly related to the folders in the '''src''' folder containing your project. | |||
To add this repository to your composer project you can run: | |||
composer config repositories.'''zeberli''' vcs https://github.com/weaverryan/derp-dangerzone | |||
Where '''zeberli''' in a unique key identifying this repository in the composer.json file. | |||
Version vom 11. Januar 2017, 13:59 Uhr
Composer - The PHP dependency manager
The Drupal community is changing to use Composer to install and update Drupal. Drush has no idea about dependencies as it is not a dependency manager.
Install the Drupal 8 Lightning distribution with Composer
composer create-project acquia/lightning-project:^8.1.0 MYPROJECT --no-interaction
Where MYPROJECT is the name of the project folder. Inside the project folder will be the webroot folder called docroot. This is the folder to server with the web server.
ie. To install a project called meos on the dev01 server, first go to /var/www then run:
composer create-project acquia/lightning-project:^8.1.0 meos --no-interaction
For more information about the Lightning Distribution see its Drupal.org project page or Github page.
Composer Configuration
List configuration from the composer.json file in the current folder.
composer config --list
Modifying Repositories
The composer config command also supports making changes to the repositories section by using it the following way:
composer config repositories.foo vcs https://github.com/foo/bar
If your repository requires more configuration options, you can instead pass its JSON representation :
composer config repositories.foo '{"type": "vcs", "url": "http://svn.example.org/my-project/", "trunk-path": "master"}'
More info on composer config commands.
More info on composer config repositories commands.
Creating your very own Composer Package
- Put your Composer package project in a git repository (example repository https://github.com/weaverryan/derp-dangerzone used in examples)
- Give your Library a composer.json File
Add a composer.json file in the library itself. This is really easy. Created a new composer.json file at the root of the git project. Composer will look at your branches and tags to get the version and source keys.
In other words, create a composer.json file in your git repository root that looks similar to this:
{
"name": "weaverryan/derp-dangerzone",
"autoload": {
"psr-0" : {
"Weaverryan\\DangerZone" : "src"
}
}
}
Where weaverryan/derp-dangerzone is the name of the git repository and where Weaverryan\\DangerZone is the PSR-0 namespace. This namespace is directly related to the folders in the src folder containing your project.
To add this repository to your composer project you can run:
composer config repositories.zeberli vcs https://github.com/weaverryan/derp-dangerzone
Where zeberli in a unique key identifying this repository in the composer.json file.