Skip to content

Instantly share code, notes, and snippets.

@nikathone
Last active March 6, 2019 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikathone/4d2be4ba1c59a6964fb815ab5156d6ed to your computer and use it in GitHub Desktop.
Save nikathone/4d2be4ba1c59a6964fb815ab5156d6ed to your computer and use it in GitHub Desktop.
Moving an existing Drupal site to composer workflow

Old site:
drush sql-dump to backup database
New site:
composer create-project drupal-composer/drupal-project:8.x-dev newsitefolder --prefer-dist --no-progress --no-interaction
cd newsitefolder
composer require <all of your modules here, as drupal/whatever>

If running SELinux on CentOS, on others it may be a different context
chcon -R -t httpd_sys_content_rw_t web
$ pwd
/path/to/newsitefolder
$ cd web/sites
$ mv default default_orig
$ cp -R /path/to/oldsite/sites/default ./
$ diff -r -u default_orig default | less

make changes needed to files in default -- mine was mostly some changes around "container_ymls" key locations
make sure not to change things like the sync folder, etc.
$ tar czf default_orig.tgz default_orig
$ rm -r default_orig

check all of the permissions on various folders / files here: make sure files and subfolders are readable/writeable as appropriate; in particular the sync folder, whatever it is, should be writable by your webserver!
$ chmod -R u+r,g+w /path/to/newsitefolder/web/sites/default/files
Suggested, at this point, to make a git repository, so that you can track changes to stuff...
$ pwd
/path/to/newsitefolder
$ git init
I added a few lines to the existing .gitignore:
$ cat <<EOTXT >>.gitignore

```# ignore custom themes  
web/themes/custom  
# ignore custom modules  
web/modules/custom  
EOTXT```  

$ git add .gitignore
$ git commit -m ".gitignore"
$ git add .
$ git commit -m "initial commit"
I needed to update .htaccess, to fix my rewrite base, then
$ git commit -a -m "fix rewrite base"
I also had to update my webserver configuration to point to the new site, and then restart the server.
Then, go to reports > status log, and fix errors (possibly due to permissions issues).

Some useful URLs:
* https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies
* http://weknowinc.com/talks/2016/drupalgov-workflow/#/
* https://glamanate.com/blog/managing-your-drupal-project-composer
* https://www.jeffgeerling.com/blog/2018/converting-non-composer-drupal-codebase-use-composer

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