GithubHelp home page GithubHelp logo

craue / craueconfigbundle Goto Github PK

View Code? Open in Web Editor NEW
172.0 172.0 36.0 456 KB

Database-stored settings made available via a service for your Symfony project.

License: MIT License

PHP 98.00% CSS 0.15% Twig 1.85%
bundle php symfony symfony-bundle

craueconfigbundle's People

Contributors

craue avatar enl avatar franmomu avatar pmartelletti avatar rvanlaak avatar stof 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

craueconfigbundle's Issues

Prevent default craue_config_setting table from being created

Is there a way to prevent the default craue_config_setting table from being created when running a doctrine:migrations:diff?

I can create a custom entity in my application by doing this: https://github.com/craue/CraueConfigBundle#using-a-custom-entity-for-settings

...however although it produces the config_setting custom table, it also includes the craue_config_setting table too - which I don't need.

$this->addSql('CREATE TABLE config_setting (name VARCHAR(255) NOT NULL, section VARCHAR(255) DEFAULT NULL, value TEXT DEFAULT NULL, comment VARCHAR(255) DEFAULT NULL, PRIMARY KEY(name))');
$this->addSql('CREATE TABLE craue_config_setting (name VARCHAR(255) NOT NULL, section VARCHAR(255) DEFAULT NULL, value VARCHAR(255) DEFAULT NULL, PRIMARY KEY(name))');

Custom table name

Hi. We have some strict table naming conventions on the project, and it would be great to add ability to specify a custom table name instead of craue_config_setting.

Getting a configuration ignoring cache

I am not sure if maybe it is me doing something wrong but I have the DoctrineCacheBundleAdapter setup and so far it is working like a charm. However, what happens if in a very specific section I want the configuration bundle to fetch a configuration from the database ignoring the cache?

An example on this is that there is a value that I am constantly changing directly on the database to test something out but since the result is cached it is obviously not working properly.

Possibility to have settings of different types

Hello,

This bundle allows creating a custom entity for settings which makes it possible to override data type.

However, it does not seem possible to use more than one data type in an application using this bundle.

I would be very helpful if one was able to create several settings of different types (eg. setting1 => date, setting2 => string of 255 char, setting3 => text rendered in a textarea, etc.).

So it seems that instead of creating a custom entity, we would be looking at having a field containing the datatype of the parameter.

Regards,

How to get settings into a Symfony Command?

Hi. I'm trying to get the settings work into a symfony command that I created

The command extends from ContainerAwareCommand.

I tried with

$this->getContainer()->getParameter('craue_config')->get('enterprise_ruc')

But doesn't works

Good bundle but...

Hi, thanks, this is a good bundle, however is "poor" in the sense that lacks some mandatory (IMHO) features like:

  • initial settings
  • settings validation
  • defaults for missing settings (i.e. not throwing when setting doesn't exist)

Have a look at https://github.com/dmishh/SettingsBundle, how about integrating some features here?

Move Entity configuration to separate yml file

As already discussed in #18 the Setting entity mapping is coded using annotations, which makes it impossible to override it. So what I'd like to propose is to move from Annotations to a yml file so the entity mapping can be overridden in /app/Resources/CraueConfigBundle. That way the bundle doesn't change, but allows others to fix this.

Cached value not getting flushed after updated from the web.

I'm enabling caching using DoctrineCacheBundle and a custom entity where settings are stored.

This entity is also being managed from a basic web backend with easy admin bundle.

When a config value is changed from the web interface, it still returns the old value when called from twig or controllers since it's kept getting cached. I have to manually flush it from the command line.

Why is this value not getting removed from the cache if updated within the app? Might I be missing something else in my setup?

getSetting

The syntax for retrieving a setting should probably mirror that of ParameterBag - ie. ->get() rather than ->getSetting()

Service "craue_config" not found

Hi,
I am trying to use this bundle but after following the step for the instalation when I want to retrieve a setting, an error is thrown at this line : $this->get('craue_config')->get('can_user_participate');.

The full error I get :

Service "craue_config" not found: even though it exists in the app's container, the container inside "App\Controller\DefaultController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Try using dependency injection instead.

I am using Symfony 4.2

Thanks,
A.

Doctrine doesn't recognize schema changes

After setting up the bundle such commands as:

php app/console doctrine:migrations:diff
php app/console doctrine:migrations:migrate
php app/console doctrine:schema:update

doesn't recognize schema changes

Add Symfony 5 support

Tried update symfony to 5.0 and get errors:

  Problem 1
    - craue/config-bundle 2.1.0 requires symfony/framework-bundle ~2.7|~3.0|~4.0 -> satisfiable by symfony/framework-bundle[v4.1.1] but these conflict with your requirements or minimum-stability.
    - craue/config-bundle 2.1.0 requires symfony/framework-bundle ~2.7|~3.0|~4.0 -> satisfiable by symfony/framework-bundle[v4.1.1] but these conflict with your requirements or minimum-stability.
    - craue/config-bundle 2.1.0 requires symfony/framework-bundle ~2.7|~3.0|~4.0 -> satisfiable by symfony/framework-bundle[v4.1.1] but these conflict with your requirements or minimum-stability.
    - Installation request for craue/config-bundle (locked at 2.1.0, required as ~2.1) -> satisfiable by craue/config-bundle[2.1.0].

Console command to create settings

I understand the reasoning behind not making it 'easy' to create settings, since you shouldn't need to unless you're developing and have access to the code/db, but I think a console command to create settings would be a pretty good middle ground between a full ui (pointless) and busting out a SQL/database editor (or fiddling around with writing a good query in a migration).

The console command could also generate the doctrine migration to insert the new setting for you when you deploy.

Thoughts?

Symfony 4 support

This is a nice bundle which I would like to use in the Symfony 4 to which we are going to migrate our project. This package, though, requires 2 or 3 version of the Symfony. Any plans to support 4th version?
I am pretty weak at writings bundles so please don't suggest making a pull request

Case - empty table

Is it possible to insert system variables / names / in a dynamic way if settings table is empty ?
Now we can only to update their values.

User settings and tenancy settings

Hi

Congrats for the bundle.

I have a multy tenancy saas with many users and i want to manage settings by user and by instance.

What is the best practice you recommend for this scenario?

Moving the bundle to the src and modify or using as parent bundle? or what?

Using a custom form schema

Hello,
I'm looking for a bit of help integrating a custom form schema. I'm trying to switch over from SyliusSettingsBundle to CraueConfigBundle because Sylius doesn't support Symfony4. The settings fields need to be displayed in a custom form that was integrated with the Sylius bundle using a service tag in services.yml, like this:

emails_settings_schema:
    class: AppBundle\Settings\EmailsSettingsSchema
    tags:
     - { name: "sylius.settings_schema", namespace: "emails" }

The schema was integrated using the findTaggedServices function in the bundle. Could you tell me how I can integrate this schema using CraueConfigBundle?

Issue using Redis as Cache

Hi,

Great bundle, just a small issue when using Redis for caching.

The key for an element is not the same on update :

  1. "[tags_excluded_football][133]"
  2. "[tags_excluded_football][1]"
  3. "[tags_excluded_football][81]"
  4. "[tags_excluded_football][36]"
  5. "[tags_excluded_football][107]"
  6. "[tags_excluded_football][3]"
  7. "[tags_excluded_football][29]"

It looks like it's incrementing.

Any way to change this ?

Thanks in advance for your help,
Julien

Bundle only works with default entity manager not with multiple EntityManagers

We are using dynamic database connections for multiple tenant databases but it seems the bundle is coupled to use the default entity manager only.

When running the migration script for the db, even when specifying the em, it fails due to

...has a dependency on a non-existent service "doctrine.orm.default_entity_manager".

I can't immediately see a config setting to override this

CraueConfigBundle, Redis and provider tagging

When provider is tagged to be cleared during cache:clear command, container is failing to be assembled.
It appears, that assembling process messes up with arguments:

"Symfony\Component\Cache\Traits\RedisTrait::init()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "string" given.

With File cache adapter the same configuration works just fine.

    craue_config_cache_provider:
        class: Symfony\Component\Cache\Adapter\RedisAdapter
        public: false
        tags:
            - { name: 'cache.pool', clearer: 'cache.system_clearer' }
        arguments:
            - '@Redis'
            - 'craue_config'
            - 3600

Field Type

Hi,

Great bundle and I am so glad to find it. I was wondering if it is possible to set the field type, for example if i want an option to display as a checkbox or dropdown menu how can i achieve it? I know the view to render the form is modify_form.html.twig but the fields that are being rendered are all TextType

Symfony 6.3

Hi there,

I try to upgrade from Symfony 6.2 to 6.3 and get the following logs:

Method "Symfony\Component\DependencyInjection\Extension\ExtensionInterface::load()" might add "void" as a native return type declaration in the future. Do the same in implementation "Craue\ConfigBundle\DependencyInjection\CraueConfigExtension" now to avoid errors or add an explicit @return annotation to suppress this message.

Method "Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()" might add "void" as a native return type declaration in the future. Do the same in implementation "Craue\ConfigBundle\DependencyInjection\CraueConfigExtension" now to avoid errors or add an explicit @return annotation to suppress this message.

Method "Symfony\Component\Form\AbstractType::buildForm()" might add "void" as a native return type declaration in the future. Do the same in child class "Craue\ConfigBundle\Form\Type\SettingType" now to avoid errors or add an explicit @return annotation to suppress this message.

Method "Symfony\Component\Form\AbstractType::finishView()" might add "void" as a native return type declaration in the future. Do the same in child class "Craue\ConfigBundle\Form\Type\SettingType" now to avoid errors or add an explicit @return annotation to suppress this message.

Method "Symfony\Component\Form\AbstractType::configureOptions()" might add "void" as a native return type declaration in the future. Do the same in child class "Craue\ConfigBundle\Form\Type\SettingType" now to avoid errors or add an explicit @return annotation to suppress this message.

Any chance you can fix this?

Best regards

Issues v2.3.0 and PR #50

I'm having issues with version 2.3.0 with PR #50
Installed this version and it broke my app. Getting the following error :

Class "Craue\ConfigBundle\Entity\Setting" sub class of "Craue\ConfigBundle\Entity\BaseSetting" is not a valid entity or mapped super class.

I had a custom Setting class, I had to shorten the name to 191 chars for indexing (multibyte).

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

class Setting extends \Craue\ConfigBundle\Entity\Setting
{
    /**
     * @ORM\Id
     * @ORM\Column(name="name", type="string", length=191, nullable=false, unique=true)
     * @Assert\NotBlank()
     */
    protected $name;
}

I did not have anything else in my config.yml or other code.

Checking the change and the readme, I changed my code to

use Craue\ConfigBundle\Entity\BaseSetting;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity(repositoryClass="Craue\ConfigBundle\Repository\SettingRepository")
 * @ORM\Table(name="config_setting")
 */
class Setting extends BaseSetting
{
    /**
     * @ORM\Id
     * @ORM\Column(name="name", type="string", length=191, nullable=false, unique=true)
     * @Assert\NotBlank()
     */
    protected $name;
}

and updated the config.yml to contain :

craue_config:
    entity_name: Tamago\DefaultBundle\Entity\Setting

Then made a DoctrineMigration to rename the craue_config_setting table to config_setting

But after all that, when getting a value, it returns null. I discovered the entity is not being hydrated correctly (value = null). Any changes to the value (setting a value) is not getting saved to the database.

Am I missing another setting somewhere ?

Doctrine Cache Provider in Symfony 4

Hi,

The configuration for using DoctrineCacheBundle seem to be for an older version of Symfony, please can you explain how to implement this in a Symfony 4 project?

# in app/config/config.yml
parameters:
  craue_config.cache_adapter.class: Craue\ConfigBundle\CacheAdapter\DoctrineCacheBundleAdapter

doctrine_cache:
  providers:
    craue_config_cache:
      apc: ~
      namespace: craue_config
      aliases:
        - craue_config_cache_provider

Custimize rendering of settings

Hello,
Is it possible to customize how settings are rendered? Specifically, I'd like to render some of the settings as plain text fields, while others as ckeditor fields. As far as I can tell, this is not possible because the settings are rendered as a collection of identical forms. Is this correct?

[Feature] Cache queries results

Hi,

Thanks for this great bundle.

I think it would be even more awesome if we could cache the results of the doctrine queries (using redis for example), and of course, invalidate when the value changes.

What do you think ?

-Julien

Per-user settings?

Thinking about using this for app-wide as well as per-user settings? Could per-user settings be achieved via the "section" functionality, or would that be fitting a square peg into a round hole?

preSave / preUpdate events

It would be great if the bundle allows us to subscribe to some events - especially right before saving or updating a setting.

I need to validate some of the settings (f.e. to be only numeric). Sure, I can write my own controller and form, but this would be an easier way.

Testing locally should be easier

Several things could be done to make testing easier:

  • using sqlite rather than mysql, as it avoids the need to setup a MySQL access (which cannot be configured)
  • document the needed setup
  • ensure that the git repo stays in a clean state after running the testsuite (currently, it is not as the cache lives inside the package and is not ignored)

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.