Home » Php » javascript – Using client js file in php

javascript – Using client js file in php

Posted by: admin February 25, 2020 Leave a comment


I have a website with PHP in the background. I would like to access the hafas interface of the german railway. It has the following library which is written in js:

is it possible to use the functions via php? I would like to send a request to the API using the files to get the result. As JS example this has to be done:

const createClient = require('hafas-client')
const dbProfile = require('hafas-client/p/db')

// create a client with the Deutsche Bahn profile
const client = createClient(dbProfile, 'my-awesome-program')
// Berlin Jungfernheide to München Hbf
client.journeys('8011167', '8000261', {results: 1})
  1. is it possible to access the files via php (JS is clientside)
  2. Or do I have to rebuild the queries in php.
  3. Or is there an alternative solution

Thank you very much,
Have a nice day

How to&Answers: