I have a php api to generate html code. What I'd like is to use it with magento.

is posible to do it ?

This is my target :

run_magento() --> generate magento page

By example in magento 2.1 we have by default :

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);

And this code will generate a magento page using magento block structure.

What I'd like to get is we could to generate those block structures dinamically.

To you understand me :

Instead to have : <p><?php echo $content ?></p>
I'd like to have : echo <?php generate_tag(p, $content) ?>

This same idea using magento Api. I have this idea already implemmented with Drupal 5-8 without problems and now I'd like to try to implemment with Magento.

Is possible ?

1 Answer 1


You can use the following script:

 * @author Raj KB<[email protected]>
 * @website http://www.magepsycho.com
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

require '/path/to/magento2/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);

$obj = $bootstrap->getObjectManager();

$state = $obj->get('Magento\Framework\App\State');

// Add Magento Code or non-magento code here...

This script can be used for quick testing your Magento2 functionality also.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.