Skip to content

Instantly share code, notes, and snippets.

@nullvariable
Created May 7, 2019 21:08
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 nullvariable/437a1a5c84cf8645256c419435379b35 to your computer and use it in GitHub Desktop.
Save nullvariable/437a1a5c84cf8645256c419435379b35 to your computer and use it in GitHub Desktop.
Use typerocket with root composer.json
{
"require": {
"typerocket/core": "4.0.*"
},
"scripts": {
"typerocket-migrate": [
"php ./wp-content/mu-plugins/typerocket/galaxy migrate up"
]
}
}
<?php
// ** /wp-content/mu-plugins/typerocket/init.php
define( 'TR_APP_NAMESPACE', 'App' );
define( 'TR_PATH', __DIR__ );
new \TypeRocket\Core\Config( __DIR__ . '/config' );
if ( defined( 'WPINC' ) ) {
( new \TypeRocket\Core\Launcher() )->initCore();
}
<?php
// ** /wp-content/mu-plugins/loader.php
/**
* MU Loader
*
* Plugin Name: TypeRocket MU Loader
* Description: Load TypeRocket
* Version: 2.0.0
* License: GPL2
*
* @package mu-loader
*/
// Load TypeRocket and TypeRocket centric code.
if ( ! defined( 'TR_APP_NAMESPACE' ) ) {
require WP_CONTENT_DIR . '/vendor/autoload.php';
require 'typerocket/init.php';
add_action(
'typerocket_loaded',
function() {
// Any custom code you need to run after TR is loaded
}
);
// In some hosting environments we can't run the galaxy command. This adds galaxy as a WP CLI command.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command(
'galaxy',
function () {
$count = count( $_SERVER['argv'] );
for ( $i = 0; $i < $count; $i++ ) {
// strip any preceeding arguments so galaxy isn't confused.
$arg = array_shift( $_SERVER['argv'] );
if ( 'galaxy' == $arg ) {
array_unshift( $_SERVER['argv'], 'galaxy' );
break;
}
}
new \TypeRocket\Console\Launcher();
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment