ddev / ddev-xhgui

XHGui service for a DDEV project
Apache License 2.0
12 stars 7 forks source link

Automate Drupal setup #33

Open tyler36 opened 6 months ago

tyler36 commented 6 months ago

This PR is an attempt to automate the steps for installtion on Drupal.

This address issues #30 .

Hopefully, this will trigger similar PRs for other frameworks when this is merge.

tyler36 commented 6 months ago

Was asked on slack

I ... wonder... can it just ask if you want to autoconfigure?

Thoughts?

rfay commented 6 months ago

It is possible to ask questions at install time, but it's tweaky. ddev-platformsh asks for config items (keys).

and

tyler36 commented 3 months ago

Hopefully, we can do something when ddev/ddev/pull/6406 gets merged.

sreichel commented 1 month ago

Mabe we can split this to make it work for all?

For Drupal it seems to be required to update the settings.php ... for OpenMage it would be enough to copy default settings - ddev.xhgui.php - to app/etc/includes path, thats autoloaded. I guess other frameworks have custom autoload paths too. (?)

For me this works perfect ... no need to edit Mage.php as i added to README :(

if (getenv('IS_DDEV_PROJECT') && getenv('NO_XHGUI') !== '1') {
    if (file_exists($xhgui = '/mnt/ddev_config/xhgui/collector/xhgui.collector.php')) {
        require_once $xhgui;
    }
}

Note: NO_XHGUI env

With having xhgui.collector included phpunit (9.6, php7.4) fails with ...

running testsSerialization of 'Closure' is not allowed

To fix, i added this to phpunit.xml.dist

    <php>
        <env name="NO_XHGUI" value="1"/>
    </php>
sreichel commented 1 month ago

@rfay why confused?

rfay commented 1 month ago

Sorry @sreichel , I don't understand your question or what it's referring to.

@rfay why confused?

sreichel commented 1 month ago

I asked why you reacted with a "confused" emoji.

rfay commented 1 month ago

I don't have very good vision. I thought it was a smiley.

sreichel commented 1 month ago

Made some suggestions. setup.sh needs to be updated, to switch project types ...i'll try to make PR later.

sreichel commented 1 month ago

Untested seetup.sh (drupal versions needs to be fixed)

#!/usr/bin/env bash
#ddev-generated
set -e

XHGUI_SETTINGS=ddev.xhgui.php

case $DDEV_PROJECT_TYPE in

  magento)
    # Copy over settings
    cp xhgui/scripts/$XHGUI_SETTINGS $DDEV_APPROOT/$DDEV_DOCROOT/app/etc/includes/
    ;;

  drupal | drupal)
    # Early return if disable_settings_management is true.
    if ( ddev debug configyaml 2>/dev/null | grep 'disable_settings_management:\s*true' >/dev/null 2>&1 ) ; then
      exit 0
    fi

    # Copy over settings
    cp xhgui/scripts/$XHGUI_SETTINGS $DDEV_APPROOT/$DDEV_DOCROOT/sites/default/

    # Add settings
    SETTINGS_FILE_NAME="${DDEV_APPROOT}/${DDEV_DOCROOT}/sites/default/settings.php"
    echo "Settings file name: ${SETTINGS_FILE_NAME}"
    grep -qF $XHGUI_SETTINGS $SETTINGS_FILE_NAME || echo "
    // Include settings required for XHGUI.
    if ((file_exists(__DIR__ . '/$XHGUI_SETTINGS') && getenv('IS_DDEV_PROJECT') == 'true')) {
      include __DIR__ . '/$XHGUI_SETTINGS';
    }" >> $SETTINGS_FILE_NAME
    ;;
  *)
    # echo -n "?"
    ;;
esac

# Add perftools/php-profiler
if ( ddev composer show --all | grep -v perftools/php-profiler >/dev/null 2>&1 ) ; then
  ddev composer require perftools/php-profiler --dev
fi
sreichel commented 2 weeks ago

Hopefully, this will trigger similar PRs for other frameworks when this is merge

Can i help?

stasadev commented 1 week ago

Hi @sreichel,

Thank you for your suggestion. We apologize for the delay in addressing your changes. The maintainer is currently unavailable but is expected to return in about a week. Your patience is greatly appreciated!