Code Monkey home page Code Monkey logo

Comments (7)

PHLAK avatar PHLAK commented on August 29, 2024 1

This is the expected behavior. Your configuration files are supposed to be your source of truth and are never changed directly. Config::set() will just let you set/override a value (in memory) after it's been loaded from your config.

from config.

PHLAK avatar PHLAK commented on August 29, 2024 1

It's straightforward to start with these two configurations and add the rest gradually.

We already support six different config file formats so persistence should support each, otherwise we start fragmenting support which makes the package harder to maintain.

from config.

PHLAK avatar PHLAK commented on August 29, 2024

I've been thinking about this and it might be worth adding a Config::persist() method for saving changes to the config files. This might be tricky though due to the support of multiple config file formats.
Reopening for now to track this.

from config.

sunchayn avatar sunchayn commented on August 29, 2024

Hey Chris,
Actually, the project I was working on needed a 2 way config system. Unfortunately, I did not found a lightweight library for this task so I created my own package and use it in my project. I called the method sync() . Here is my package and this was my main project, I made it supports PHP based configuration only because that's what I needed, persisting JSON is easy too. It's straightforward to start with these two configurations and add the rest gradually.

from config.

xbipin avatar xbipin commented on August 29, 2024

any plans on adding this feature as i need to save the config once i set something

from config.

darkstriders avatar darkstriders commented on August 29, 2024

Looking forward to Config::persist() method

from config.

Externaluse avatar Externaluse commented on August 29, 2024

Hi @PHLAK, I've been implementing a persist through Symfony/Cache.
In the example below, I have hard-configured items to ignore in a config. When the system loads, it retrieves these from the cache through a callback unless the cache is expired or doesn't exist yet. That way I can add items on runtime, which will then be persisted for cacheDuration time.
$cache = new FilesystemAdapter(namespace: $config->get('Api.RaceName'), defaultLifetime: 7 * 24 * 3600, directory: $config->get('Logging.Directory', 'Logs')); $alwaysIgnore = $cache->get(IGNORECACHEKEY, function (ItemInterface $item) use ($config) { $item->expiresAfter(new DateInterval('P3D')); // 3 days return $config->get("Configuration.AlwaysIgnore", []); });

from config.

Related Issues (9)

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.