PHP + Delphi(Pascal), issue real-time warnings

Question:

I would like to design a system, small and simple, coded in the Pascal language (IDE delphi), to receive notifications (such as a warning that some event has occurred), when receiving the warning, playing some sound.

I understand a little about Delphi, it was one of the languages ​​I started just out of curiosity, but I ended up dropping it after I came to the WEB platform.

I don't know if it's possible to create something with PHP + Delphi, something like sending an email, the software capturing and sending some alert (like a sound) to the client.

I wish it was possible to link Delphi with PHP, but I don't know if it's possible to interact a web platform language with another one that isn't, in a direct way.

Answer:

I suggest the following architecture: – WebService PHP on the server; – Desktop application, Delphi, querying the server's WS.

For the desktop application, there's no secret, use the Timer, and make the application stay there in Windows Tray, you can use this component: QTrayIcon .

For server calls, you can use the Indy library.

On the server, in PHP it's simple for you to make a simple WebService that reads the call via GET and returns whether changes were made or not, you can return with a JSON, containing the desired responses, something like this:

.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pg=$1

Simple WS example:

<?php
header("Access-Control-Allow-Origin: *");

$dadosRecebidos = $_GET['pg']);

switch ($_SERVER['REQUEST_METHOD']) {
    case 'GET':
        if ($dadosRecebidos[0] == TESTE){
            echo json_encode(array(MSG_OK, "CONEXAO OK"));
    case ...
...

I also suggest migrating from Delphi to Lazarus , all open-source !

Scroll to Top