Magento 2中文手册教程 - 自定义基础目录路径(mage_dirs)

本文介绍了Magento2中如何通过设置MAGE_DIRS来指定自定义的基目录路径和基本URLs,包括缓存、媒体等关键目录的具体配置方法。

Magento 2 基础目录路径介绍

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路径.

一章:Magento介绍...................................................................................................................4 Magento 的特色......................................................................................................................5 什么是Magento........................................................................................................................6 Magento的元素和专业术语....................................................................................................6 网站和商店(website and store)...................................................................................7 网站(website)..............................................................................................................7 商店(store)..................................................................................................................7 商店界面(store views)................................................................................................7 Magento的程序架构................................................................................................................8 内核(Core)..................................................................................................................9 本地的(Local).............................................................................................................9 社区(Community).......................................................................................................9 扩展(Extensions).........................................................................................................9 模块(Modules)............................................................................................................9 界面(Interface)..........................................................................................................10 主题(Themes)............................................................................................................10 区块(Blocks).............................................................................................................11 第二章:Magento入门.................................................................................................................12 Magento的系统需求..............................................................................................................12 Magento下载..........................................................................................................................13 Magento安装和配置..............................................................................................................14 Magento后台控制面板介绍..................................................................................................14 创建多网站和商店(Creating Multiple Websites and Stores)...................................14 缓存管理(Cache Management).................................................................................16 第三章:建立目录........................................................................................................................17 产品目录概念总览................................................................................................................17 设置默认项....................................................................................................................17 产品图片存放目录(Product Image Placeholders)....................................................19 创建分类(Creating Categories).................................................................................21 分类中添加产品(Assigning products at the category level)....................................24 定制分类页面的外观(Assigning designs at the category level)..............................25 在分类页面中使用静态区块(Using static blocks with categories).........................26 属性(Attributes)................................................................................................................27 创建属性(Creating an Attribute)...............................................................................27 特性(Properties)........................................................................................................27 管理标记/选项(Manage Label/Options)...................................................................30 管理属性集(Managing Attribute Sets).....................................................................31 产品(Procucts)..................................................................................................................34
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值