我尝试通过以下方式更新doctrine架构:
$ php bin/console doctrine:schema:update --force
而且我一直在:
PHP Fatal error: Uncaught
Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to
load class "FOSUserBundle" from namespace "App\FOS\UserBundle".
Kernel.php:
<?php
namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function getCacheDir()
{
return $this->getProjectDir().'/var/cache/'.$this->environment;
}
public function getLogDir()
{
return $this->getProjectDir().'/var/log';
}
public function registerBundles()
{
$bundles = array(
new FOS\UserBundle\FOSUserBundle(),
);
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
}
composer.json文件:
"autoload": {
"psr-4": {
"App\\": "src/",
"FOS\\": "vendor/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "test/"
}
FOSUserBundle.php命名空间是:
namespace FOS\UserBundle;
并没有工作,但namaspace App工作正常。我试过了:
$ composer dump-autoload
我究竟做错了什么?它仍然在FOS之前使用App命名空间。
您需要添加斜杠。
$bundles = array(
new \FOS\UserBundle\FOSUserBundle(),
);