Search code examples
phpconcrete5

In concrete5 how do you create a stand alone script that uses concrete5 built in models


I need to create a script that reads data on a concrete5 site. I do not want to create a new db connection or create a database connection outside of the concrete5 api environment. Is it possible to include some scripts from the concrete5 cms and somehow have access to the models so that I can access the data?


Solution

  • There are two ways.

    The simplest is via the web server (including a CURL request from the command line) to access a tools file. Check out the [root]/concrete/tools directory for examples. You'd put it in [root]/tools. Tools are much simpler than a single page, but get all the models loaded, etc.

    Otherwise, you can run from the command line. See http://www.concrete5.org/community/forums/documentation_efforts/how-to-running-concrete5-from-php-command-line/ . Same deal applies -- you'll get the basic models automatically, and you can use Loader::whatever() like normal.