magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

What replaced Mage::run()?

Open joejack22 opened this issue 12 years ago • 3 comments

Hello everyone,

I have searched the WIKI and could not find what can be used now in the index file to load different store and website views.

Typically the following would work.

/* Store or website code */ $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */ $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run($mageRunCode, $mageRunType);

However, as expected, I get the Mage class not found error.

I don't want to do it with my .htaccess file.

Is there a function/class that does this in Magento2?

joejack22 avatar Feb 26 '14 01:02 joejack22

Take a look in index.php, they give you a hint at the top of the file:

<?php
/**
 * Application entry point
 *
 * Example - run a particular store or website:
 * --------------------------------------------
 * $params = $_SERVER;
 * $params['MAGE_RUN_CODE'] = 'website2';
 * $params['MAGE_RUN_TYPE'] = 'website';
 * ...
 * $entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $params);
 * --------------------------------------------

require __DIR__ . '/app/bootstrap.php';

$entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $_SERVER);
$entryPoint->run('Magento\App\Http');

philwinkle avatar Feb 26 '14 05:02 philwinkle

Oh wow, can't believe I missed that! The one time I didn't look up there.

joejack22 avatar Feb 26 '14 15:02 joejack22

@joejack22, as we see @philwinkle gave you the exactly correct answer. Please close this issue if you don't have any other questions. Thank you!

verklov avatar Feb 28 '14 14:02 verklov