Hiện tại có cách nào để tải các mô-đun khác nhau cho mỗi môi trường không, chỉ tải phần mở rộng CommerceBug của Alan khi tôi ở trong môi trường phát triển của mình?
Giống như trong Magento 1 Tôi có thể .gitignore các tệp mô-đun trong ứng dụng / mã nhưng tôi không thể bỏ qua các thay đổi đối với app / etc / config.php một cách dễ dàng thông qua git.
Dường như không thể tải các mô-đun được xác định trong env.php của bạn vì phương thức tải Magento \ Framework \ App \ DeploymentConfig \ Reader chỉ sử dụng mảng_merge, thay vì một số loại hợp nhất sâu, để hợp nhất dữ liệu tệp và ném Ngoại lệ nếu tương tự chìa khóa được tìm thấy.
/**
* Loads the configuration file
*
* @param string $fileKey
* @return array
* @throws \Exception
*/
public function load($fileKey = null)
{
$path = $this->dirList->getPath(DirectoryList::CONFIG);
$fileDriver = $this->driverPool->getDriver(DriverPool::FILE);
$result = [];
if ($fileKey) {
$filePath = $path . '/' . $this->configFilePool->getPath($fileKey);
if ($fileDriver->isExists($filePath)) {
$result = include $filePath;
}
} else {
$configFiles = $this->configFilePool->getPaths();
$allFilesData = [];
$result = [];
foreach (array_keys($configFiles) as $fileKey) {
$configFile = $path . '/' . $this->configFilePool->getPath($fileKey);
if ($fileDriver->isExists($configFile)) {
$fileData = include $configFile;
} else {
continue;
}
$allFilesData[$configFile] = $fileData;
if (!empty($fileData)) {
$intersection = array_intersect_key($result, $fileData);
if (!empty($intersection)) {
$displayMessage = $this->findFilesWithKeys(array_keys($intersection), $allFilesData);
throw new \Exception(
"Key collision! The following keys occur in multiple config files:"
. PHP_EOL . $displayMessage
);
}
$result = array_merge($result, $fileData);
}
}
}
return $result ?: [];
}
Tôi đã tìm thấy một vấn đề github rất sớm được nêu ra bởi @mzeis trên https://github.com/magento/magento2/issues/7 nói về nhiều cấu hình cho mỗi môi trường nhưng điều này đã bị đóng.
Có thể thực hiện một số hook git gọi mô-đun bin / magento: enable và module: vô hiệu hóa nhưng đây có vẻ là một cách rất vòng để đạt được cấu hình phụ thuộc môi trường thực sự.