Magento Files and Folders Structure

Learn more about the different files and folders Magento needs to operate

This part of the Magento tutorial will provide detailed information regarding the Magento's default files and folders structure.

The files and folders included in the main directory are as follows:

  • .htaccess - contains mod_rewrite rules, which are essential for the Search Engine Friendly URLs. There you can also find standard web server and php directives that can improve your web site performance;
  • .htaccess.sample - this is a backup of the .htaccess file. If you modify .htaccess it can be used in order to get the default settings;
  • app (directory) - this folder contains the themes and configuration files. Also there are the template files for the default administration theme and the installation;
  • bin (directory) - contains the magento CLI. Using that tool would require SSH access to the server. The magento CLI utility is quite powerful and can help you in installing modules, upgrading the application, reindexing, compiling, etc;
  • dev (directory) - contains various tools for developers such as migration tools and tests;
  • index.php - the main index file for Magento;
  • lib (directory) - the Magento core code is located in this folder. It contains the software's PHP libraries;
  • LICENSE_AFL.txt - the Academic Free License under which the Magento software is distributed;
  • LICENSE.txt - the Open Software License under which the Magento software is distributed;
  • php.ini.sample - this file contains sample php directives that can be used in order to modify your PHP setup. If you want to alter the default setup edit the file and then rename it to php.ini;
  • phpserver (directory) - contains a router.php file for the php built-in web server;
  • pub (directory) - contains another index.php file. You can configure your server to run your application through any of this index.php file. Using pub/index.php is a good option as it will stop access of application files and it is good for security. Also contains media, errors and generated static files;
  • setup (directory) - the Magento installation's setup files are located there. It is used for the installation process mainly;
  • update (directory) - contains files used by the application during an upgrade;
  • var (directory) - cache, sessions, database backups, data exports and cached error reports can be found in this directory;
  • vendor (directory) - contains the core application and theme code that are installed via Composer. Third party libraries such as Zend Framework that are installed this way are also present in this directory.