phpenumsphp-extensionpeclspl

Error: Class 'SplEnum' not found in PHP 7


I have a project with PHP 7.3, under Windows 10. I use the PHP from Xampp.

I get the following error:

Fatal error: Uncaught Error: Class 'SplEnum' not found in [...]

for

class BanLevel extends SplEnum { ... }

It seems I am misunderstanding the docu:

  1. https://www.php.net/manual/en/class.splenum.php
  2. https://www.php.net/manual/en/spl.installation.php

This gives me the idea it should be included in my PHP artefact.

What am I missing?

UPDATE: The class.splenum.php page has gone offline. It is still available in Romanian, though:
https://www.php.net/manual/ro/class.splenum.php, or here:
https://php-legacy-docs.zend.com/manual/php5/en/class.splenum


Solution

  • It seems I checked the wrong documentation,
    this is the right one:
    https://www.php.net/manual/en/spl-types.installation.php

    It clarifies:

    This PECL extension is not bundled with PHP.

    A DLL for this PECL extension is currently unavailable.

    So I can't use SPLEnum under Windows, except I compile it into PHP.

    UPDATE:

    The spl-types.installation.php page does not exist on php.net anymore, but it is still available here:
    https://php-legacy-docs.zend.com/manual/php5/en/spl-types.installation