Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Latest commit

 

History

History
99 lines (79 loc) · 2.92 KB

embedding.md

File metadata and controls

99 lines (79 loc) · 2.92 KB

Embedding the hazdev-template in another project

npm install grunt-connect-rewrite --save-dev
npm install hazdev-template --save-dev

Gruntfile configuration

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);
};

NOTE: This overrides the default php configuration

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

Configure grunt-connect-rewrite module:

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')
                            ];
                    }
            }
    }
 }

Site configuration

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.