Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple Demo repo #5

Open
tacman opened this issue Mar 29, 2024 · 9 comments
Open

Simple Demo repo #5

tacman opened this issue Mar 29, 2024 · 9 comments

Comments

@tacman
Copy link
Contributor

tacman commented Mar 29, 2024

Is there a demo repo for this bundle? I'd love to see it in action, without having to create the Settings classes and such. Thanks.

@mesilov
Copy link

mesilov commented Apr 25, 2024

+1

@gmurambadoro
Copy link
Contributor

Hi @tacman . I will create a demonstration bundle for you and link it here. This is really a cool project, and I only got to find out about it only recently.

@gmurambadoro
Copy link
Contributor

Hi @tacman @jbtronics , I have created a demo repo that you can use for a "real world" Symfony 7 example application.

Let me know if this is helpful.

Regards,
Gavin.

@tacman
Copy link
Contributor Author

tacman commented May 23, 2024

Thanks! Very helpful.

Any reason not to use php 8.3? I wanted to run it with sqlite (instead of doing the whole docker install), but I don't have sqlite installed on php8.2.

Once I made those changes, the installation instructions become really easy, after cloning

echo 'DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"' > .env.local
composer install
bin/console doctrine:schema:update --force --complete
bin/console d:fixtures:load -n
symfony server:start -d
symfony open:local

I can make a PR if you'd like.

Also, Symfony 7.1 is coming out in a few days, so I tweaked the composer file to allow it.

@tacman
Copy link
Contributor Author

tacman commented May 23, 2024

One thing that would really help is to make the pagination setting specific to the user.

That is, the admin might want 25, and the 'user' only 15 per page.

Only the admin should be able to change the global settings.

It's not clear how to make the pagination a user-specific setting, that is, part of the User class.

Of course, what I'm trying to avoid is adding a "pageLength" property to my user record, and instead use this bundle.

Thx.

@gmurambadoro
Copy link
Contributor

Hi @tacman

There is no reason not to use PHP 8.3, it should work with any of the supported PHP versions for Symfony 7. You may send a pull request through since I think SQLite would simplify the code as well.

At the moment it appears that settings are global, and user-specific settings are not possible. @jbtronics may give us clarity.

Regards,
Gavin.

@jbtronics
Copy link
Owner

Thanks @gmurambadoro . I did not have the time to look into your demo yet, but I certainly will.

And yes, for the moment this bundle only allows for global settings.
I hope to extend it to allow users to override global settings for themselves and so on, but this will probably require also some changes in usage (as you somehow have to tell for which user to retrieve the settings).

@jbtronics
Copy link
Owner

@gmurambadoro Maybe a few suggestions to improve it:

The dependencyInjectable on the settings class attribute is redundant, as its true by default. The option is currently only there to disable this dependency injection for certain settings class.

Also, I would recommend to use dependency injection of settings instances over getting them from the entity manager, whenever possible. That makes type derivation easier and decouples your code from the SettingsManager, making it easier for testing.

That will probably not work for user related settings (as you somehow have to bring in the connection to a certain user in there), but this case will probably require some changes to the code anyway.

In a real world application, you should probably configure the storageAdapters via the central config file, but I guess for a demo, its good to demonstrate the ability to specify it on a per class base.

@jbtronics
Copy link
Owner

Also if somebody is interested, I am currently in the process of using this bundle for another project of mine, Part-DB, which was more or less the reason why I created this bundle.

You can find the settings definitions here: https://github.com/Part-DB/Part-DB-server/tree/settings-bundle/src/Settings
It heavily utilizes the splitting up settings into small functional units and then embedding it into a larger treee of settings via settings embedds.

With the right template, this allows for the easy creation of complex structured settings forms, completly alone from the infos from the attributes:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants