Getting Started

We are in the most fun section! Here you will understand how to create and start your PHP server.

Creating the main file

We need to create a file called index.js in the project folder, this is where we will" create "our php server.

Editing index.js

Let's start! Open index.js with any text editor and enter the code below:

var php = require('easyphp');

php.start(80, function() {
    console.log('(PHP) Server started');
})

In the code above, we defined that we need EasyPHP to start the server withvar php = require ('easyphp'); After that, we added the function to start the server, editing the port and an extra function to be called when the server starts.

php.get('/home/', 'home.php')

The get you can use to define unique URL's. for example, as shown above, if I go to mywebsite.com/home/ it will return home.php

php.all('error404.html', function () {
console.log('Page accessed!')
})

All will get all folders and subfolders that contain php files to be read according to the URL. For example: mywebsite.com/home/about If there is a folder named home and a php file called about, it will return about.php in case he doesn't find it, it will return index.php.

Last updated