How can Craft-generated Content HTML be accessed via an external PHP app?
Your app can load up Craft using its bootstrap.php file:



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


That file returns a Craft\WebApp instance. From it, you can access all of Craft’s services, including the ElementsService which provides APIs for fetching elements and their content.

Read through our Working with Elements guide to get an idea of how those APIs work.

As a quick example, here’s how you’d get the entries in a section with an ID of 1 with a category selected, with an ID of 5:

$criteria = $craft-&gt;elements-&gt;getCriteria(Craft\ElementType::Entry);
$criteria-&gt;sectionId = 1;
$criteria-&gt;relatedTo = array('targetElement' =&gt; 5);

$entries = $criteria-&gt;find();


To get the HTML for an entry, you could either assemble that in PHP based on the entry’s content fields, but it would probably be easier to just write a template for it, and have TemplatesService::render() render it for you:

$html = $craft-&gt;templates-&gt;render('path/to/templates', array(
    'entries' =&gt; $entries
));