The 'environment only' mode, set by the C5_ENVIRONMENT_ONLY constant and frequently used by cron jobs, is also useful for 'Interactive mode' (php -a) users. Coming from the rails world I was very used to irb (and its invoker, "rails console") so for me it's quite handy to have an equivalent.
To set this up, create a new file to set up these variables. Save it as c5console.php
<?php define('DIR_BASE','.');
define('C5_ENVIRONMENT_ONLY',true);
include('index.php');
Then to run, you may set an alias in the shell's rc file (~/.bashrc if you use bash) to start the interactive mode shell with that file prepended, like so:
alias c5console='php -dauto_prepend_file=/path/to/c5console.php -a'
Alternatively, you could just run the above command directly. Next, execute from your concrete5 root directory (where index.php lives), and you can start testing concrete5 code in the console like so:
$ c5console
Interactive mode enabled
php > echo UserInfo::getByID(1)->getUserName() . "\n";
admin
Loading Conversation