GithubHelp home page GithubHelp logo

illuminatech / config Goto Github PK

View Code? Open in Web Editor NEW
146.0 6.0 14.0 117 KB

Manage Laravel configuration by persistent storage

License: Other

PHP 100.00%
laravel config configuration repository persistent database

config's People

Contributors

drbyte avatar klimov-paul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

config's Issues

Saving and validation not working for keys with dots

As dots are internally replaced by php with undercores in $_POST

See
https://www.php.net/variables.external
symfony/symfony#9009

As a result we have:

in form:

<input type="text" name="foo.bar" value="10">

in $request->all():

[
    "foo_bar" => "10"
]

in \Illuminatech\Config\PersistentRepository::makeValidator rules:

["foo->bar"]=>
  array(2) {
    [0]=>
    string(9) "sometimes"
    [1]=>
    string(7) "integer"
  }

Thus validation rules are not applied and value not saved.

Target class [cache.store] does not exist.

What steps will reproduce the problem?

Extending Illuminatech/Config/Providers/AbstractPersistentConfigServiceProvider and calling parent::register()

What is the expected result?

No error thrown.

What do you get instead?

The error "Target class [cache.store] does not exist." is thrown from line 75 of AbstractPersistentConfigServiceProvider.

Additional info

Sorry if this is not enough information. Please let me know if I can provide more. I may be missing some step but I am following the README to implement this.

Q A
This Package Version 1.3.0
Laravel Framework Version 8.27.0
PHP version 7.4.15
Operating system CentOS 7.9

Encryption Attribute Not Included in Item::toArray()

What steps will reproduce the problem?

Call \Illuminatech\Config\PersistentRepository::getItems()->toArray()

What is the expected result?

Returns an array with 'encrypt' attribute.

What do you get instead?

An array without the encrypt attribute.

Additional info

This makes the solution provided here invalid.

Q A
This Package Version 1.3.1
Laravel Framework Version 9.16.0
PHP version 8.1.7
Operating system CentOS 7.9

Still problem with arrays passed as keys

The issue I was trying to fix in #2 still continues. The fix I proposed works fine, but doing it in userland requires a bunch of hacks to overload a bunch of package methods. It'd be preferable for the package to just do it itself.

In this particular case it's iterating over a config that was dynamically created by hyn/multi-tenant, but barfs when it finds it to be an array:

Image 2019-06-13 at 9 24 18 AM

Feature Request: set configuration items multiple times

I am trying to use this package as having a persistent configuration repository will be very useful for my purposes. I have created a Service Provider that on boot() will extend the configuration service class like so:

       $this->app->extend('config', function ($originConfig) {
            $storage = new StorageEloquent(ConfigurationItem::class);
            return (new PersistentRepository($originConfig, $storage))
                ->setCache($this->app->make('cache.store'))
                ->setCacheKey($this->configItemCacheKey)
                ->setCacheTtl($this->configItemCacheTtl);
        });

This works as expected. If I also call setItems() in the same statement, they are retrieved from the database using the Eloquent model.

However, I also have many other "services" with their own Service Provider. I was hoping to be able to instruct the PersistentRepository in the boot() method of each Service Provider what the configuration items (->setItems()) are for each service. Unfortunately, it seems that calling ->setItems() will completely overwrite previous calls. It would be extremely useful to call this multiple times to "build up" the list of persistent configuration items managed by the repository.

`PersistentRepository::synchronize()` does not respects custom item ID

What steps will reproduce the problem?

Configure persistent repository with the item, which id does not match its key, set new value to this item and invoke synchronize():

$persistentRepository = new PersistentRepository(/* ... */);
$persistentRepository->setItems([
     'custom.id' => [
        'id' => 'custom_id',
    ],
]);

$persistentRepository->set('custom.id', 'new value')

$persistentRepository->synchronize();

What is the expected result?

New value is saved inside the persistent storage.

What do you get instead?

New value is ignored.

Additional info

Q A
This Package Version 1.0.3
Laravel Framework Version 5.8.*
PHP version 7.2.*
Operating system *

documentation

I'm sorry but I love the idea, but your documentation is very poorly written and lacking support on how to get properly started, migration, best practice during boot-time.

Changing setting to be encrypted gives payload error

What steps will reproduce the problem?

Define a non-encrypted setting, and persist it.
Then change the properties to set 'encrypt' => true.
Now attempt to read persisted values (ie: load any page in the app).

What is the expected result?

Expected no app errors.

What do you get instead?

The following error occurs, presumably because it's assuming the existing persisted setting is already encrypted.

[2019-07-10 15:31:04] local.ERROR: The payload is invalid. 
{"userId":123,
"exception":"[object] (Illuminate\\Contracts\\Encryption\\DecryptException(code: 0): The payload is invalid. 
at vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:195)"
} []

Additional info

Q A
This Package Version 1.0.2
Laravel Framework Version 5.8.28
PHP version 7.3.6

Workaround

The only (and unfriendly) workaround appears to be to manually delete the setting from persisted storage, then run the app and collect the setting value via the app and have the app save it "fresh".

Retrieving configuration items from dot notation nested arrays does not work as expected

What steps will reproduce the problem?

If I set two configuration items like the following:

setItems([            'services.example.item1' => [
                'label' => 'Item 1',
                'rules' => ['required', 'array'],
                'cast' => 'array'
            ],
            'services.example.item2' => [
                'label' => 'Item 2',
                'rules' => ['required', 'array'],
                'cast' => 'array'
            ]
])

And then I try to retrieve them like so:

Config::get('services.example')

Nothing is returned (null).

What is the expected result?

I should get an array of configuration items, item1 and item2.

What do you get instead?

I get a null response.

Additional info

The issue seems to be related to the call to isPersistentKey when calling get

Additionally, if I call Config::restore() beforehand, I am able to get the expected result.

Q A
This Package Version 1.4.0
Laravel Framework Version 10.13.5
PHP version 8.1.20
Operating system CentOS 7.9

Long delays to optimize autoloader when using package

What steps will reproduce the problem?

When running composer install --no-dev --optimize-autoloader -vvv, the command php -d allow_url_fopen='1' -d disable_functions='' -d memory_limit='1536M' artisan package:discover --ansi is also run.

Because this loads the service providers, a database connection will be attempted for the configuration items. When, for example, building your code base on a CI/CD server, this will hang until a timeout because it cannot connect to the database.

What is the expected result?

Avoid a database connection during artisan/build commands.

What do you get instead?

Timeout on database connections.

Additional info

Q A
This Package Version 1.4.0
Laravel Framework Version 10.13.5
PHP version 8.1.20
Operating system CentOS 7.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.