Search code examples
composer-phpdrupal-8drupal-console

Adding Composer as Manager of Drupal 8


I installed D8 manually but I need Composer to Manage and Install Drush and Drupal Console. I found docs about fresh install, but I would to know if it's possible to add Composer as Drupal components manager after a manual druapl install ?

Actually I have Composer and Drush9 installed. But I can't do update for D8 because Composer doesn't find infos about this:

 ~/www/mgasquet/sited8 $ composer outdated
behat/mink-selenium2-driver          dev-master 93474c6 dev-master 3ab9f31 Selenium2 (WebDriver) driver for Mink framework
brumann/polyfill-unserialize         v1.0.3             v1.0.4             Backports unserialize options introduced in PHP 7.0 to older PHP versions.
composer/installers                  v1.6.0             v1.7.0             A multi-framework Composer library installer
dflydev/dot-access-data              v1.1.0             v2.0.0             Given a deep data structure, access data by dot notation.
doctrine/annotations                 v1.2.7             v1.7.0             Docblock Annotations Parser
doctrine/cache                       v1.6.2             v1.8.0             Caching library offering an object-oriented API for many cache backends
doctrine/collections                 v1.3.0             v1.6.2             Collections Abstraction library
doctrine/common                      v2.6.2             v2.10.0            Common Library for Doctrine projects
doctrine/inflector                   v1.1.0             v1.3.0             Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                1.0.5              1.2.0              A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       v1.0.1             1.1.0              Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
drupal/coder                         8.3.1              8.3.6              Coder is a library to review Drupal code.
egulias/email-validator              2.1.7              2.1.11             A library for validating emails against several RFCs
grasmash/yaml-expander               1.4.0              2.0.0              Expands internal property references in a yaml file.

Thanks for tips.

EDIT: is this a good and actual way ? tuto

EDIT2: as I must update modules too, I face off a little issue ragarding "minimum-stability" , I put this in my composer.json,

"minimum-stability": "dev",
    "prefer-stable": true,

But it replace dev version by alpha ones. I prefer using dev or stable not alpha or beta, RC admitted. How can I do that ?

EDIT3: modules aren't downloaded in modules/contrib, so do I need to add this to my composer.json ?

"extra": {
        "installer-paths": {
            "modules/contrib/{$name}/": ["type:drupal-module"],
            "themes/contrib/{$name}/": ["type:drupal-theme"]
        },

Solution

  • You can definitely attempt the recommendations on the guide you linked to. Take a full code, database, and file backup of the site first.

    That said, I highly recommend you re-build the site using drupal-project. After which:

    • run composer require for all of your contributed modules / themes
    • copy any custom modules / themes
    • re-import the database
    • copy over your files directory

    P.S. to anyone viewing this answer in the future please check the core strategic initiative for up to date info.