でスリム3を使用しようとすると、私は次のようなメッセージが出ます:問題ドクトリン2
Slim Application Error
The application could not run because of the following error:
Details
Type: Error
Message: Class 'App\Action\InterventionsAction' not found
File: /var/www/html/ws_slim/public/index.php
Line: 53
Trace
#0 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#1 /var/www/html/ws_slim/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#2 /var/www/html/ws_slim/vendor/slim/slim/Slim/Route.php(344): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#3 /var/www/html/ws_slim/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#4 /var/www/html/ws_slim/vendor/slim/slim/Slim/Route.php(316): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#5 /var/www/html/ws_slim/vendor/slim/slim/Slim/App.php(476): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#6 /var/www/html/ws_slim/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#7 /var/www/html/ws_slim/vendor/slim/slim/Slim/App.php(370): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#8 /var/www/html/ws_slim/vendor/slim/slim/Slim/App.php(295): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#9 /var/www/html/ws_slim/public/index.php(59): Slim\App->run()
#10 {main}
私のインデックスファイルには、このようなものです:
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use App\Action\InterventionsAction;
require 'vendor/autoload.php';
$app = new \Slim\App([
'settings' => [
'displayErrorDetails' => true
]
]);
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello,, $name");
return $response;
});
$app->get('/api/interventions', function (Request $request, Response $response) {
$int = new InterventionsAction($em);
$response->getBody()->write("Hello,, ");
return $response;
});
$app->run();
とInterventionsActionは、このようなものです:
<?php
namespace App\Action;
use Doctrine\ORM\EntityManager;
final class InterventionsAction
{
private $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function fetch($request, $response, $args)
{
$interventions = $this->em->getRepository('App\Entity\Interventions')->findAll();
$interventions = array_map(
function ($interventions) {
return $interventions->getArrayCopy();
},
$interventions
);
return $response->withJSON($interventions);
}
}
ファイルツリー:
├── cli-config.php
├── composer.json
├── composer.lock
├── CONTRIBUTING.md
├── EXPORT
│ ├── Companies.php
│ ├── CompaniesPlansPayments.php
│ ├── CompaniesPlans.php
│ ├── DepartmentsCoordinators.php
│ ├── Departments.php
│ ├── InterventionclasificationDetails.php
│ ├── Interventionclasifications.php
│ ├── Interventionrelations.php
│ ├── Interventions.php
│ ├── InterventiontypesCompanies.php
│ ├── Interventiontypes.php
│ ├── Locations.php
│ ├── LocationTypes.php
│ ├── Managementreview.php
│ ├── Managementreviewrelations.php
│ ├── Plans.php
│ ├── ServicelinesManagers.php
│ ├── Servicelines.php
│ ├── Users.php
│ └── Usertypes.php
├── logs
│ ├── app.log
│ └── README.md
├── nbproject
│ ├── private
│ │ └── private.properties
│ ├── project.properties
│ └── project.xml
├── phpunit.xml
├── public
│ └── index.php
├── README.md
├── src
│ ├── Action
│ │ └── InterventionsAction.php
│ ├── dependencies.php
│ ├── Entity
│ │ ├── Companies.php
│ │ ├── CompaniesPlansPayments.php
│ │ ├── CompaniesPlans.php
│ │ ├── DepartmentsCoordinators.php
│ │ ├── Departments.php
│ │ ├── InterventionclasificationDetails.php
│ │ ├── Interventionclasifications.php
│ │ ├── Interventionrelations.php
│ │ ├── Interventions.php
│ │ ├── InterventiontypesCompanies.php
│ │ ├── Interventiontypes.php
│ │ ├── Locations.php
│ │ ├── LocationTypes.php
│ │ ├── Managementreview.php
│ │ ├── Managementreviewrelations.php
│ │ ├── Plans.php
│ │ ├── ServicelinesManagers.php
│ │ ├── Servicelines.php
│ │ ├── Users.php
│ │ └── Usertypes.php
│ ├── middleware.php
│ ├── routes.php
│ └── settings.php
├── templates
│ └── index.phtml
├── tests
│ └── Functional
│ ├── BaseTestCase.php
│ └── HomepageTest.php
└── vendor
├── autoload.php
├── bin
│ ├── doctrine -> ../doctrine/orm/bin/doctrine
│ ├── doctrine-dbal -> ../doctrine/dbal/bin/doctrine-dbal
│ ├── doctrine.php -> ../doctrine/orm/bin/doctrine.php
│ └── phpunit -> ../phpunit/phpunit/phpunit
├── composer
│ ├── autoload_classmap.php
│ ├── autoload_files.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ ├── ClassLoader.php
│ ├── installed.json
│ └── LICENSE
├── container-interop
│ └── container-interop
├── doctrine
│ ├── annotations
│ ├── cache
│ ├── collections
│ ├── common
│ ├── dbal
│ ├── inflector
│ ├── instantiator
│ ├── lexer
│ └── orm
├── monolog
│ └── monolog
├── myclabs
│ └── deep-copy
├── nikic
│ └── fast-route
├── phpdocumentor
│ ├── reflection-common
│ ├── reflection-docblock
│ └── type-resolver
├── phpspec
│ └── prophecy
├── phpunit
│ ├── php-code-coverage
│ ├── php-file-iterator
│ ├── php-text-template
│ ├── php-timer
│ ├── php-token-stream
│ ├── phpunit
│ └── phpunit-mock-objects
├── pimple
│ └── pimple
├── psr
│ ├── container
│ ├── http-message
│ └── log
├── sebastian
│ ├── code-unit-reverse-lookup
│ ├── comparator
│ ├── diff
│ ├── environment
│ ├── exporter
│ ├── global-state
│ ├── object-enumerator
│ ├── recursion-context
│ ├── resource-operations
│ └── version
├── slim
│ ├── php-view
│ └── slim
├── symfony
│ ├── console
│ ├── debug
│ ├── polyfill-mbstring
│ └── yaml
└── webmozart
└── assert
私の質問は、おそらく私はいくつかの設定値を設定していないか、探しているはずの何かがありますか?
ディレクトリ構造とオートローダーの設定(composer.json)を表示する必要がありますか? –
ここに完全なディレクトリをどのように表示できますか?私はそれらを別々にインストールしましたが、最初にSlimを入手してコマンドプロンプトで教訓をインストールしましたので、作者がいませんでした。 – perodriguezl
これは盲目的な推測ですが、 use文の上に 'require 'vendor/autoload.php'がありますか?私は間違っているかもしれませんが、いずれにせよ、エラーメッセージには 'App \ Action \ InterventionsAction'クラスが見つかりませんので、これはDoctrineの問題よりディレクトリ構造/ファイルの命名/自動読み込み問題の方が多いと思います。少なくとも、問題の領域をゼロにするのに役立つはずです。 – stratedge