我正在使用 using 和库创建一个REST API,PHP但是Composer当coffeecode/datalayer我尝试加载我的类时,我收到Class not found 错误,当我dump-autoload在终端上键入时,我得到Generated autoload files contains 0 classes作曲家.json{ "name": "bruno_monteiro/restapi_php", "description": "Simple PHP REST API", "type": "project", "require": { "coffeecode/datalayer": "1.1.*" }, "license": "MIT", "authors": [ { "name": "Bruno Monteiro", "email": "" } ], "minimum-stability": "stable", "autoload": { "psr-4": { "Source\\": "source/" } }}模型namespace Source\Models;final class Validations{ ...}控制器(发生错误的地方)namespace Source\Controllers;require "../../vendor/autoload.php";require "../Config.php";use Source\Models\Validations;switch($_SERVER["REQUEST_METHOD"]){case "POST": $data = json_decode(file_get_contents("php://input"), false); if(!$data){ header("HTTP/1.1 400 Bad Request"); echo json_encode(array( "response"=>"Nenhum dado informado" )); exit; } $errors = array(); if(!Validations::validateString($data->first_name)){ array_push($errors, "Nome informado inválido"); } ...目录结构│ composer.json│ composer.lock│ Script.sql│├───source│ │ Config.php│ ││ ├───Controllers│ │ User.php│ ││ └───Models│ User.php│ Validations.php│└───vendor │ autoload.php │ ├───coffeecode │ └───datalayer │ │ composer.json │ │ CONTRIBUTING.md │ │ LICENSE │ │ README.md │ │ │ ├───example │ │ │ db_config.php │ │ │ destroy_example.php │ │ │ find_example.php │ │ │ pdo_example.php │ │ │ save_example.php │ │ │ │ │ └───Models │ │ Address.php │ │ User.php │ │ │ └───src │ └───composer
添加回答
举报
0/150
提交
取消