aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2011-02-17 01:40:20 +0100
committerLaurent Bachelier <laurent@bachelier.name>2011-02-17 01:40:20 +0100
commitbd3c43446756055fecfbcc50a7359e98ac64436b (patch)
tree0e8953243fd850e5b556ac5a8bbfff02333ab87d
parentAdd the setenv module (diff)
parentgenconf does not require to be in the project directory anymore (diff)
downloadsymfttpd-bd3c43446756055fecfbcc50a7359e98ac64436b.tar.xz
Merge branch 'master' into multiapp
-rw-r--r--README.md33
-rw-r--r--data/lighttpd.conf.php2
-rwxr-xr-xgenconf15
-rwxr-xr-xspawn6
-rw-r--r--symfttpd.conf.php6
5 files changed, 44 insertions, 18 deletions
diff --git a/README.md b/README.md
index 8a13d1c..ec81ce7 100644
--- a/README.md
+++ b/README.md
@@ -149,38 +149,50 @@ while project-level config is for things that only concern your project.
## genconf
-If you don't want to copy/paste lighttpd configs, handle regexps when
-you add files, or fight rewriting issues (which can often happen
+If you don't want to copy/paste lighttpd configs, handle regular expressions
+when you add files, or fight rewriting issues (which can often happen
considering that most available examples are badly written),
then this tool is for you. It is also used internally by `spawn`.
### Quick start
-This first part is unnecessary if you used `mksymlinks`:
-
- cd /path/to/example.com/config
- ln -s /path/to/symfttpd/genconf ./lighttpd.php
-
lighttpd config:
$HTTP["host"] == "example.com" {
- include_shell "/path/to/example.com/config/lighttpd.php"
+ include_shell "/path/to/symfttpd/genconf -p /path/to/example.com/web"
}
or if you want a different default application:
$HTTP["host"] == "mobile.example.com" {
- include_shell "/path/to/example.com/config/lighttpd.php --default=mobile"
+ include_shell "/path/to/symfttpd/genconf -p /path/to/example.com/web -d mobile"
}
If symfttpd is running in single-process mode, or you only running an independent
-lighttpd, you have to restart it each time you add a file the the web/ root.
+lighttpd, you have to restart it each time you add a file in the `web/` root.
Hopefully, it doesn't happen often.
Also, don't forget to run `php symfony plugin:publish-assets`, or even better,
`mksymlinks` before.
+### Alternative
+
+The web directory can be omitted if genconf is present in the project directory.
+It can either be a symbolic link, or a copy shipped with the project
+(it is designed to be independent).
+This first part is unnecessary if you used `mksymlinks`:
+
+ cd /path/to/example.com/config
+ ln -s /path/to/symfttpd/genconf ./lighttpd.php
+
+lighttpd config:
+
+ $HTTP["host"] == "example.com" {
+ include_shell "/path/to/example.com/config/lighttpd.php"
+ }
+
+
### Available options
* `-d <app>` (default): Change the default application (default being `index`)
@@ -189,6 +201,7 @@ Also, don't forget to run `php symfony plugin:publish-assets`, or even better,
(useful for allowing a `_dev` alternative, for example)
* `-n <dir1,dir2>` (nophp): Deny PHP execution in the specified directories
(default being `uploads`).
+* `-p <path>` (path): Path of the `web` directory. Autodected to ../web if not present.
For portability reasons, only short options (one letter) are used.
diff --git a/data/lighttpd.conf.php b/data/lighttpd.conf.php
index 936e48f..6c03c62 100644
--- a/data/lighttpd.conf.php
+++ b/data/lighttpd.conf.php
@@ -46,5 +46,5 @@ accesslog.filename = "<?php echo $log_dir ?>/access.log"
debug.log-file-not-found = "enable"
debug.log-request-header-on-error = "enable"
-include_shell "<?php echo $php_cmd ?> <?php echo escapeshellarg($project_path.'/'.$genconf) ?>"
+include_shell "<?php echo $genconf_cmd ?>"
diff --git a/genconf b/genconf
index 45b6c93..e901262 100755
--- a/genconf
+++ b/genconf
@@ -6,14 +6,15 @@
error_reporting(E_ALL|E_STRICT);
-$opts = getopt('d:oa:n:');
+$opts = getopt('d:oa:n:p:');
$opt_keys = array(
'd'=>'default',
'o'=>'only',
'a'=>'allow',
'n'=>'nophp',
+ 'p'=>'path',
);
-$options = array('default'=>'index', 'allow'=>false, 'nophp'=>false);
+$options = array('default'=>'index', 'allow'=>false, 'nophp'=>false, 'path'=>null);
foreach ($opts as $kopt => $opt)
{
$options[$opt_keys[$kopt]] = $opt;
@@ -25,11 +26,13 @@ $options['allow'] = $options['allow']
$options['nophp'] = $options['nophp']
? explode(',', $options['nophp'])
: array('uploads');
+$options['path'] = $options['path']
+ ? realpath($options['path'])
+ // Not using __FILE__ since it resolves symlinks
+ : realpath(dirname($argv[0]).'/../web');
-// Not using __FILE__ since it resolves symlinks
-$path = realpath(dirname($argv[0]).'/../web');
$files = array('dir'=>array(), 'php'=>array(), 'file'=>array());
-foreach (new DirectoryIterator($path) as $file)
+foreach (new DirectoryIterator($options['path']) as $file)
{
$name = $file->getFilename();
if ($name[0] != '.')
@@ -53,7 +56,7 @@ foreach ($options['allow'] as $name)
$files['php'][] = $name.'.php';
}
?>
-server.document-root = "<?php echo $path ?>"
+server.document-root = "<?php echo $options['path'] ?>"
url.rewrite-once = (
<?php foreach ($files['dir'] as $name): ?>
diff --git a/spawn b/spawn
index bc775e4..7cbb076 100755
--- a/spawn
+++ b/spawn
@@ -82,6 +82,10 @@ catch (ExecutableNotFoundError $e)
exit(1);
}
+if ($options['genconf_cmd'] === false)
+{
+ $options['genconf_cmd'] = $options['php_cmd'].' '.escapeshellarg(realpath(dirname(__FILE__)).'/genconf').' -p '.escapeshellarg($options['project_path'].'/web');
+}
Template::writeConfig($options);
// Pretty information. Nothing interesting code-wise.
@@ -137,7 +141,7 @@ else
$prev_genconf = null;
while (false !== sleep(1))
{
- $handle = popen($options['php_cmd'].' '.$project_path.'/config/lighttpd.php', 'r');
+ $handle = popen($options['genconf_cmd'], 'r');
$genconf = stream_get_contents($handle);
pclose($handle);
if ($prev_genconf !== null && $prev_genconf !== $genconf)
diff --git a/symfttpd.conf.php b/symfttpd.conf.php
index 515195c..7c7872a 100644
--- a/symfttpd.conf.php
+++ b/symfttpd.conf.php
@@ -117,6 +117,12 @@ $options['php_cmd'] = realpath(PHP_BINDIR.'/php');
$options['php_cgi_cmd'] = realpath(PHP_BINDIR.'/php-cgi');
/**
+ * Command to generate the docroot and rewriting config.
+ * @var string|false false to use included genconf tool with default parametrs
+ */
+$options['genconf_cmd'] = false;
+
+/**
* Default server template path
* @var string|null null to autodetect (try to find "php-cgi" in the path)
*/