meanbee / libmageconf
Discover Magento environment and configuration information outside of an application installation.
Installs: 3 287
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 5
Forks: 3
Open Issues: 0
Requires (Dev)
- php-vfs/php-vfs: ^1.3
- phpunit/phpunit: ^5.3
This package is not auto-updated.
Last update: 2023-08-05 13:17:30 UTC
README
This library provides a mechanism for discovering a Magento (1.x and 2.x supported) installation, given a starting directory. This is useful for building tools that integrate externally with Magento but still need access to its configuration or certain files, such as magedbm and mageconfigsync.
Installation
composer require meanbee/libmageconf
Usage
Given that I have Magento installed in /home/nrj/magento
, I can discover its location with the following code:
$rootDiscovery = new RootDiscovery('/home/nrj');
// Outputs: "Root: /home/nrj/magento"
printf("Root: %s", $rootDiscovery->getRootDirectory());
Given that I know where the Magento installation's local.xml
is, I can access the configuration held in that file with
the following code:
$configReader = ConfigReader\MagentoOne("path/to/local.xml");
$databaseName = $configReader->getDatabaseName();
or
$configReader = ConfigReader\MagentoTwo("path/to/env.php");
$databaseName = $configReader->getDatabaseName();