symfonyの説明で、AbstractControllerを参照しますので名前空間を追加します、として
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
と書かれているけど、それはどこにあるのよ、という話。
常識なのかもしれないけど、悩んだ。
composer.jsonには、
"autoload": {
"psr-4": {
"App\": "src/"
}
},
とあるだけ。
\vendorにautoload.phpというのがあって、中は、'/composer/autoload_real.php';
で、その autoload_real.phpには、
autoload_namespaces.php、autoload_psr4.php、autoload_classmap.php、autoload_files.php
など、怪しいファイル名の記述が並ぶ。
中でも、 autoload_psr4.php が怪しい。 中身は、
'phpDocumentor\Reflection\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'),
'Webmozart\Assert\' => array($vendorDir . '/webmozart/assert/src'),
'Twig\Extra\TwigExtraBundle\' => array($vendorDir . '/twig/extra-bundle'),
'Twig\' => array($vendorDir . '/twig/twig/src'),
'Symfony\Polyfill\Php81\' => array($vendorDir . '/symfony/polyfill-php81'),
'Symfony\Polyfill\Php80\' => array($vendorDir . '/symfony/polyfill-php80'),
'Symfony\Polyfill\Php73\' => array($vendorDir . '/symfony/polyfill-php73'),
'Symfony\Polyfill\Php72\' => array($vendorDir . '/symfony/polyfill-php72'),
'Symfony\Polyfill\Mbstring\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\Polyfill\Intl\Normalizer\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),
'Symfony\Polyfill\Intl\Idn\' => array($vendorDir . '/symfony/polyfill-intl-idn'),
'Symfony\Polyfill\Intl\Icu\' => array($vendorDir . '/symfony/polyfill-intl-icu'),
'Symfony\Flex\' => array($vendorDir . '/symfony/flex/src'),
'Symfony\Contracts\Translation\' => array($vendorDir . '/symfony/translation-contracts'),
'Symfony\Contracts\Service\' => array($vendorDir . '/symfony/service-contracts'),
'Symfony\Contracts\HttpClient\' => array($vendorDir . '/symfony/http-client-contracts'),
'Symfony\Contracts\EventDispatcher\' => array($vendorDir . '/symfony/event-dispatcher-contracts'),
'Symfony\Contracts\Cache\' => array($vendorDir . '/symfony/cache-contracts'),
'Symfony\Component\Yaml\' => array($vendorDir . '/symfony/yaml'),
'Symfony\Component\WebLink\' => array($vendorDir . '/symfony/web-link'),
'Symfony\Component\VarExporter\' => array($vendorDir . '/symfony/var-exporter'),
'Symfony\Component\VarDumper\' => array($vendorDir . '/symfony/var-dumper'),
'Symfony\Component\Validator\' => array($vendorDir . '/symfony/validator'),
'Symfony\Component\Translation\' => array($vendorDir . '/symfony/translation'),
'Symfony\Component\Stopwatch\' => array($vendorDir . '/symfony/stopwatch'),
'Symfony\Component\Serializer\' => array($vendorDir . '/symfony/serializer'),
'Symfony\Component\Security\Http\' => array($vendorDir . '/symfony/security-http'),
'Symfony\Component\Security\Guard\' => array($vendorDir . '/symfony/security-guard'),
'Symfony\Component\Security\Csrf\' => array($vendorDir . '/symfony/security-csrf'),
'Symfony\Component\Security\Core\' => array($vendorDir . '/symfony/security-core'),
'Symfony\Component\Routing\' => array($vendorDir . '/symfony/routing'),
'Symfony\Component\PropertyInfo\' => array($vendorDir . '/symfony/property-info'),
'Symfony\Component\PropertyAccess\' => array($vendorDir . '/symfony/property-access'),
'Symfony\Component\Process\' => array($vendorDir . '/symfony/process'),
'Symfony\Component\OptionsResolver\' => array($vendorDir . '/symfony/options-resolver'),
'Symfony\Component\Mime\' => array($vendorDir . '/symfony/mime'),
'Symfony\Component\Mailer\' => array($vendorDir . '/symfony/mailer'),
'Symfony\Component\Intl\' => array($vendorDir . '/symfony/intl'),
'Symfony\Component\Inflector\' => array($vendorDir . '/symfony/inflector'),
'Symfony\Component\HttpKernel\' => array($vendorDir . '/symfony/http-kernel'),
'Symfony\Component\HttpFoundation\' => array($vendorDir . '/symfony/http-foundation'),
'Symfony\Component\HttpClient\' => array($vendorDir . '/symfony/http-client'),
'Symfony\Component\Form\' => array($vendorDir . '/symfony/form'),
'Symfony\Component\Finder\' => array($vendorDir . '/symfony/finder'),
'Symfony\Component\Filesystem\' => array($vendorDir . '/symfony/filesystem'),
'Symfony\Component\ExpressionLanguage\' => array($vendorDir . '/symfony/expression-language'),
'Symfony\Component\EventDispatcher\' => array($vendorDir . '/symfony/event-dispatcher'),
'Symfony\Component\ErrorHandler\' => array($vendorDir . '/symfony/error-handler'),
'Symfony\Component\Dotenv\' => array($vendorDir . '/symfony/dotenv'),
'Symfony\Component\DomCrawler\' => array($vendorDir . '/symfony/dom-crawler'),
'Symfony\Component\DependencyInjection\' => array($vendorDir . '/symfony/dependency-injection'),
'Symfony\Component\Debug\' => array($vendorDir . '/symfony/debug'),
'Symfony\Component\CssSelector\' => array($vendorDir . '/symfony/css-selector'),
'Symfony\Component\Console\' => array($vendorDir . '/symfony/console'),
'Symfony\Component\Config\' => array($vendorDir . '/symfony/config'),
'Symfony\Component\Cache\' => array($vendorDir . '/symfony/cache'),
'Symfony\Component\BrowserKit\' => array($vendorDir . '/symfony/browser-kit'),
'Symfony\Component\Asset\' => array($vendorDir . '/symfony/asset'),
'Symfony\Bundle\WebServerBundle\' => array($vendorDir . '/symfony/web-server-bundle'),
'Symfony\Bundle\WebProfilerBundle\' => array($vendorDir . '/symfony/web-profiler-bundle'),
'Symfony\Bundle\TwigBundle\' => array($vendorDir . '/symfony/twig-bundle'),
'Symfony\Bundle\SecurityBundle\' => array($vendorDir . '/symfony/security-bundle'),
'Symfony\Bundle\MonologBundle\' => array($vendorDir . '/symfony/monolog-bundle'),
'Symfony\Bundle\MakerBundle\' => array($vendorDir . '/symfony/maker-bundle/src'),
'Symfony\Bundle\FrameworkBundle\' => array($vendorDir . '/symfony/framework-bundle'),
'Symfony\Bundle\DebugBundle\' => array($vendorDir . '/symfony/debug-bundle'),
'Symfony\Bridge\Twig\' => array($vendorDir . '/symfony/twig-bridge'),
'Symfony\Bridge\ProxyManager\' => array($vendorDir . '/symfony/proxy-manager-bridge'),
'Symfony\Bridge\PhpUnit\' => array($vendorDir . '/symfony/phpunit-bridge'),
'Symfony\Bridge\Monolog\' => array($vendorDir . '/symfony/monolog-bridge'),
'Symfony\Bridge\Doctrine\' => array($vendorDir . '/symfony/doctrine-bridge'),
'Sensio\Bundle\FrameworkExtraBundle\' => array($vendorDir . '/sensio/framework-extra-bundle/src'),
'Psr\Log\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\Link\' => array($vendorDir . '/psr/link/src'),
'Psr\Container\' => array($vendorDir . '/psr/container/src'),
'Psr\Cache\' => array($vendorDir . '/psr/cache/src'),
'ProxyManager\' => array($vendorDir . '/friendsofphp/proxy-manager-lts/src/ProxyManager'),
'Prophecy\' => array($vendorDir . '/phpspec/prophecy/src/Prophecy'),
'PhpParser\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
'PackageVersions\' => array($vendorDir . '/composer/package-versions-deprecated/src/PackageVersions'),
'Monolog\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'Laminas\Code\' => array($vendorDir . '/laminas/laminas-code/src'),
'Egulias\EmailValidator\' => array($vendorDir . '/egulias/email-validator/src'),
'Doctrine\SqlFormatter\' => array($vendorDir . '/doctrine/sql-formatter/src'),
'Doctrine\Persistence\' => array($vendorDir . '/doctrine/persistence/lib/Doctrine/Persistence'),
'Doctrine\ORM\' => array($vendorDir . '/doctrine/orm/lib/Doctrine/ORM'),
'Doctrine\Migrations\' => array($vendorDir . '/doctrine/migrations/lib/Doctrine/Migrations'),
'Doctrine\Instantiator\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'Doctrine\Inflector\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Inflector'),
'Doctrine\Deprecations\' => array($vendorDir . '/doctrine/deprecations/lib/Doctrine/Deprecations'),
'Doctrine\DBAL\' => array($vendorDir . '/doctrine/dbal/src'),
'Doctrine\Common\Lexer\' => array($vendorDir . '/doctrine/lexer/lib/Doctrine/Common/Lexer'),
'Doctrine\Common\Collections\' => array($vendorDir . '/doctrine/collections/lib/Doctrine/Common/Collections'),
'Doctrine\Common\Cache\' => array($vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache'),
'Doctrine\Common\Annotations\' => array($vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations'),
'Doctrine\Common\' => array($vendorDir . '/doctrine/common/lib/Doctrine/Common', $vendorDir . '/doctrine/event-manager/lib/Doctrine/Common', $vendorDir . '/doctrine/persistence/lib/Doctrine/Common'),
'Doctrine\Bundle\MigrationsBundle\' => array($vendorDir . '/doctrine/doctrine-migrations-bundle'),
'Doctrine\Bundle\DoctrineBundle\' => array($vendorDir . '/doctrine/doctrine-bundle'),
'DeepCopy\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
'App\Tests\' => array($baseDir . '/tests'),
'App\' => array($baseDir . '/src'),
だそうです。
確かに\vendor\symfony\framework-bundle\ControllerにAbstractController.phpありました。
ちなみに、 AbstractController.php に renderという関数はないけど、実装するControllerTrait内にあった。
わかりづらい。
PSR-4 autoloaderという仕組みらしく、知らなかったのは私だけ。