Skip to content

Instantly share code, notes, and snippets.

@Dan-Q
Created August 19, 2016 10:41
Show Gist options
  • Save Dan-Q/6a86d73d468076b815be534c9b0e925f to your computer and use it in GitHub Desktop.
Save Dan-Q/6a86d73d468076b815be534c9b0e925f to your computer and use it in GitHub Desktop.
Concrete5 Console. Bash script (with embedded/self-referencing PHP script) to provide an interactive PHP console onto your Concrete5 installation. Place in Concrete5 directory, mark executable, and run.
#!/bin/bash
# Concrete5 Console<?php /*
cd `dirname $0`
php -dauto_prepend_file=`basename "$0"` -a
cd -
exit
*/
define('DIR_BASE','.');
define('C5_ENVIRONMENT_ONLY',true);
include('index.php');
@Dan-Q
Copy link
Author

Dan-Q commented Aug 19, 2016

This file is a polyglot. The first part of script (up to and including exit command) is Bash: switches to the directory of the script (which should be the Concrete5 installation directory) and then opens a PHP interactive session, first running itself. A PHP /*...*/ comment block limits as much as possible of the Bash code from being displayed as PHP output. The PHP code loads the Concrete5 environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment