CodeIgniter Forums

Full Version: Overwrite config file composer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I overwrite a composer package?

For example Ion_Auth Config.php

I need a customized Config.php, which does not change when using composer update
i have not done it ; but the basics are putting your code at your repo ,then adding a reference to that source into the composer.json file. So when you do say a composer update it will check against all entries  in composer.json including your repo. Its on the composer docs. This seems to be the essence:

    "require": {
        "vendor/my-private-repo": "dev-master"
    "repositories": [
            "type": "vcs",
            "url":  "[email protected]:vendor/my-private-repo.git"

It can work, thanks!
thinking about it my approach would work if you were using additional packages, that you wanted to keep updated via your repo but you want to overwrite a core Class in Config Directory say Routes.php then actually i think one of the maintainers needs to answer this one.

If you want to write your own class then thats not difficult and i'm doing that . If its one of your classes then its only a case of giving it a namespace then making sure it can be found . If your class is within a Directory , that itself is inside  app directory then for example i have a class called CheckSpam in a Directory called Andy : 
<?php namespace App\Andy;

class CheckSpam

from a controller i can make use of my class via stating this in controller:

use \App\Andy\CheckSpam;

then from a method i instantiate class and use a method:

$spamHandle = new CheckSpam();
    //CheckSpam is in app/Andy and has namespace App\Andy
        $logic = $spamHandle->filterSpam($cleanMessage);

f i do a composer update i'm pretty sure only items listed in composer.json will be updated/changed and my class's should be untouched ?