What is the best way to create a Singleton Webservice in PHP?

We need to access a database that allows only one connection at a time. It screams singleton for me. The trick, of course, is that a singleton connection will be opened (directly or indirectly) through a web service (the most likely SOAP-based web service) located on a separate server from the calling application (s)), which means that there may be more than one application / instance trying to connect to the singleton class.

In PHP, what's the best way to create a global singleton or singleton web service?

TIA

+3
source share
2 answers

PHP , "" , . - java " ". php "" ( ) - . -, $_SESSION, , php "". , , - .

, , Singleton, , , , , . , php, , , . Edit: , , , singleton, -, ? , , , . , , . , , 2 : 1) , .

2) , , , .

+3

" DB SERVER" .;-), ...

SoapServer , 1

$s1 = sem_get(123, 1);
sem_acquire($s1);

// soapserver code here

sem_release($s1); 
+4

Source: https://habr.com/ru/post/1745882/


All Articles