Skip to content

sergsu/kalabox-app-pantheon

 
 

Repository files navigation

Kalabox Pantheon App

Overview

By default Kalabox can pull apps from and push apps to Pantheon... but this is much more than basic push/pull integration. Kalabox will build out a local Pantheon environment for each app. This means solr, redis, ssl and terminus all work just like they do on Pantheon. You can also use drush, wp-cli, ssl and toggle php version. YAY!

Creating and starting a Pantheon app

This will spin up a Pantheon-on-Kalabox environment, set up relevant tools like terminus, drush and wp-cli and pull down the site and environment that you choose.

cd /dir/i/want/my/app/to/live (usually ~/Desktop/apps)
kbox create pantheon
? Choose a Pantheon account. [email protected]
? Which site? kalabox-eight
? Which environment? dev
? What will you call this monster you have created: (kalabox-eight) eight
cd eight
kbox start # Site is available at http(s)://eight.kbox

Tools and working with your code

You can run various Pantheon-helpful tools like terminus.

Global commands that can be run from anywhere
  apps             Display list of apps.
  create       
      pantheon     Creates a Pantheon app.
  update           Run this after you update your Kalabox code.
  version          Display the kbox version.

Actions that can be performed on this app
  config           Display the kbox application's configuration.
  containers       Display list of application's installed containers.
  destroy          Completely destroys and removes an app.
  pull             Pull down new code and optionally data and files.
  push             Push up new code and optionally data and files.
  rebuild          Rebuilds your app while maintaining your app data.
  restart          Stop and then start a running kbox application.
  start            Start an installed kbox application.
  stop             Stop a running kbox application.

Commands and tools this app can use
  drush            Run drush commands.
  git              Run git commands.
  rsync            Run rsync commands.
  terminus         Run terminus commands.
  wp               Run wp-cli commands.

Pulling from Pantheon

You can refresh your local code and even your database and files by running kbox pull from inside of your Pantheon app. This will pull from the environment you specify during kbox create.

kbox pull -- -h
Options:
  -h, --help     Display help message.                                 [boolean]
  -v, --verbose  Use verbose output.                                   [boolean]
  --database     Import latest database backup.                        [boolean]
  --files        Import latest files.                                  [boolean]

Pushing to Pantheon

You can easily push up code and even your database and files by running kbox push. This will push to the environment you specified during kbox create.

kbox push -- -h
Options:
  -h, --help     Display help message.                                 [boolean]
  -v, --verbose  Use verbose output.                                   [boolean]
  --message      Tell us about your change                              [string]
  --database     Push local database up.                               [boolean]
  --files        Push local files up.                                  [boolean]

SSL

You can use https by just typing in https://myapp.kbox in your browser. We self-sign the certs so you will need to allow this in your browser.

SOLR

Apache Solr comes in each local Pantheon environment. You can use it the exact same way as you do on Pantheon. Reference the Pantheon docs for more information.

Redis

Just follow the same instructions from Pantheon to get redis to work locally. https://pantheon.io/docs/articles/sites/redis-as-a-caching-backend/

The TL;DR for Drupal 7 here is

  1. Install the redis module.
  2. Use this code snippet in settings.php
// All Pantheon Environments.
if (defined('PANTHEON_ENVIRONMENT')) {
  // Use Redis for caching.
  $conf['redis_client_interface'] = 'PhpRedis';
  $conf['cache_backends'][] = 'sites/all/modules/redis/redis.autoload.inc';
  $conf['cache_default_class'] = 'Redis_Cache';
  $conf['cache_prefix'] = array('default' => 'pantheon-redis');
  // Do not use Redis for cache_form (no performance difference).
  $conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
  // Use Redis for Drupal locks (semaphore).
  $conf['lock_inc'] = 'sites/all/modules/redis/redis.lock.inc';
}

Xdebug

xdebug is set up on your php appserver. Here is an example SublimeText 2 config (similar settings have been tested on Codebug, Eclipse, and other debugging tools). Note that you may need to launch it in the browser the first time using XDEBUG_SESSION_START=1 as a query parameter (ex: http://my-app.kbox/some-page?XDEBUG_SESSION_START=1). If breakpoints aren't working in your debugger, try inserting xdebug_break() in your code.

{
  "folders":
  [
    {
      "path": "/local/path/to/my/code"
    }
  ],
  "settings":
  {
    "xdebug":
    {
      "max_children": 32,
      "max_depth": 16,
      "pretty_output": true,
      "path_mapping":
      {
        "/code/": "/local/path/to/my/code/"
      },
      "port": 9000,
      "url": "http://mysite.kbox/"
    }
  }
}

Other Resources


(C) 2015 Kalamuna and friends

About

Kalabox app that emulates the pantheon env.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 84.0%
  • Shell 12.5%
  • PHP 2.4%
  • Nginx 1.1%