Part Three - Add-Ons

Building an Extra From GitHub

gourmet fare

Build From GitHub

Sometimes you want to try out the latest version, or even the latest development version, of an extra, and it's not in the MODX respository. You can download it from GitHub and build its installable package yourself. From a Slack conversation.

sottwell asked...

I like ModxTalks but I have no idea how to build an extra from github, and the latest package in the repository is pretty old.

The Solution:

opengeek says...

you can generally just checkout the github package, add a config file to point at your core and run the build script — it’s a pain but not that difficult usually. It will generate the package in the core/packages dir and you can search locally and install it

What's the Story?

A properly set up GitHub repository will have a _build directory. All you need to do is download the zip file from GitHub, put the unzipped directory in a MODX installation's space, and edit its build.config.php file. You'll probably need to edit the MODX_BASE_PATH and MODX_BASE_URL settings. For example, on one of my localhost development installations, to build modxTalks I used:

/**
 * Define the MODX path constants necessary for installation
 *
 * @package modxtalks
 * @subpackage build
*/
define('MODX_BASE_PATH', '/Applications/MAMP/htdocs/blog.modx/');
define('MODX_CORE_PATH', MODX_BASE_PATH . 'core/');
define('MODX_MANAGER_PATH', MODX_BASE_PATH . 'manager/');
define('MODX_CONNECTORS_PATH', MODX_BASE_PATH . 'connectors/');
define('MODX_ASSETS_PATH', MODX_BASE_PATH . 'assets/');

define('MODX_BASE_URL', '/blog.modx/');
define('MODX_CORE_URL', MODX_BASE_URL . 'core/');
define('MODX_MANAGER_URL', MODX_BASE_URL . 'manager/');
define('MODX_CONNECTORS_URL', MODX_BASE_URL . 'connectors/');
define('MODX_ASSETS_URL', MODX_BASE_URL . 'assets/');

Then in my browser I went to localhost/blog.modx/modxTalks-develop/_build/build.transport.php. It ran the build and put the modxtalks-1.0.4-pl.transport.zip file in my MODX installation's core/packages directory. Then I just used the Installer, selecting the "Search Locally for Packages" option, to install it.

This kind of local file installation won't enable it to recognize any future updates from the MODX repository, though.