PHP Extension website
This project provides most elements:
For the latest news for this project, search on Twitter the #Win32Service hashtag .
This extension provide a wrapper between Windows Service Manager and your PHP script. The PHP version supported by this extension is 7.1.1 and later. This extension work only for the Windows Build of PHP and with all variant (NTS/TS and 32/64 bit).
This extension requires the elevated privileges for work. However, you can delegate for some actions
You can download the pre-build extension from:
Unzip the package and copy the extention into the folder
ext of your PHP installation.
After copy, edit the the file
php.ini and add one line for load the extension depending on your version of PHP (7.1/7.2/7.3, x64/x86, ZTS/NTS). In example for PHP 7.3 in TS mode and 32 bit architecture :
extension = php_win32service-7.3-ts-vc14-x86.dll (or use the short name available since PHP 7.2 :
extension = win32service if the extension file is named
Check in command line if the extension is correctly loaded with this command
php --ri win32service.
If the output indicate this extension is not loaded, check the PHP configuration.
Note: The PHP version 7.1.0 dont work with this extension, use the latest version of PHP 7.1.
You can use this PHP service-library for implements your service runtime and management scripts. If you project is based on Symfony 4+, you can use the bundle to integrate the library into Symfony and reduce the number of codes do you need to write.
Otherwise , the downloaded zip contains examples scripts used for testing. The file
service.php contains a skeleton for implement one service in PHP.
To use this example, open a command line window in administrator mode. Go to the example folder and run this command
php service.php create to installing the test service.
Now a new service is added into the Windows service manager. You can start, stop this service from the Windows service manager or from the administrator command line.
Good coding !
Crash, feature request, or suggest, please open an issue.
Help for the extension function, visit the official PHP web site
Blog post: Nouveautés de Win32Service 0.4 [FR]