Skip to content

Instantly share code, notes, and snippets.

@dsnopek
Last active February 12, 2019 20:34
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dsnopek/56311dbea347874e75180883efabb620 to your computer and use it in GitHub Desktop.
Save dsnopek/56311dbea347874e75180883efabb620 to your computer and use it in GitHub Desktop.
################################
# _ _ _ #
# /\ | | | | | | #
# / \ | | ___ _ __| |_| | #
# / /\ \ | |/ _ \ '__| __| | #
# / ____ \| | __/ | | |_|_| #
# /_/ \_\_|\___|_| \__(_) #
# #
################################
#
# This is no longer the recommend way to get a Drupal 8 and CiviCR
# codebase assembled!
#
# Please see this article for the currently recommend way:
#
# https://www.mydropwizard.com/blog/better-way-install-civicrm-drupal-8
#
# Below is the previous contents of this Gist...
#
#
# One day, hopefully, in the not-so-distant future, all that will be necessary is:
#
# composer require civicrm/civicrm-core
#
# But for now, the following commands will do the trick!
#
# NOTE: These command should all be run at the top-level Drupal directory.
#
# What version do we want?
CIVICRM_VERSION=5.3.1
# Repositories aren't inherited from requirements, so we have to put this one from civicrm-core/composer.json again
composer config repositories.zetacomponents-mail vcs https://github.com/civicrm/zetacomponents-mail.git
#
# RE-RUN THE COMMANDS BELOW TO UPGRADE CIVICRM (after first changing $CIVICRM_VERSION)
#
# (NOTE: if you do an upgrade, remember to do the database updates on the site afterward
# via /civicrm/upgrade?reset=1 or 'drush cvupdb')
#
# Require civicrm-core at the requested version.
composer require "civicrm/civicrm-core:$CIVICRM_VERSION"
# Run 'bower install' to get Javascript stuff
(cd vendor/civicrm/civicrm-core && bower install)
# Download the latest Drupal package to copy some stuff that's
# generated by the build and included in release tarballs.
wget -O /tmp/civicrm.tar.gz https://download.civicrm.org/civicrm-$CIVICRM_VERSION-drupal.tar.gz
tar -xzf /tmp/civicrm.tar.gz -C /tmp
# Copy the 3rd party dependencies (Whaaaat? Someone who's been doing CiviCRM for a while
# will need to explain this to me :-) Why not use composer for pulling in these too?)
cp -r /tmp/civicrm/packages vendor/civicrm/civicrm-core/
# Setup the civicrm-version.php
cat /tmp/civicrm/civicrm-version.php | sed -e 's/Drupal/Drupal8/' > vendor/civicrm/civicrm-core/civicrm-version.php
# Copy sql
cp -r /tmp/civicrm/sql vendor/civicrm/civicrm-core/
# Copy some misc other things
cp /tmp/civicrm/civicrm.config.php vendor/civicrm/civicrm-core/
cp /tmp/civicrm/CRM/Core/I18n/SchemaStructure.php vendor/civicrm/civicrm-core/CRM/Core/I18n/
cp /tmp/civicrm/install/langs.php vendor/civicrm/civicrm-core/install/
# Clean-up
rm -rf /tmp/civicrm.tar.gz /tmp/civicrm
@jptillman
Copy link

jptillman commented Nov 29, 2018

Just tried running this script and got the following output and errors on a Drupal source directory that was created via the standard composer template project (https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies#download-core).

Looks like there are some version conflicts. Any tips on how to resolve?

./composer.json has been updated
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositorUpdating dependencies (including require-dev)         Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - civicrm/civicrm-core 5.3.1 requires civicrm/civicrm-cxn-rpc ~0.17.07.01 -> satisfiable by civicrm/civicrm-cxn-rpc[v0.17.07.01].
    - Installation request for civicrm/civicrm-core 5.3.1 -> satisfiable by civicrm/civicrm-core[5.3.1].
    - Conclusion: remove psr/log 1.1.0
    - Conclusion: don't install psr/log 1.1.0
    - civicrm/civicrm-cxn-rpc v0.17.07.01 requires psr/log ~1.0.0 -> satisfiable by psr/log[1.0.0, 1.0.1, 1.0.2].
    - Can only install one of: psr/log[1.0.0, 1.1.0].
    - Can only install one of: psr/log[1.0.1, 1.1.0].
    - Can only install one of: psr/log[1.0.2, 1.1.0].
    - Installation request for psr/log (locked at 1.1.0) -> satisfiable by psr/log[1.1.0].


Installation failed, reverting ./composer.json to its original content.

@mlutfy
Copy link

mlutfy commented Jan 8, 2019

@jptillman (or others running into this): run composer require psr/log:1.0 --update-no-dev

Waiting for this to be merged: civicrm/civicrm-cxn-rpc#8

@mlutfy
Copy link

mlutfy commented Jan 8, 2019

I posted a recap of blocking issues (and links to various resources) here: https://lab.civicrm.org/dev/drupal/wikis/drupal8-composer

@sleidig
Copy link

sleidig commented Feb 6, 2019

regarding the conflicting psr/log requirement:

As it seems the dependency is about to be updated to 1.1 anyway, another workaround is to set an alias in your (drupal) composer.json to "fake" 1.1 to be accepted for 1.0.0 by changing"require": { "psr/log": "^1.1"} to "require": { "psr/log": "1.1.0 as 1.0.0"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment