Skip to content

Commit 5a5a933

Browse files
committed
Create a README
1 parent 1266755 commit 5a5a933

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

README.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# SimpleConfigBundle
2+
3+
This bundle provide an UI to configure other bundles by override a configuration file.
4+
5+
This should be used to allow administrators of your Application to easily change some simple configuration.
6+
References this [documentation example](http://symfony.com/doc/current/bundles/configuration.html#using-the-bundle-extension), they could can change the _Twitter Client Id_ and _Twitter Client secret_.
7+
8+
The mechanism behind is to retrieve all available configuration for a bundle, display it in a form, and dump the submitted data in a new _config file_ that will override the default configuration.
9+
10+
11+
## Installation
12+
13+
### Step 1: Download the Bundle
14+
15+
Open a command console, enter your project directory and execute:
16+
17+
```console
18+
$ composer require barth/simple-config-bundle
19+
```
20+
21+
> :warning: This is not already available as I didn't yet submit this package to [Packagist](https://packagist.org)
22+
> Stay tuned for update by giving a :star: ?
23+
24+
Or open your `composer.json`, and add following content :
25+
26+
```js
27+
{
28+
// ...
29+
"repositories": [
30+
{
31+
"type": "vcs",
32+
"url": "git@github.com:Jibbarth/SimpleConfigBundle",
33+
"vendor-alias": "barth"
34+
}
35+
],
36+
"require": {
37+
//...
38+
"barth/simple-config-bundle": "dev-master"
39+
}
40+
//...
41+
}
42+
```
43+
44+
Open a command console, enter your project directory and execute the
45+
following command to download the latest stable version of this bundle:
46+
47+
```console
48+
$ composer update
49+
```
50+
51+
This command requires you to have Composer installed globally, as explained
52+
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
53+
of the Composer documentation.
54+
55+
### Step 2: Enable the Bundle
56+
57+
Then, enable the bundle by adding it to the list of registered bundles
58+
in the `config/bundle.php` file of your project:
59+
60+
```php
61+
<?php
62+
// config/bundles.php
63+
64+
return [
65+
// ...
66+
Barth\SimpleConfigBundle\BarthSimpleConfigBundle::class => ['all' => true],
67+
];
68+
```
69+
70+
### Step 3: Active the override for configuration
71+
72+
In your `src/Kernel.php`, alter the `configureContainer` function :
73+
74+
```php
75+
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
76+
{
77+
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
78+
// Feel free to remove the "container.autowiring.strict_mode" parameter
79+
// if you are using symfony/dependency-injection 4.0+ as it's the default behavior
80+
$container->setParameter('container.autowiring.strict_mode', true);
81+
$container->setParameter('container.dumper.inline_class_loader', true);
82+
$confDir = $this->getProjectDir().'/config';
83+
84+
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
85+
$loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
86+
87+
// ADD THIS LINE
88+
$loader->load($confDir.'/{packages}/override/**/*'.self::CONFIG_EXTS, 'glob');
89+
90+
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
91+
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
92+
}
93+
```
94+
95+
### Step 4: Import routes
96+
97+
In your `config/routes.yaml`, add the following route definition :
98+
99+
```yaml
100+
#config/routes.yaml
101+
barth_simpleconfig:
102+
resource: "@BarthSimpleConfigBundle/Controller/"
103+
type: annotation
104+
prefix: /admin
105+
```
106+
107+
:warning: You should provide a `prefix` where only **ROLE_ADMIN** can access.
108+
109+
### Optionnal Steps
110+
111+
You should add the `config/packages/override` path to your gitignore.
112+
If you deploy your app with awesome tools like [Capistrano](https://capistranorb.com/) or [Deployer](https://deployer.org/), don't forget to make this path as **shared** to avoid lose custom override between each deployment.
113+
114+
### Blacklist bundles
115+
116+
By default, all bundles that come with [symfony/website-skeleton](https://github.com/symfony/website-skeleton) are blacklisted.
117+
You cannot override them so easily.
118+
119+
You can extend this list by adding the _bundle alias_ in your configuration :
120+
121+
```yaml
122+
#config/packages/barth_simple_config
123+
barth_simple_config:
124+
blacklisted_bundles:
125+
- nelmio_api_doc # for example
126+
```
127+
128+
## How use it
129+
130+
When installation is completed, you have two new routes :
131+
132+
* http://yourdomain.org/admin/config That exposes all available configuration routes
133+
* http://yourdomain.org/admin/config/{package} That display your form configuration
134+
135+
## Customize
136+
137+
By default, pages don't look very pretty. To integrate it in your template, don't hesitate to override the `base.html.twig` template by creating a new one in `templates/bundles/BarthSimpleConfigBundle/` and make it extend your base template.
138+
139+
140+
## Contribute
141+
142+
First of all, thank you for contributing :heart:
143+
144+
If you find any typo/misconfiguration/... please send me a PR or open an issue.
145+
146+
Also, while creating your PR, please write a description which gives the context and/or explains why you are creating it.
147+
148+
149+
## TODOs
150+
151+
- [ ] Make installation as simple as a `composer require barth/simple-config-bundle`, so submit it to packagist
152+
- [ ] Process configuration when form is submitted to validate it immediatly.
153+
- [ ] Write Tests Suite
154+
- [ ] Add translations

0 commit comments

Comments
 (0)