<p>Craig, I really don't know much directly about this, but it occurred to me to look at the ConsoleApp, which is used in one normal way to run Craft headless (from yiic on command line). It's in app/etc/console/ConsoleApp.php.</p>

<p>A little hunting around with PhpStorm, excellent for this sort of thing as others, turns up that ConsoleApp is loading plugins, and I think it will be loading things like Assets through the loadEditionComponents call -- edition checks out to mean Craft Edition, as Personal, Client, Pro, etc. by your license -- so that S3 might be available for Assets, and so forth.</p>

<p>Just what you would need to do, haven't time to go further on. You might find just calling ConsoleApp->run() would do, or may have to make a modified version of ConsoleApp, but seems it might make a good scaffold in that case.</p>

<p>Good fortune on this; interested to know what you work out.</p>

CC BY-SA 3.0
2016-06-15T14:04:50.137Z
Thanks so much! I'll check into this! That sounds like a good place to start!
Incraigulous
CC BY-SA 3.0
2016-06-15T15:53:04.697Z
I did a little bit of playing around. I can't simply run the console application because it checks to make sure it's a console app and fails. I think I would have to actually crete a new application class that extends CApplication that doesn't include request handling. I'm not sure exactly how to do that yet, but hopefully I can find something in ConsoleApp that will tell me.
Incraigulous
CC BY-SA 3.0
2016-06-17T06:48:52.227Z
Actuallly, I had a look at the 'Related' SEs over on the right, and the first one looks like it has what you need, per Craft CEO/co-creator Brandon Kelley.: http://craftcms.stackexchange.com/questions/608/bootstrap-craft-from-another-app. You can see if this gets you there...
narration_sd
CC BY-SA 3.0
2016-06-14T05:10:39.823Z
2016-06-14T05:16:09.170Z
2016-06-14T05:16:09.170Z
narration_sd
<p>I’m trying to bootstrap Craft as a service inside of another framework (lumen). I’m requiring the bootstrap file which seems to get me up and running except that plugins and assets aren’t included in the EntryModel results.</p>

<p>I’m requiring Craft like this:</p>

<p><code>
$craft = require_once base_path().'/../craft/app/bootstrap.php'; 
$this-&gt;app-&gt;singleton('Craft', function() use ($craft) { <br>
    return $craft;
 });
</code></p>

<p>and then getting my EntryModel like this:</p>

<p><code>
$criteria = app()-&gt;make('Craft')-&gt;elements-&gt;getCriteria(ElementType::Entry);
 $criteria-&gt;section = 'emails'; 
$criteria-&gt;slug = 'tuition-agreement-link'; 
$email = $criteria-&gt;first();
</code></p>

<p>Text content returns perfectly, but asset fields return <code>null</code>. The one thing I can see that craft/app/index.php does differently than me is calling $app->run() (since I'm not actually trying to run the full blown app with request routing). Anyone know if there is an additional step I can take to bootstrap assets and plugins without running the full blown app? Am I trying to do the impossible?</p>

<bootstrap-craft>
Using Craft inside Lumen / Laravel
# Using Craft inside Lumen / Laravel

(Asked by: username_0 on 2016-06-13)

I’m trying to bootstrap Craft as a service inside of another framework (lumen). I’m requiring the bootstrap file which seems to get me up and running except that plugins and assets aren’t included in the EntryModel results.

I’m requiring Craft like this:

`$craft = require_once base_path().'/../craft/app/bootstrap.php'; 
$this->app->singleton('Craft', function() use ($craft) {   
return $craft;
 });`

and then getting my EntryModel like this:

`$criteria = app()->make('Craft')->elements->getCriteria(ElementType::Entry);
 $criteria->section = 'emails'; 
$criteria->slug = 'tuition-agreement-link'; 
$email = $criteria->first();`

Text content returns perfectly, but asset fields return `null`. The one thing I can see that craft/app/index.php does differently than me is calling $app->run() (since I'm not actually trying to run the full blown app with request routing). Anyone know if there is an additional step I can take to bootstrap assets and plugins without running the full blown app? Am I trying to do the impossible?

**Tags:** bootstrap-craft

---

## 1 answers

### Answer by username_1 on 2016-06-14. Score: 1

Craig, I really don't know much directly about this, but it occurred to me to look at the ConsoleApp, which is used in one normal way to run Craft headless (from yiic on command line). It's in app/etc/console/ConsoleApp.php.

A little hunting around with PhpStorm, excellent for this sort of thing as others, turns up that ConsoleApp is loading plugins, and I think it will be loading things like Assets through the loadEditionComponents call -- edition checks out to mean Craft Edition, as Personal, Client, Pro, etc. by your license -- so that S3 might be available for Assets, and so forth.

Just what you would need to do, haven't time to go further on. You might find just calling ConsoleApp->run() would do, or may have to make a modified version of ConsoleApp, but seems it might make a good scaffold in that case.

Good fortune on this; interested to know what you work out.

> **Comments:**
> **username_0**: Thanks so much! I'll check into this! That sounds like a good place to start!  
> **username_0**: I did a little bit of playing around. I can't simply run the console application because it checks to make sure it's a console app and fails. I think I would have to actually crete a new application class that extends CApplication that doesn't include request handling. I'm not sure exactly how to do that yet, but hopefully I can find something in ConsoleApp that will tell me.  
> **username_1**: Actuallly, I had a look at the 'Related' SEs over on the right, and the first one looks like it has what you need, per Craft CEO/co-creator Brandon Kelley.: http://craftcms.stackexchange.com/questions/608/bootstrap-craft-from-another-app. You can see if this gets you there...  

---

