Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

elfeffe's avatar

Any experience using Mage.php from Magento inside Lumen?

I'm trying to get some data from Magento, I have Lumen in a folder in Magento Root

Magento Root

  • Lumen
    • Public

I'm trying to connect to Magento using this on index.php

require_once('../../app/Mage.php'); //Path to Magento

umask(0);

Mage::app();

But I get

ErrorException in Autoload.php line 94: include(App\Http\Controllers\Mage.php): failed to open stream: No such file or directory

Anyone with experience on this?

0 likes
5 replies
sirdiego's avatar
sirdiego
Best Answer
Level 15

Magentos "Mage" class seems to be in the global namespace and your are in the App\Http\Controllers namespace. You need to at least prefix the call with an backslash to tell php to look in the global namespace:

\Mage::app();

You should read about namespaces in the php documentation.

Cheers.

1 like
elfeffe's avatar

Thank you, I found another way to do this, but will try this. Thank you again

dglass's avatar

@elfeffe any update on how you managed to get this to work? I'm trying out something similar and haven't had any luck yet

elfeffe's avatar

We used

use \Mage;


 /**
     * Create a new instance.
     *
     */
    public function __construct()
    {
            require_once(env('MAGENTO_PATH'));
            Mage::app();
       
    }

Please or to participate in this conversation.