Giter Club home page Giter Club logo

dcg-membership-number-config's Introduction

What is this?

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://[email protected]/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

dcg-membership-number-config's People

Contributors

gulkhantc avatar swathikrishna1 avatar

Watchers

James Cloos avatar Dave Richards avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.