dcg / dcg-membership-number-config
There is no license information available for the latest version (v1.0.1) of this package.
A package to add config to a project
v1.0.1
2019-06-24 09:53 UTC
Requires
- php: >=5.4
Requires (Dev)
- mockery/mockery: ~0.8
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2025-05-26 03:48:05 UTC
README
A package to add config to a project
Usage
To add this library to an existing application,
Add the following repository to the app's composer.json,
"repositories": [ { "type": "vcs", "url": "https://git@bitbucket.org/tastecard/dcg-lib-config.git" } ]
Add the following to the require section,
"dcg/dcg-lib-config": "dev-master"
Add this to the scripts section:
"scripts": { "post-update-cmd": [ "Dcg\\Config\\FileCreator::createConfigFile", ] }
OR, if the parent project is to be a dependancy of another project which also needs config. Create a class which extends FileCreator and specify a different source/destination config file like so:
namespace Dcg\Client\MembershipNumberState\Config; class FileCreator extends \Dcg\Config\FileCreator { /** * Get the location of the config file to use as an example (template) * @param Composer\Script\Event $event * @return string */ protected static function getSourceFile(\Composer\Script\Event $event) { $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir'); return $vendorDir . DIRECTORY_SEPARATOR . 'dcg' . DIRECTORY_SEPARATOR . 'dcg-lib-membership-number-state-client' . DIRECTORY_SEPARATOR . 'config.php'; } /** * Get the location of where the config file should be copied to * @param Composer\Script\Event $event * @return string */ protected static function getDestinationFile(\Composer\Script\Event $event) { $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir'); return dirname($vendorDir) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'membership-number-state-config.php'; } }
Create the config class which uses the config file specific to the project which needs config
namespace Dcg\Client\MembershipNumberState; class Config extends \Dcg\Config { /** * Get the default config file to use * @return string */ protected static function getDefaultConfigFile() { return self::getRootDir().'/config/membership-number-state-config.php'; } }
- Run composer install