What replaced Mage::run()?
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?
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');
Oh wow, can't believe I missed that! The one time I didn't look up there.
@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!