MAGE_DIRS 您能够指定使用的自定义基目录路径和基本URLURLs.
MAGE_DIRS
Magento/Framework/App/Filesystem/DirectoryList.PHP中指定一个关联数组,其中键是常量,值是目录或URL路径的绝对路径。
你可以用以下任何一种方式设置 MAGE_DIRS :
use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\bootstrap; require __DIR__ . '/app/bootstrap.php'; $params = $_SERVER; $params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [ DirectoryList::CACHE => [DirectoryList::PATH => '/mnt/nfs/cache'], DirectoryList::MEDIA => [DirectoryList::PATH => '/mnt/nfs/media', DirectoryList::URL_PATH => ''], ]; $params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [ DirectoryList::PUB => [DirectoryList::URL_PATH => ''], DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'], DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'], DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload'], ]; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication('Magento\Framework\App\Http'); $bootstrap->run($app);
上面的代码分别设置了 [cache] 、 [media] 、 /mnt/nfs/cache 、 /mnt/nfs/media路径.
[cache]
[media]
/mnt/nfs/cache
/mnt/nfs/media