Forum > Networking and Web Programming

Using pascal programs as backend for PHP based webpages?

(1/10) > >>

BosseB:
I have built a Raspberry Pi based data collection system and I have used FreePascal and Lazarus to program its control software running on the RPi.

This consists of a few console programs intended to be run by cron.
The data are managed inside an SQLite database (for which I have received good help on this forum!)

Now I want to build a configuration utility that will be web based (Apache2 on the RPi) and originally I thought that I would use PHP7 and straight HTML coding.
But that would mean to somehow re-create the database and other functions I have already developed in Pascal so it would work with PHP...
Not so fun.

Why web based?
Well, it makes it possible to use any computer with a web browser to configure the system when connected to the same network rather than logging on to the RPi itself, which is headless (no monitor or keyboard attached).


Question:
Is there some simple way to call processing functions written in Pascal from within PHP such that it can retrieve data to display to the user or execute commands and feed back results?

All I really want is read and write to the SQLite database and also scan a few directories for certain files, list and down/upload these.

Has someone here been there and done that and is willing to share the experience?

PaulRowntree:
Ignorant question coming ...Why do you need the PHP intermediate layer? 

MarkMLl:
I'd suggest https://wiki.freepascal.org/CGI_Web_Programming and related pages.

I've just set up a very simple webpage on a server run by our ISP which will eventually be a portal to various backend stuff- probably in VMs. They don't support PHP etc but do support CGI, and I wrote a simple script in Perl which expands SSIs in a page passed as the parameter and emits the result.

MarkMLl

bee:
You don't need to use PHP to make web apps. Just use Pascal directly, either as CGI, FastCGI, or Apache module. Free Pascal provides fpWeb framework for everything you need to make web apps. I've made lots of web apps using FPC since like 15 years ago. I've never need PHP or nodeJS or any non-Pascal language for that. Now it's even better, Free Pascal has a sister project named pas2js that convert pascal program into javascript. So, you can even write the front-end side using pascal as well. Isn't that awesome? 😊

BosseB:

--- Quote from: PaulRowntree on December 15, 2019, 06:22:43 pm ---Ignorant question coming ...Why do you need the PHP intermediate layer?

--- End quote ---
Because that is the only way I (kind of) know how to use for programming stuff on webpages...
There is a way to call an external executable on the webserver from PHP and somehow retrieve the result, I guess. Since I have written a number of related utilities in pascal and compiled for Raspbian they are available to be called. Only I don't really know how to extract the result from them...

Navigation

[0] Message Index

[#] Next page

Go to full version