I'm writing an import script to add some external content to a C5 installation.
I'm unsure which file(s) I need to include in order to get the C5 API available (without any action like loading a page)?
/concrete/dispatcher.php
does a truckload of initializations, but I'm unsure which ones are required. Just including dispatcher.php
causes the script to navigate to the installation dialog.
Is there a canonical way to initialize C5 in an external tool? I can't find any in the developer docs.
There is a C5_ENVIRONMENT_ONLY
constant you can define, after which you can include the "index.php" file to get the c5 system without having it serve a specific page or theme.
<?php
define('C5_ENVIRONMENT_ONLY', true);
include("index.php");
//C5 should be loaded now, so you can interact with the API...
I just tested this out on the latest version (5.6.1) and it worked just fine -- I was able to query the database via Loader::db(), and able to interact with logged-in user object (global $u). So I assume if those 2 things worked then anything would work.
I did find these 2 forum threads from a while ago:
...which indicate you also need to declare the DIR_BASE
constant... but this may be an old requirement because I got my tests to run just fine without it.