It should be mentioned that depending on the system, an module can be available.
On CentOS I just ran:
sudo yum install php73-php-sysvsem
then reload:
sudo service php-fpm reload (or apache, depending on your case)
and semaphore functions are now available.