Question

What's the best way to load the Mage.php (Magento) class within Symfony2. I've read documentation and and tried different autoloader and classloader configurations but the only thing works for me is below.. Ideally, I'd like to use "Best Practices" which my current solution doesn't do. This would probably involve not using the require_once and instead loading from autoload.php or using composer.json

/* 
 * var/www/symfony/app/console -- THIS WORKS ONLY IN THE SYMFONY CONSOLE
 */
    if($env == 'prod'){
    require_once '/var/www/production/app/Mage.php';
}else{
    require_once '/var/www/development/app/Mage.php';
}

This code allows me to do Magento tasks ($product->save(), backoffice type things, batch updating products) from within the Symfony Environment without breaking down the Core Magento functionality and putting the data at risk.

For anyone curious why I would want to do this

The Symfony Framework is easier for rapid development of back-end processes and back-end reporting. Twig and the Symfony Form functionality works well for reporting.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top