I know that in Magento 1 the directory "/tmp/magento" was used as fall-back in case it existed.

I would like to know if that is still the case in Magento 2.

  • probably this is php issue, /tmp path is an environment variable
    – MagenX
    Aug 1, 2016 at 18:09
  • @MagenX: Magento 2 uses PHP here and applies realpath onto sys_get_temp_dir which in the end might (directly or indirectly) be based on that environment variable, yes. IIRC it's similar on Windows and in the end, IIRC, it's the same for the working directory.
    – hakre
    Aug 1, 2016 at 21:00
  • More importantly: No not a PHP issue. There is code in Magento 1 that maps on top of the var folder falling back to sys_get_temp_dir via "Magento itself chooses to try /tmp/magento/ if the var/ folder is not writable." (not fully precise, see the linked question on the right for details). My quesiton is really pretty specific: Is the same fall-back in Magento 2 as it was in Magento 1. And I'm pretty sure that's no PHP detail so it "happened" to Magento 1 but it was a decision and by design for Magento 1 to do so and it would be interesting to know practically if it's the same in Magento 2.
    – hakre
    Aug 1, 2016 at 21:18

1 Answer 1


As @MagenX says, /tmp is an environment variable. It is the temporary folder that php is using for various tasks, like handling uploads.

The temporary folder can be changed in php configuration (via upload_tmp_dir directive).

Magento2 uses the temp folder too: $this->directories[self::SYS_TMP] = [self::PATH => realpath(sys_get_temp_dir())]; https://github.com/magento/magento2/blob/6ea7d2d85cded3fa0fbcf4e7aa0dcd4edbf568a6/lib/internal/Magento/Framework/Filesystem/DirectoryList.php#L99

but only for handling files, not for cache when var is not available (like magento1 did).

  • The $this->directories array defines the names of directories you can retrieve from the Directory-Listing. The temp-directory is in there, but that's all in common with my question. What I'm asking about is if there is a fall-back similar to Magento 1 in Magento 2 for let's say the "var" folder (another name). Here is the reference I speak about in Magento 1: Magento writing to tmp/magento directory - It's perhaps valid to compare the object you have as $this in you answer to Mage::getModel('core/config'). (good question btw.)
    – hakre
    Aug 1, 2016 at 21:14
  • 1
    Albeit: You write about that the temporary folder that PHP is using can be changed in PHP configuration. Can you leave a link to the PHP .ini directive that is defining the tmp folder? That would be a good addition to your answer.
    – hakre
    Aug 1, 2016 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.