Table of Contents
If you’re using a theme or plugin that requires Composer, it will likely result in a fatal error on activation. The popular Breakdance builder plugin uses Composer, and this article will walk you through how to use Composer with our Git integration using Breakdance as an example. The script provider can be adjusted to work with any plugin that requires Composer to function.
The Fatal Error
This following fatal error example is because when Breakdance is deployed via Git, you will need to use composer via the deploy scripts to install its dependencies. It looks as follows:
This is the error that it is showing: Fatal error: Uncaught Error: Class 'Breakdance\Lib\Vendor\Whoops\Handler\Handler' not found in /var/www/example.com/htdocs/wp-content/plugins/breakdance/plugin/error-reporter/error-reporter-ajax-handler.php:12 Stack trace: #0 /var/www/example.com/htdocs/wp-content/plugins/breakdance/plugin/error-reporter/base.php(5): require_once() #1 /var/www/example.com/htdocs/wp-content/plugins/breakdance/plugin/base.php(7): require_once('/var/www/exampl...') #2 /var/www/example.com/htdocs/wp-content/plugins/breakdance/plugin.php(36): require_once('/var/www/exampl...') #3 /var/www/example.com/htdocs/wp-settings.php(447): include_once('/var/www/exampl...') #4 /var/www/example.com/wp-config.php(140): require_once('/var/www/exampl...') #5 /var/www/example.com/htdocs/wp-load.php(55): require_once('/var/www/exampl...') #6 /var/www/example.com/htdocs/wp-blog-header.php(13): require_once('/var/www/exampl...') #7 /var/www/example.com/htdocs/index.php(17): require('/var/www in /var/www/example.com/htdocs/wp-content/plugins/breakdance/plugin/error-reporter/error-reporter-ajax-handler.php on line 12
Our Git integration offers multiple deployment scripts that can be run before or after deploying your Git repositories. There are two predeploy scripts and two postdeploy scripts, and these can can be added to the
gpconfig directory inside your repo like so:
These are bash scripts, and we’ll be using the
predeploy-server.sh. This will run prior to the Git pull. More information on all of these scripts can be found here:
An Overview of GridPane Git Options: Full and Hybrid Repo Types
Breakdance Predeploy-server Script
Add the following to your
#!/bin/bash timeout 300 wget https://getcomposer.org/download/2.5.4/composer.phar timeout 300 chmod 755 $GP_GIT_RELEASE_PATH/wp-content/plugins/breakdance/plugin/vendor/bin/mozart export COMPOSER_ALLOW_SUPERUSER=1 timeout 300 php composer.phar update -n --working-dir=$GP_GIT_RELEASE_PATH/wp-content/plugins/breakdance/plugin/ timeout 300 php composer.phar install -n --working-dir=$GP_GIT_RELEASE_PATH/wp-content/plugins/breakdance/plugin/
Push the changes, and Breakdance should now activate and operate as expected.
If you receive a shellcheck error after deploying your repo with the above script present, this will be due to a formatting issue.
/var/www/breakdance.test/releases/release-1678189338/.gpconfig/predeploy-server.sh failed a shellcheck
Running a Shellcheck
To confirm the reason for the shellcheck error, you can copy the given path and run the following:
shellcheck --exclude="SC2145,SC2068,SC2261,SC2086,SC2034" "/path/to/predeploy-server.sh"
shellcheck --exclude="SC2145,SC2068,SC2261,SC2086,SC2034" "/var/www/breakdance.test/releases/release-1678189338/.gpconfig/predeploy-server.sh"
You’ll likely see the following:
^-- SC1017: Literal carriage return. Run script through tr -d '\r' .
To fix the issue do the following:
- Copy and paste the above script into a simple text file
- Delete the contents of your predeploy-server script
- Copy and paste the contents out of your text file back into your predeploy-server script and save.
This should remove any unexpected formatting that’s causing the shellcheck failure.