Code Monkey home page Code Monkey logo

config's Issues

8.3 & 8.4

Can you add support for 8.3 and 8.4 is only a few months away so keep this in mind too.

Upgrade symfony/yaml

Hello,
could you please upgrade symfony/yaml in your library?
from:
"symfony/yaml": "^3.0 || ^4.0 || ^5.0",
to:
"symfony/yaml": "^3.0 || ^4.0 || ^5.0 || ^6.0",
Because now it doesn't allow us to use latest symfony/yaml v6.0 and php 8.2
Thanks!

Invalid .json Syntax & Error Handling

I'm using this in a couple of WordPress plugins. It would be nice if it not throw an Exception if the file syntax is invalid. Example:

$config = new Config\Config('/path/to/app/config.json');

If config.json has invalid syntax, it throws a nasty exception.

I'm not sure how I would address this, but maybe you could return an Exception() object if there is an error. I'm just brainstorming...

$config = new Config\Config('/path/to/app/my_config.json');

if( is_object( $config ) && get_class( $config ) == 'Exception' ) {
  // Let the user know
  echo $config->GetMessage();
} else {
  // Do magical things
}

Better maybe better?:

$config = new Config\Config('/path/to/app/my_config.json');

if( $result = $config->get_error() ) {
  // Show some sort of pretty panel/notice
  echo 'An error has occurred: ' . $result;
} else {
  // Do magical things
}

Thank you,
Daniel

Invalid JSON syntax exception

Improve InvalidFileException messages

Currently InvalidFileException does not contain a message when thrown. This could be improved by including the name of or path to the file which is invalid. See #2

For example:

Invalid file detected at $path

or

Unable to parse file at $path

'Config' Namespace

I'm wondering if using the namespace Config could run into conflicts.

Perhaps Phlak\Config?

Index arrays in config is not overrided correctly

Hello!
Trying to use your lib, but faced a problem:

require 'vendor/autoload.php';

use PHLAK\Config\Config;

$array1 = [
	'assoc_key' => 'testvalue',
	'key' => [1,2,3,4],
];
$array2 = [
	'assoc_key' => 'override',
	'key' => ['somevalue'],
];

$config1 = new Config($array1);
$config2 = new Config($array2);
print_r($config1->merge($config2)->toArray());

It returns:

Array
(
    [assoc_key] => override
    [key] => Array
        (
            [0] => somevalue
            [1] => 2
            [2] => 3
            [3] => 4
        )

)

But should return:

Array
(
    [assoc_key] => override
    [key] => Array
        (
            [0] => somevalue
        )

)

Append/prepend values onto a config array item

$config = new Config([
    'whitelist' => [
        'ips' => [
            '127.0.0.1',
            '192.168.0.1'
        ]
    ]
]);

$config->append('whitelist.ips', '10.10.0.1');

Should result in

[
    'whitelist' => [
        'ips' => [
            '127.0.0.1',
            '192.168.0.1',
            '10.10.0.1'
        ]
    ]
]

This should also be able to accept an array of values.

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.