Skip to content

Instantly share code, notes, and snippets.

@anavdesign
Last active July 20, 2019 14:51
Show Gist options
  • Save anavdesign/5640570ac4ec07837e51d9d402ba84e7 to your computer and use it in GitHub Desktop.
Save anavdesign/5640570ac4ec07837e51d9d402ba84e7 to your computer and use it in GitHub Desktop.
Drupal: Composer Instal

Drupal Composer Install

Drupal Install

  1. Move into the project folder

    cd ~/www/sites/FolderName
    
  2. Composer template for Drupal projects https://github.com/drupal-composer/drupal-project

    Run Composer Create

    composer create-project drupal-composer/drupal-project:8.x-dev drupal --stability dev --no-interaction
    

    Or Use Shortcut

    dcc
    
  3. Drush Site Install https://drushcommands.com/drush-9x/site/site:install/

    1. Make Directories

      mkdir backup && mkdir notes && mkdir project
      
    2. Change Directory

      cd drupal
      
    3. Drush Site Install

      drush si standard --db-url=mysql://root:root@127.0.0.1/SITENAME_loc --account-mail="noreply@email.com" --account-name=admin --account-pass=admin --site-mail="noreply@email.com" --site-name="SITE NAME" -y
      

      Or Use Drush Site Install Shortcut

      dsi DBNAME
      

      Append subdirectory name to Drush si for a multisite install

      --sites-subdir=SUBDIRNAME
      

      Site Intall Options

      • si ( site-install )
      • profile_name ( the install profile you wish to run )
      • -v ( Verbose )
      • -y ( Assume yes to all prompts )
      • --account-mail=admin@example.com ( Defaults to admin@example.com )
      • --account-name=admin ( Defaults to admin )
      • --account-pass=admin ( Defaults to a randomly generated password )
      • --db-url=mysql://root:root@localhost/drupal ( Install using the specified DB params or create new database )
      • --site-mail ( From: for system mailings. Defaults to admin@example.com )
      • --site-name ( Defaults to Site-Install )
      • --sites-subdir ( Subdirectory Name for multisite installation )

      additional si options can be found @ https://drushcommands.com/drush-8x/core/site-install/

  4. Create Symbolic Link to Site Directory

    cd ../ && ln -s drupal/web/ www
    
  5. Create Sublime Project

    1. Project > Save Project As... > siteName.sublime-project

    2. Update Drupal Sublime Project

      {
          "folders":
          [
              {
                  "name": "Drupal",
                  "path": "../drupal",
                  "folder_exclude_patterns": [
                      "notes",
                      "drupal/web/sites",
                      "drupal/web/modules",
                      "drupal/web/themes",
                      "drupal/web/libraries",
                  ],
              },
              {
                  "name": "Sites",
                  "path": "../drupal/web/sites"
              },
              {
                  "name": "Theme",
                  "path": "../drupal/web/themes/custom/THEME_NAME",
                  "folder_exclude_patterns": [
                      "app",
                      "templates",
                  ],
              },
              {
                  "name": "- Templates",
                  "path": "../drupal/web/themes/custom/THEME_NAME/templates"
              },
              {
                  "name": "App",
                  "path": "../drupal/web/themes/custom/THEME_NAME/app",
                  "folder_exclude_patterns": [
                      "js",
                      "sass",
                      "svg",
                  ],
              },
              {
                  "name": "- JS",
                  "path": "../drupal/web/themes/custom/THEME_NAME/app/js"
              },
              {
                  "name": "- SASS",
                  "path": "../drupal/web/themes/custom/THEME_NAME/app/sass"
              },
              {
                  "name": "Contrib Themes",
                  "path": "../drupal/web/themes/contrib/",
              },
              {
                  "name": "Modules",
                  "path": "../drupal/web/modules"
              },
              {
                  "name": "Libraries",
                  "path": "../drupal/web/libraries"
              },
              {
                  "name": "Project Root",
                  "path": "../",
                  "folder_exclude_patterns": [
                      "drupal"
                  ],
                  "follow_symlinks": false,
              }
          ],
          "settings":
          {
              "tab_size": 2
          }
      }
      
      
      
  6. Install Contributed Modules

    TODO: Create Installation Profile to include all base modules

    Change to Project Root Direcotry

    cd drupal/
    

    Install Contributed Modules

    composer require drupal/admin_toolbar drupal/block_class drupal/block_visibility_groups drupal/coffee drupal/color_field drupal/devel drupal/eck drupal/entity_reference_revisions drupal/eu_cookie_compliance drupal/features drupal/field_group drupal/filefield_paths drupal/google_analytics drupal/google_analytics_reports drupal/honeypot drupal/iframe drupal/image_effects drupal/image_url_formatter drupal/inline_entity_form drupal/metatag drupal/module_filter drupal/pathauto drupal/rabbit_hole drupal/redirect drupal/responsive_favicons drupal/token_custom drupal/token_embed_views drupal/token_filter drupal/twig_tweak drupal/video_embed_field drupal/viewsreference drupal/xmlsitemap drupal/yoast_seo;
    
  7. Additional Contrib Modules

    composer require drupal/address;
    composer require drupal/auto_entitylabel;
    composer require drupal/computed_field;
    composer require drupal/contact_block;
    composer require drupal/content_access;
    composer require drupal/custom_search;
    composer require drupal/ds;
    composer require drupal/front;
    composer require drupal/imce;
    composer require drupal/login_destination;
    composer require drupal/markdown;
    composer require drupal/menu_block;
    composer require drupal/menu_item_role_access;
    composer require drupal/modal_page;
    composer require drupal/prepopulate;
    composer require drupal/profile;
    composer require drupal/sharethis;
    composer require drupal/special_menu_items;
    composer require drupal/taxonomy_menu;
    composer require drupal/userprotect;
    
    

Install Libraries

  1. Color Field

    1. Edit the composer.json file of your website and under the repositories: { section add:

      {
          "type": "package",
          "package": {
              "name": "recurser/jquery-simple-color",
              "version": "master",
              "type": "drupal-library",
              "source": {
                  "url": "https://github.com/recurser/jquery-simple-color.git",
                  "type": "git",
                  "reference": "master"
              }
          }
      },
      {
          "type": "package",
          "package": {
              "name": "bgrins/spectrum",
              "version": "1.8.0",
              "type": "drupal-library",
              "source": {
                  "url": "https://github.com/bgrins/spectrum.git",
                  "type": "git",
                  "reference": "1.8.0"
              }
          }
      },
      
    2. Run Composer Require

      composer require recurser/jquery-simple-color bgrins/spectrum;
      
  2. Webform

    https://www.drupal.org/node/3003140

    1. Edit the composer.json file of your website and under the extra: { section add:

      "merge-plugin": {
          "include": [
              "web/modules/contrib/webform/composer.libraries.json"
          ]
      }
      
    2. The merging is accomplished by the aid of the Composer Merge Plugin plugin, from project root run:

      composer require drupal/webform wikimedia/composer-merge-plugin;
      
    3. Run Composer Update

      composer update
      
    4. Add webform private files directory to sites/default/settings.php

      $settings['file_private_path'] = 'sites/default/files/private';
      
    5. Create Private Files DIrectory

      mkdir web/sites/default/files/private
      
  3. Magnific Popup

    https://www.drupal.org/project/magnific_popup/issues/2857287

    1. Edit the composer.json file of your website and under the repositories: { section add:

      {
          "type": "package",
          "package": {
              "name": "dimsemenov/magnific-popup",
              "version": "1.1.0",
              "type": "drupal-library",
              "source": {
                  "url": "https://github.com/dimsemenov/Magnific-Popup.git",
                  "type": "git",
                  "reference": "1.1.0"
              }
          }
      }
      
    2. Run Composer Require

      composer require drupal/magnific_popup dimsemenov/magnific-popup;
      
  4. Slick Slider

    1. Edit the composer.json file of your website and under the repositories: { section add:

      {
          "type": "package",
          "package": {
              "name": "kenwheeler/slick",
              "version": "1.8.0",
              "type": "drupal-library",
              "source": {
                  "url": "https://git@github.com/kenwheeler/slick.git",
                  "type": "git",
                  "reference": "1.8.0"
              }
          }
      },
      {
          "type": "package",
          "package": {
              "name": "gdsmith/easing",
              "version": "1.4.1",
              "type": "drupal-library",
              "source": {
                  "url": "https://github.com/gdsmith/jquery.easing.git",
                  "type": "git",
                  "reference": "1.4.1"
              }
          }
      },
      {
          "type": "package",
          "package": {
              "name": "dinbror/blazy",
              "version": "1.8.2",
              "type": "drupal-library",
              "source": {
                  "url": "https://github.com/dinbror/blazy.git",
                  "type": "git",
                  "reference": "1.8.2"
              }
          }
      }
      
    2. Run Composer Require

      composer require drupal/slick drupal/slick_entityreference drupal/slick_views kenwheeler/slick gdsmith/easing dinbror/blazy;
      
  5. Chosen

    https://www.drupal.org/project/chosen

    1. Edit the composer.json file of your website and under the repositories: { section add:

      {
          "type": "package",
          "package": {
              "name": "harvesthq/chosen",
              "version": "1.8.2",
              "type": "drupal-library",
              "dist": {
                  "url": "https://github.com/harvesthq/chosen/releases/download/v1.8.2/chosen_v1.8.2.zip",
                  "type": "zip"
              },
              "require": {
                  "composer/installers": "^1.2.0"
              }
          }
      }
      
    2. Run Composer Require

      composer require harvesthq/chosen drupal/chosen;
      

Uninstall Contrib Modules

/admin/modules/uninstall

  1. unistall contact module
drush pmu contact

Install Contrib Modules

/admin/modules

  1. admin_toolbar
  2. admin_toolbar_tools
  3. block_class
  4. block_visibility_groups
  5. chosen
  6. chosen_lib
  7. coffee
  8. color_field
  9. eck
  10. entity_reference_revisions
  11. eu_cookie_compliance
  12. features
  13. features_ui
  14. field_group
  15. filefield_paths
  16. honeypot
  17. image_effects
  18. image_url_formatter
  19. inline_entity_form
  20. magnific_popup
  21. metatag
  22. module_filter
  23. pathauto
  24. rabbit_hole
  25. redirect
  26. responsive_favicons
  27. rh_node
  28. slick
  29. slick_entityreference
  30. slick_ui
  31. slick_views
  32. token
  33. token_custom
  34. token_embed_views
  35. token_filter
  36. twig_tweak
  37. video_embed_field
  38. viewsreference
  39. webform
  40. webform_ui
  41. xmlsitemap
  42. yoast_seo
drush en admin_toolbar admin_toolbar_tools block_class block_visibility_groups chosen chosen_lib coffee color_field eck entity_reference_revisions eu_cookie_compliance features features_ui field_group filefield_paths honeypot image_effects image_url_formatter inline_entity_form magnific_popup metatag module_filter pathauto rabbit_hole redirect responsive_favicons rh_node slick slick_entityreference slick_ui slick_views token token_custom token_embed_views token_filter twig_tweak video_embed_field viewsreference webform webform_ui xmlsitemap yoast_seo -y;

Custom Modules & Theme Installer Paths

Edit the composer.json file of your website and under the extra > installer-paths section add:

"web/modules/custom/{$name}": ["type:drupal-custom-module"],
"web/themes/custom/{$name}": ["type:drupal-custom-theme"]


Install Custom Modules

Landing Page

Edit the composer.json file of your website and under the repositories: { section add:

{
    "type": "package",
    "package": {
        "name": "anavdesign/landing-page",
        "version": "master",
        "type": "drupal-custom-module",
        "source": {
            "url": "https://github.com/anavdesign/andesign-drupal-landing-page.git",
            "type": "git",
            "reference": "master"
        }
    }
},

Run Composer Require

composer require anavdesign/landing-page

Eanble Module

drush en landing-page -y

Set Drupal File Permissions

sudo find web/ -type d -exec chmod 755 {} \;
sudo find web/ -type f -exec chmod 644 {} \;
sudo chmod 444 web/.htaccess;
sudo chmod 555 web/sites/default/;
sudo chmod 744 web/sites/default/settings.php;
sudo find web/sites/default/files -type d -exec chmod 775 {} \;
sudo find web/sites/default/files -type f -exec chmod 644 {} \;

Increase PHP Memory

  1. Append to .htacecss file in drupal root directory
    # PHP Settings
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value memory_limit 64M
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment