[SOLVED] How To Upgrade Contributed Module Of Drupal 7 To Drupal 8 Using Drupal Module Upgrader
BY akhila.vn
10 months ago
0 comments comment

For upgrading any of your contributed Drupal 7 modules, you just need to follow the few steps shown below. First of all you have to make sure that Drush is installed. If not installed, follow the steps from here.

Now install a fresh Drupal 8 in your system using Drush commands or directly download from Drupal.org. You must be aware that Drupal 8 has changed its structure from Drupal 7 in configuration, theming, folder structure etc. So now we can find the contributed and custom modules in the modules folder in the root directory. It is also better to create a contrib folder in modules folder for both DMU (Drupal Module Upgrader) and your Drupal 7 module for migration.

And now let's have a look at DMU. Drupal Module Upgrader is a script that scans and upgrades the source code of your Drupal 7 module, it also generates a list of new fixes with information links to Drupal.org as an upgrade-info.html file that will be available in your upgrading module directory. Also note that, this DMU scripts will run using Drush and Composer.

Now get into your Drupal 8's contrib folder using the terminal (For example: cd public_html/d8/modules/contrib) and follow the steps :

  • Download DMU using the drush command drush dl drupalmoduleupgrader. For example :
    xx@xx:~/public_html/d8/modules/contrib$ drush dl drupalmoduleupgrader
    Project drupalmoduleupgrader (8.x-1.2) downloaded to                 [success]
  • Now get into your Drupal module upgrader folder and install Composer. For example:
    xx@xx:~/public_html/d8/modules/contrib$ cd drupalmoduleupgrader/
    xx@xx:~/public_html/d8/modules/contrib/drupalmoduleupgrader$ composer install
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
      - Installing cebe/markdown (dev-master f89dc1d)
        Cloning f89dc1da1fc6823f0286d6cad736a642efd0f59e
      - Installing phpdocumentor/reflection-docblock (2.0.4)
        Loading from cache
      - Installing grom358/pharborist (dev-master 0db9e51)
        Cloning 0db9e51299a80e95b06857ed1809f59bbbab1af6
      - Installing symfony/filesystem (2.6.x-dev 823c035)
        Cloning 823c035b1a5c13a4924e324d016eb07e70f94735
      - Installing symfony/finder (2.6.x-dev 203a10f)
        Cloning 203a10f928ae30176deeba33512999233181dd28
      - Installing mikey179/vfsstream (v1.5.0)
        Loading from cache
      - Installing phpunit/php-token-stream (1.4.8)
        Loading from cache
      - Installing symfony/yaml (v2.7.4)
        Loading from cache
      - Installing sebastian/version (1.0.6)
        Loading from cache
      - Installing sebastian/global-state (1.0.0)
        Loading from cache
      - Installing sebastian/recursion-context (1.0.1)
        Loading from cache
      - Installing sebastian/exporter (1.2.1)
        Loading from cache
      - Installing sebastian/environment (1.3.2)
        Loading from cache
      - Installing sebastian/diff (1.3.0)
        Loading from cache
      - Installing sebastian/comparator (1.2.0)
        Loading from cache
      - Installing phpunit/php-text-template (1.2.1)
        Loading from cache
      - Installing doctrine/instantiator (1.0.5)
        Loading from cache
      - Installing phpunit/phpunit-mock-objects (2.3.7)
        Loading from cache
      - Installing phpunit/php-timer (1.0.7)
        Loading from cache
      - Installing phpunit/php-file-iterator (1.4.1)
        Loading from cache
      - Installing phpunit/php-code-coverage (2.2.3)
        Loading from cache
      - Installing phpspec/prophecy (v1.5.0)
        Loading from cache
      - Installing phpunit/phpunit (4.8.9)
        Loading from cache
    phpdocumentor/reflection-docblock suggests installing dflydev/markdown (~1.0)
    phpdocumentor/reflection-docblock suggests installing erusev/parsedown (~1.0)
    sebastian/global-state suggests installing ext-uopz (*)
    phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
    phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
    Generating autoload files
  • Get back to your contrib folder and clone your Drupal 7 module to it. You can find its cloning commands from its Drupal.org version control page. Here for example: commerce_techprocess is used as Drupal 7 module for migration.
    xx@xx:~/public_html/d8/modules/contrib/drupalmoduleupgrader$ cd ..
    xx@xx:~/public_html/d8/modules/contrib$ git clone --branch 7.x-1.x http://git.drupal.org/project/commerce_techprocess.git
    Cloning into 'commerce_techprocess'...
    remote: Counting objects: 23, done.
    remote: Compressing objects: 100% (22/22), done.
    remote: Total 23 (delta 6), reused 0 (delta 0)
    Unpacking objects: 100% (23/23), done.
    Checking connectivity... done.
  • Get back to your site root directory and enable drupalmoduleupgrader.
    xx@xx:~/public_html/d8$ drush en drupalmoduleupgrader
    The following extensions will be enabled: drupalmoduleupgrader
    Do you really want to continue? (y/n): y
    drupalmoduleupgrader was enabled successfully.                       [ok]
  • Now start analysing your module using the upgrader, it will list out the fixes and generate an html info file.
    xx@xx:~/public_html/d8$ drush dmu-analyze commerce_techprocess --path=modules/contrib/commerce_techprocess/
    Generated a report at                                                [success]
  • After all, you can upgrade your module using the command,
    xx@xx:~/public_html/d8$ drush dmu-upgrade commerce_techprocess --path=modules/contrib/commerce_techprocess/
    It will automatically create some of the Drupal 8 supporting files (for example: .info.yml, .routing.yml etc) and update some of your module codes, and other main functionalities will be commented and provide a @FIXME comment along with it. So that you can easily findout the necessary fixes that the DMU can't do.

Now enable your module and fix the issues in Drupal 8 syntax. Also note that your .info or other Drupal 7 supporting files will be there which can be easily removed after fix(if it has no use) and completely upgrading your module codes. Now test your code.

Happy Coding!



on 21st May 2013 / by Anoop John
Drupal 6 will be maintained till the release of Drupal 8. Drupal 8 release is expected to happen towards the end of 2013. The current stable branch Drupal 7 will be maintained till the release of Drupal 9 (probably 2015). If you are running a production site on Drupal 6 then you will probably have to start looking at upgrading the site by the end of this year. Drupal Drupal 6 Drupal Upgrade Drupal 7 Drupal 8 Leave a reply Your email address will not be published. Required fields are marked *

on 26th December 2014 / by abhai.sasidharan
YAML is a data serialization language which is easily readable to both humans and computers. It is for this very reason that YAML is being used in Drupal 8. YAML stands for YAML Ain't Markup Language. Drupal Drupal 8 Leave a reply Your email address will not be published. Required fields are marked *

on 29th December 2014 / by abhai.sasidharan
Drupal, up until now a PAC (Presentation Abstraction Control) architecture, has taken a step closer to MVC (Model View Controller) architecture. Although nowhere have they mentioned about MVC, the new Drupal 8 is strictly object oriented. Another feature in Drupal 8, that is different from the existing versions of Drupal is that it is not entirely Drupal. Drupal 8 uses many components in symfony like it's ClassLoader, YAML file structure, twig and so on. For a detailed description please visit the Drupal 8 home page. Drupal Drupal 8 Leave a reply Your email address will not be published. Required fields are marked *
Leave a reply
Your email address will not be published. Required fields are marked *

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
The content of this field is kept private and will not be shown publicly.
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.