-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New notifer for Linux which use libnotify and PHP-FFI #100
Conversation
Hi @morawskim. Thanks for your PR, it looks realy good. I will need to play a bit a with it but this is definitely something that could bin included in JoliNotif |
Hi @morawskim Do you have some time to finish this PR? It would be great to support a FFI-based notifier for linux environments. |
Yes, I will finish this PR. |
Hello @pyrech I wanted to write some additional unit tests, but FFI class is final, so we cannot create mock class. I checked some potential memory leaks lastly. Valgrind report some memory leak, but not in libnotify. |
Thanks for your work so far. About the tests, I understand it's not ideal to unit test the FFI part. Instead maybe we could just trigger the notifier for real and ensure there is no exception (and skip the tests when the notifier is not available). It would be better than nothing. What do you think about it? |
Thanks for suggestion @pyrech
I have considered this, but I was afraid that this will require a lots of dependencies and the image will be huge. But now.... Simple test:
Amazing, we don't need install desktop environment, only one library. Runt tests |
I just rebased your PR in order to have PHPStan running in the CI. I also:
It worked out of the box on my computer, so congrats for your PR. |
… tests
Thanks a lot for your contribution @morawskim 🙏 |
Hello
This PR add another notifier, which use FFI and libnotify.
Probably most of Linux notifier supported in this repository under the hood use this library.
This notifier has some advantages and disadvantages.
Support for FFI in PHP vary between distributions. Sometimes we need to install dedicated package.
In other hand can be slightly faster (we don't need to crate external process)
and more portable (we don't need external application, only libnotify).
FFI allows us to call C code from PHP script.
The FFI extension need to be installed to use this notifier.
Also support for FFI is only in CLI SAPI, due to security concerns.
At the moment I tested this notifier with:
All existing notifiers use external commands and maybe this new notifier does not meet project goals.
I decided to mark this PR as draft.
I can finish this PR if that notifier can be included in this package, otherwise you can close this PR.