Recent Posts


Magento 2: The `pub` Folder


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Magento 2 seems to be moving in a more Symfony/Zend 2/modern direction by splitting out the source folder (app) from the publicly browsable folder (pub). This is good, but the default distribution has a little weirdness — there’s two index.php files. There’s the one you’d expect in pub


and then there’s another one at the root level of the project


This means you can set either folder as the root in your web server, and then tell Magento where the pub folder actually is with something like this

#File: pub/index.php
$params = $_SERVER;
$params[Mage::PARAM_APP_URIS][Mage_Core_Model_Dir::PUB] = '';
$entryPoint = new Mage_Core_Model_EntryPoint_Http(new Mage_Core_Model_Config_Primary(BP, $params));

Hopefully the root level index.php file is a temporary development thing. If this ships in the final version, we’ll see a lot of users needlessly exposing their app folder to the web.

In the meantime, you’ll want to avoid hard coding any javascript/css asset paths, as the <script/> and <link/> tag paths will vary depending on which index.php a user has their system configured to serve.

Copyright © Alan Storm 1975 – 2022 All Rights Reserved

Originally Posted: 20th August 2013