npm install grunt-connect-rewrite --save-dev
npm install hazdev-template --save-dev
NOTE: Plus (+) characters are added to the beginning of lines to highlight lines being added to the gruntfile, but are not part of the content that should be added.
Configure php include path, by updating the mountPHP middleware function:
var mountPHP = function (dir, options) {
+ options = options || {
+ '.php': 'php-cgi',
+ 'env': {
+ 'PHPRC': process.cwd() + '/node_modules/hazdev-template/dist/conf/php.ini'
+ }
+ };
return gateway(require('path').resolve(dir), options);
};
This may include custom extensions or other PHP settings, these should be re-added to the php.ini file that is loaded from the template. For example, to add the PDO Sqlite and init_curl extensions:
extension_dir = C:\php55\ext
extension = php_pdo_sqlite.dll
extension = php_curl.dll
In each grunt task that uses connect, add configureRewriteRules task before any connect:
grunt.registerTask('default', [
'clean:dist',
'compass:dev',
+ 'configureRewriteRules',
'connect:test',
'connect:dev',
'open:test',
'open:dev',
'watch'
]);
At top of Gruntfile, add this:
+ var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
In the connect section, add a rules property to configure template rewrites; add the rewriteRulesSnippet middleware and mount the node_modules folder
connect: {
options: {
hostname: 'localhost'
},
+ rules: [
+ {
+ from: '^/theme/(.*)$',
+ to: '/hazdev-template/src/htdocs/$1'
+ }
+ ],
dev: {
options: {
base: '<%= app.src %>/htdocs',
port: 8080,
middleware: function (connect, options) {
return [
lrSnippet,
mountFolder(connect, '.tmp'),
mountPHP(options.base),
mountFolder(connect, options.base),
+ rewriteRulesSnippet,
+ mountFolder(connect, 'node_modules')
];
}
}
}
}
See Site Configuration for information on configuring a
template theme and site. The effective DOCUMENT_ROOT is often src/htdocs
, for
_config.inc.php
, but may vary.