Download the PHP package monsieurbiz/sylius-settings-plugin without Composer
On this page you can find all versions of the php package monsieurbiz/sylius-settings-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download monsieurbiz/sylius-settings-plugin
More information about monsieurbiz/sylius-settings-plugin
Files in monsieurbiz/sylius-settings-plugin
Package sylius-settings-plugin
Short Description Add a settings panel to your Sylius.
License MIT
Informations about the package sylius-settings-plugin
Settings for Sylius
This plugin gives you the ability to have Plugins oriented settings in your favorite e-commerce platform, Sylius.
Compatibility
Sylius Version | PHP Version |
---|---|
1.12 | 8.1 - 8.2 - 8.3 |
1.13 | 8.1 - 8.2 - 8.3 |
1.14 | 8.1 - 8.2 - 8.3 |
Installation
If you want to use our recipes, you can configure your composer.json by running:
⚠️ Warning: For Doctrine DBAL < 3.0
You have to ignore migration `Version20240710130300.php` if you are under Doctrine DBAL < 3.0.
For the installation without flex, follow these additional steps
Change your `config/bundles.php` file to add this line for the plugin declaration: Then create the config file in `config/packages/monsieurbiz_settings_plugin.yaml` : Finally import the routes in `config/routes/monsieurbiz_settings_plugin.yaml` :
Update your database:
Continue to "How it works" to add your first setting for your store.
Note: you may encounter an error during the installation via composer if you let it run the scripts.
Copy the configuration files and rerun the composer require
, it should work. This is due to the use of other plugins in the DI.
The configuration is then required to run any console command.
How it works
As a good start you can have a look at:
- The configuration file to add your own settings.
- The form with your own fields.
Then you can get your settings using a twig function: setting()
.
Have a look at this example.
You can also use the DI to get your Settings, as example with the settings in the test Application app.default
:
Note: the "Settings" menu won't appear until you have at least one setting.
Fetch settings
Use fixtures
We've implemented a fixtures loader to help you to create your settings if you need to have different settings for your tests or project (by channel, by locale…).
You need to create a yaml file with your fixtures, like explained in the documentation of Sylius.
You can find our own example in the source code, section sylius_fixtures
: configuration file.
It's also possible to run test fixtures with a local suite in development: make sylius.fixtures.local
.
By default, a fixture will replace the value of a setting if it already exists.
If you want to keep a value as it is in the database when running this fixture, you can use the flag ignore_if_exists: true
for each element that you want to be kept.
Extends existing settings form
If you want to add a field to an existing settings form (like in another plugin), you can check the example in the test app
Use CLI
You can use a CLI command to set a value for a setting directly from the console:
$ ./bin/console monsieurbiz:settings:set {alias} {path} {value} --channel="FASHION_WEB" --locale="en_US" --type="text"
Examples:
The options channel and locale can be omitted if you want to set the value for a global scope. If a value exists for the given scope the type can be omitted as it will be the same as the existing one unless you want to change the type. For a new value you need to specify the type.
⚠️ When specifying the type, be sure to know what you are doing as it should be coherent with the Form Type of the field.
Use cache
Settings use cache.adapter.array
adapter by default. If you want to increase performance, you can use
cache.adapter.apcu
, cache.adapter.redis
or any adapters instead.
You had to add the following lines to your config file:
Contributing
You can find a way to run the plugin without effort in the file DEVELOPMENT.md.
Then you can open an issue or a Pull Request if you want! 😘
Thank you!
License
This plugin is completely free and released under the MIT License.