Skip to content

Commit 0cef2fc

Browse files
committed
Updated readme.
1 parent c603dd1 commit 0cef2fc

File tree

18 files changed

+305
-229
lines changed

18 files changed

+305
-229
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ example/output
33
example/env.php
44
example/example.nginx.conf
55
example/example.php-fpm.conf
6+
autogen
7+
test/fixtures/output/site.generated.ini
8+
test/fixtures/output/site.ini

README.md

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
Configurator
22
============
33

4-
Generates config files from PHP based templates and PHP style config files.
4+
A few simple tools to manage configuration data sanely. These tools are to hold environment data that can be shared without risk. They are not designed to hold 'secrets' e.g. api/oauth keys.
55

6+
* Config file generator
67

8+
* Environment settings
79

8-
## Generate config files
10+
* Convert PHP ini files to PHP-FPM format
911

12+
## Config file generator
1013

11-
Source config file
14+
This tool allows you to generate config files from PHP based templates and PHP data files that hold all of the setting for the different environments
15+
16+
Source config template file:
1217

1318
```
19+
<?php
20+
21+
$config = <<< END
22+
23+
server {
24+
1425
access_log ${'nginx.log.directory'}/project.access.log requestTime;
1526
error_log ${'nginx.log.directory'}/project.error.log;
1627
root ${'project.root.directory'}/public;
28+
}
29+
30+
END;
31+
32+
return $config;
33+
1734
```
1835

19-
Settings file:
36+
Data file that holds data for arbitrary environments:
2037

2138
```
2239
<?php
@@ -37,8 +54,7 @@ $dave = [
3754
3855
```
3956

40-
41-
configurate data/nginx.conf.php var/generated/nginx.conf centos,dave -p settings.php
57+
Running the command `configurate data/nginx.conf.php var/generated/nginx.conf centos,dave -p settings.php` would generated the file:
4258

4359

4460
```
@@ -48,27 +64,59 @@ configurate data/nginx.conf.php var/generated/nginx.conf centos,dave -p settings
4864
```
4965

5066

67+
### Syntax
68+
69+
`configurate [-p|--phpsettings="..."] [-j|--jssettings="..."] input output environment`
70+
71+
-p - a comma separated list of PHP data files. Each need to return an array of data.
72+
-j - a comma separated list of JSON data files.
73+
input - the input template file.
74+
output - the output file to write.
75+
environment - a comma separated list of environment settings to apply.
76+
5177

5278

5379
## Generate environment settings
5480

81+
A tool that will parse the environment settings required by an application, and the data files that hold the settings for all environments, and will generated a file that contains a function that returns an array of what env settings are required by this application
5582

5683

57-
A file that returns an array of what env settings are required by this application
84+
File listing the environment settings required by the application:
5885

5986
```
6087
<?php
6188
62-
use ImagickDemo\Config;
89+
use ExampleApp\AppConfig;
6390
6491
$env = [
65-
Config::CACHING_SETTING,
66-
Config::SCRIPT_PACKING,
92+
AppConfig::CACHING_SETTING,
93+
AppConfig::SCRIPT_PACKING,
94+
AppConfig::FILE_STORAGE
6795
];
6896
6997
return $env;
7098
```
7199

100+
A data file that holds all the data for the various environment settings
101+
102+
```
103+
$dev = [
104+
AppConfig::SCRIPT_PACKING => true,
105+
AppConfig::CACHING_SETTING => 'caching.disable',
106+
];
107+
108+
$live = [
109+
AppConfig::SCRIPT_PACKING => true,
110+
AppConfig::CACHING_SETTING => 'caching.time'
111+
];
112+
113+
114+
// Anyone doing UX testing needs to have the scripts packed together
115+
// to avoid slow UI responses
116+
$uxtesting[AppConfig::SCRIPT_PACKING] = true;
117+
```
118+
119+
Running the command `bin/genenv -p environment/config.php environment/envRequired.php env.php dev,uxtesting`
72120

73121
Produces a file containing a single function that contains all the requested env settings.
74122

@@ -78,7 +126,7 @@ Produces a file containing a single function that contains all the requested env
78126
function getAppEnv() {
79127
static $env = [
80128
'caching.setting' => 'caching.revalidate',
81-
'script.packing' => '',
129+
'script.packing' => 'true',
82130
];
83131
84132
return $env;
@@ -89,22 +137,31 @@ function getAppEnv() {
89137
The keys are the actual strings, rather than the constants used in the application, to allow the settings to be used outside of the application.
90138

91139

140+
### Syntax
92141

142+
`genenv [-p|--phpsettings="..."] [-j|--jssettings="..."] input output environment`
93143

144+
-p - a comma separated list of PHP data files. Each need to return an array of data.
145+
-j - a comma separated list of JSON data files.
146+
input - the input template file.
147+
output - the output file to write.
148+
environment - a comma separated list of environment settings to apply.
94149

95150
## Convert PHP ini files to PHP-FPM format
96151

97-
Because of reasons, PHP-FPM doesn't use the standard PHP in file format when including ini files in a pool in the PHP-FPM conf file.
152+
Because of reasons, PHP-FPM doesn't use the standard PHP in file format when including ini files in a pool in the PHP-FPM conf file. This aspect of the Configurator converts PHP style ini files to the format PHP-FPM expects:
98153

99-
This aspect of the Configurator converts PHP style ini files:
154+
Input ini file:
100155

101156
```
102157
extension=imagick.so
103158
default_charset = "utf-8";
104159
post_max_size = 10M
105160
```
106161

107-
to PHP-FPM style files:
162+
Running the command `php bin/fpmconv example.php.ini example.phpfpm.ini`
163+
164+
will generate this PHP-FPM ini file
108165

109166
```
110167
php_admin_value[extension] = "imagick.so"

0 commit comments

Comments
 (0)