Search code examples
phpsoaplaminas

Undefined const "Laminas\Soap\SOAP_1_2"


i'm starting with Soap in PHP and i have a little problem with the Laminas framework, who throw this error.

Error of PHP

and this is the code

<?php

// api.php

require_once __DIR__ . '/vendor/autoload.php';

class Hello
{
    /**
     * Say hello.
     *
     * @param string $firstName
     * @return string $greetings
     */
    public function sayHello($firstName)
    {
        return 'Hello ' . $firstName;
    }

}

$serverUrl = "http://localhost/soap.php";
$options = [
    'uri' => $serverUrl,
];
$server = new \Laminas\Soap\Server(null, $options); // This line throw the error
// Code...

Thanks for your answer.


Solution

  • The error is Undefined constant Laminas\Soap\SOAP_1_2. The constant SOAP_1_2 is defined in the PHP SOAP extension. Laminas just use it.

    Check if Soap is enabled in the output of phpinfo(), and enable it if it is not.