php-crud-api: Tqdev\\PhpCrudApi\\Config not found

Hi,

I got a very weird error, the API was working well for weeks, but then one time I see the API shows some kind of server error.

I checked the apache logs and find

PHP Fatal error:  Uncaught Error: Class "Tqdev\\PhpCrudApi\\Config" not found in api.php:12140

\nStack trace:\n#0 {main}\n  thrown in api.php on line 12140

It’s very weird that the error throws on the new Config, would you know the cause of the issue? I just did an apache restart and it was fine then.

Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 27 (13 by maintainers)

Most upvoted comments

This may be related to your PHP version. Can you report which PHP version you use?

@mevdschee

Doesn’t work for PHP v8.2, v8.1, v7.2 either

This may be related to your PHP version. Can you report which PHP version you use?

8.2

@mevdschee Sure, here’s the part:


namespace Tqdev\PhpCrudApi {

    use Tqdev\PhpCrudApi\Api;
    use Tqdev\PhpCrudApi\Config;
    use Tqdev\PhpCrudApi\RequestFactory;
    use Tqdev\PhpCrudApi\ResponseUtils;

    $config = new Config([
        'driver' => 'mysql',
        'address' => '172.18.30.1',
        'port' => '3306',
        'username' => '5023f6a54fe42c64',
        'password' => '6b7f11d039f29fb400284fbc610f7ec38b0a6cd2f6cfe043',
        'database' => '5023f6a54fe42c64',
        'debug' => true,
        'middlewares' => 'json'
    ]);

    $request = RequestFactory::fromGlobals();
    $api = new Api($config);
    $response = $api->handle($request);
    ResponseUtils::output($response);
}

Hi @mevdschee ,

I’m seeing the same issue in a fresh Wordpress install:

PHP Fatal error: Uncaught Error: Class "Tqdev\\PhpCrudApi\\Config" not found in /public/api/api.php