Skip to content

How To Add Silex To Your Node.js Project

Alex Hoyau edited this page Jun 7, 2019 · 8 revisions

This document is a work in progress, we need your help, ask questions in the issues and add answers here please

Adding Silex to your nodejs project is useful if you plan to customize Silex. Here are the pages related to this one:

Here is the code which is explained in this page

Requirements

Check the node version supported by Silex, it is in the file .nvmrc here. It should support more recent nodejs version but it is not guaranteed.

If your project is a nodejs project you probably already have a package.json, if not use npm init to create one.

Install Silex as an npm dependency

$ npm install -S silex-website-builder

Create a start script

Create a file and name it index.js

const { SilexServer, Config } = require('silex-website-builder');

const config = new Config();
const silex = new SilexServer(config);

silex.start(function() {
  console.log('server started');
});

Start Silex

$ node index.js

Test Silex at the address http://localhost:6805/.

Also you may want to add this to your package.json so that it starts when you do npm start:

  ...
  "start": "node index.js",
  ...

Next steps

Now you can

WARNING: Support for Silex v2 has stopped. Try Silex v3 alpha, Read about it, Subscribe to the newsletter

Clone this wiki locally