I have a project with this structure:
config.php -> I define some constant
autoload.php -> require config.php + require all my class
api.php -> I require autolaod.php
index.php -> I require api.php
define( "LIB_PATH", "lib" );
define( "CLASS_PATH", "class" );
require( LIB_PATH . "/jwt.php" );
require( CLASS_PATH . "/progetto.php" );
require( CLASS_PATH . "/azienda.php" );
require( CLASS_PATH . "/entrata.php" );
require( CLASS_PATH . "/uscita.php" );
require( CLASS_PATH . "/user.php" );
From what you wrote, the api.php doesn't have class/user.php required. class/user.php is required only in index.php (through autoload.php) and in api.php (directly).
The solution is to add
require('./class/user.php') in the api.php file.
Good approach would be to have all requires of class files in the autoload.php and require the autoload to index.php, api.php, and all other new files where needed.
The edit in the answer now looks like good solution.