Archives par mot-clé : supervisord

Win32Service 1.0.0 is available

Win32Service Logo
Win32Service Logo

The new version 1.0.0 of Win32Service extension for PHP is available.

Or

Win32Service is a PHP extension. The version 0.4.x is for PHP7 and the version 1.0.x is for PHP8. This extension provides a simple way to run your PHP script like a service into the Windows Service Manager. Win32Service is same as supervisorD or SystemD for Linux.

The PHP documentation for win32service is up to date.

The v1.0.0 change log

  • Add Win32ServiceException (extends Exception)
  • The return value is no longer false when call method with wrong parameters
    • win32_start_service_ctrl_dispatcher
    • win32_set_service_exit_mode
    • win32_set_service_exit_code
    • win32_set_service_status
    • win32_create_service
    • win32_delete_service
    • win32_get_last_control_message
    • win32_query_service_status
    • win32_start_service
    • win32_stop_service
    • win32_pause_service
    • win32_continue_service
    • win32_send_custom_control
  • Add check in array information provided to win32_create_service. On error, this method throw a ValueError.
  • For function win32_send_custom_control, the PHP error The control argument value is not between 128 and 255. is now throw on ValueError.
  • For all function needed the service name, a ValueError is throw if the string is empty.
  • The PHP Error This function work only when using the CLI SAPI and called into the service code. has been converted to Win32ServiceException for this method
    • win32_start_service_ctrl_dispatcher
    • win32_set_service_exit_mode
    • win32_set_service_exit_code
    • win32_set_service_status
    • win32_get_last_control_message
  • The PHP Warning Service ctrl dispatcher already running has been converted to Win32ServiceException.
    This exception is throw if function win32_start_service_ctrl_dispatcher is called when the control dispatcher is already started.
  • The PHP Warning Failed to start dispatcher thread has been converted to Win32ServiceException.

Edit on December 1, 2020 : I have updated this blog post to add download pre-built DLL links.

More blogpost about Win32Service

Win32Service 1.0.0-alpha2 is available

Win32Service Logo
Win32Service Logo

The new version 1.0.0-alpha2 of Win32Service extension for PHP is available for test.

Win32Service is a PHP extension. The version 0.4.x is for PHP7 and the version 1.0.x is for PHP8. This extension provides a simple way to run your PHP script like a service into the Windows Service Manager. Win32Service is same as supervisorD or SystemD for Linux.

The v1.0.0-alpha2 change log

  • Add Win32ServiceException (extends Exception)
  • The return value is no longer false when call method with wrong parameters
    • win32_start_service_ctrl_dispatcher
    • win32_set_service_exit_mode
    • win32_set_service_exit_code
    • win32_set_service_status
    • win32_create_service
    • win32_delete_service
    • win32_get_last_control_message
    • win32_query_service_status
    • win32_start_service
    • win32_stop_service
    • win32_pause_service
    • win32_continue_service
    • win32_send_custom_control
  • Add check in array information provided to win32_create_service. On error, this method throw a ValueError.
  • For function win32_send_custom_control, the PHP error The control argument value is not between 128 and 255. is now throw on ValueError.
  • For all function needed the service name, a ValueError is throw if the string is empty.
  • The PHP Error This function work only when using the CLI SAPI and called into the service code. has been converted to Win32ServiceException for this method
    • win32_start_service_ctrl_dispatcher
    • win32_set_service_exit_mode
    • win32_set_service_exit_code
    • win32_set_service_status
    • win32_get_last_control_message
  • The PHP Warning Service ctrl dispatcher already running has been converted to Win32ServiceException.
    This exception is throw if function win32_start_service_ctrl_dispatcher is called when the control dispatcher is already started.
  • The PHP Warning Failed to start dispatcher thread has been converted to Win32ServiceException.

The release 1.0.0-alpha2 on the GitHub project

The next version of Win32Service

Win32Service Logo
Win32Service Logo

I work in my free time to improve the win32service extension to make it great and easier to use. The future version is 1.0.0 only for PHP 8.

I’m excited about this future version.

What is the planned changes?

This extension needs a little cleanup. In many cases, the Windows version is checked. All this check will be removed because VS16 is used to build PHP 8 and this extension works only on Windows 7 SP1 and newer or Windows 2012 R2 or newer.

With PHP 8 a new ValueError exception is available. Many checks will be added to improve the work of this extension. Especially the win32_create_service function.

And the last, same as many other functions in PHP extensions, all function who returns an error code will be changed to throw an exception. All PHP Errors and some PHP Warning will be changed by throwing an exception.

What is the side effect to change?

You need to change your code when you upgrade your project to PHP 8.

The Win32Service project provides a PHP library and a Symfony Bundle. Both will be upgraded to PHP 8 on a new major version.

My Actual To-do List

All this plan needs more work. This is my to-do list but you can help me.

  • Upgrade the extension code.
  • Write more tests for the extension.
  • Update the English PHP documentation for Win32Service.
  • Update the French PHP documentation for Win32Service.
  • Update the PHP library win32service/service-library.
  • Update the Symfony Bundle win32service/win32servicebundle.
  • Update the example project.

Help me

You can help me in many ways:

You are interested in this project, but you cannot help in this way, you can buy a day of work. Please contact me.

Or ping me to encourage me.

The new Win32Service library

Today, I want to write a new blog post for a new library. This library is written in PHP and need the Win32Service extension for PHP.

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 ?