Bootstrap Craft from another app Is there any known way to bootstrap Craft to use the core functions inside another application? For example, in Magento anyone can include a file, initialize the app and use all the functions from there.
This is exactly what i am trying to achieve but in Craft.
Thank you!
Craft’s bootstrap file in located at craft/app/index.php. Importing that will get you 99% of the way there.

The only problem is, index.php not only loads Craft, it also runs it. In doing so, Craft is going to insist that it completely resolves the request, with a response to the browser.

I’m thinking we should move most of that code into a new bootstrap.php file, with the only exception being the last line:

$app-&gt;run();


Then index.php would simply import bootstrap.php and call $app-&gt;run() itself. That way you could import bootstrap.php rather than index.php, and do whatever you want with the app, like fetch entries, without losing control over the whole request.

In the meantime, you could copy the contents, sans $app-&gt;run(), of index.php into your own file and import that instead. You’d need to go through it and update all of the paths, too.

Another option would be to make Craft think the page should be a 404, and catch the 404 exception:

// Make it look like a 404
$_GET['p'] = "some/invalid/path";

// Import Craft, catching the 404
try
{
    require 'path/to/craft/app/index.php';
}
catch (\Craft\HttpException $e){}

// ...


Little hacky, but that may be your cleanest option until we give you a bootstrap.php file to import instead.

UPDATE

As of Craft 2.2, Craft now ships with a bootstrap.php file which handles all of the app initialization stuff with the exception of actually calling run().

When you include bootstrap.php(), a new Craft application will be returned.

$craft = require 'craft/app/bootstrap.php';