Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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