Why this library ? The goal is eased to use the Win32Service extension of separate clearly the two most important part provided by this extension.
The first part is the service management. This can be split in two subparts (register and unregister a service for first and start, pause, continue and stop the service in the second). There’s scripts need an elevated right on the server. Automatically, the security approach allows this usage only in the command line (cli SAPI).
The second part is the service running. This part assumes only the PHP script executed when the service state is « running ».
When you read the official documentation available in the PHP.net website, this different usage is not clearly defined. Many other points are in favor of the library. The full-oriented object is available with the library. An abstract class is provided for the service running. The access denied or service not found errors are converted in special exception and other errors in generic exception provided by the library.
In the execution case, the abstract class provides many hooks to execute some code before the changing of service state. The typical use case is opening a database connexion in start or continue, close-it in pause or stop…
Now with this library, you can write a Windows service easily.
The library is available here with examples. How did you manage your PHP service on Windows Server ?
Read also :
- Win32Service 1.0.1 is available
- Win32Service 1.0.0 is available
- Win32Service 1.0.0-alpha2 is available
- The next version of Win32Service
- Win32Service for PHP8
- There comes the time to upgrade.
- Win32Service 0.4 for PHP 7.4
- [Win32Service] PHP 7.0 and 7.1 support
- [Win32Service] Comment utiliser les paramètres de Récupération
- Win32Service Bundle
- Nouveautés de Win32Service 0.4
- Projet Win32Service
- The new Win32Service library
- Extension PHP pour réaliser des services Windows