据我所知,如果扩展use Symfony\Bundle\FrameworkBundle\Controller\Controller;
namespace Park\PurchaseBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class PurchaseController extends Controller
{
public function indexAction(Request $request) {
$em = $this->getDoctrine()->getManager();
}
}
,则应在Controller中提供Etity Manager。但由于未知原因,这对我没有用处:
Attempted to call an undefined method named "getManager" of class "Doctrine\Bundle\DoctrineBundle\Registry".
Did you mean to call e.g. "getManagerForClass", "getManagerNames", "getManagers" or "resetManager"?
Symfony的app_dev显示错误
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
);
...
return $bundles;
}
}
App_Kernel.php看起来不错
composer update
我可能错过了什么重要的东西?
修改
这是一个由我不知道的人制作的旧项目。它是在Symfony v2.1上制作的,现在我试图将其升级到v2.7。我已经更新了composer.json并完成了$this->getDoctrine()->getEntityManager()
而没有任何警告。现在使用来自Symfony调试应用程序的空白屏幕使用$this->getDoctrine()->getManager()
而不是[Mon Sep 19 18:15:16.821608 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP Stack trace:, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821614 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 1. {main}() /home/user/www/park/web/app_dev.php:0, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821619 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 2. Symfony\\Component\\HttpKernel\\Kernel->handle() /home/user/www/park/web/app_dev.php:34, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821626 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 3. Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel->handle() /home/user/www/park/app/bootstrap.php.cache:2480, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821632 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 4. Symfony\\Component\\HttpKernel\\HttpKernel->handle() /home/user/www/park/app/bootstrap.php.cache:3269, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821638 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 5. Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw() /home/user/www/park/app/bootstrap.php.cache:3115, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821644 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 6. call_user_func_array:{/home/user/www/park/app/bootstrap.php.cache:3156}() /home/user/www/park/app/bootstrap.php.cache:3156, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821650 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 7. Mediapark\\UserBundle\\Controller\\UserController->editAction() /home/user/www/park/app/bootstrap.php.cache:3156, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821657 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 8. Doctrine\\Bundle\\DoctrineBundle\\Registry->getEntityManager() /home/user/www/park/src/Mediapark/UserBundle/Controller/UserController.php:54, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821677 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 9. Doctrine\\Bundle\\DoctrineBundle\\Registry->getEntityManager() /home/user/www/park/app/cache/dev/classes.php:7635, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821685 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 10. Doctrine\\Bundle\\DoctrineBundle\\Registry->getEntityManager() /home/user/www/park/app/cache/dev/classes.php:7635, referer: http://192.168.100.8/park/app_dev.php/admin/users
[Mon Sep 19 18:15:16.821693 2016] [:error] [pid 16040] [client 192.168.100.8:36756] PHP 11. Doctrine\\Bundle\\DoctrineBundle\\Registry->getEntityManager() /home/user/www/park/app/cache/dev/classes.php:7635, referer: http://192.168.100.8/park/app_dev.php/admin/users
...
服务器崩溃。这是Apache输出到error.log文件:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.7.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"Trsteel/ckeditor-bundle": "~1.6",
"stof/doctrine-extensions-bundle": "~1.1@dev",
"symfony/intl": "2.8.*",
"sensio/generator-bundle": "~2.3",
"jms/security-extra-bundle": "1.6.*",
"jms/di-extra-bundle": "1.8.*",
"gedmo/doctrine-extensions": "<=2.3.x-dev",
"phpunit/phpunit": "3.7.*",
"behat/symfony2-extension": "1.1.0",
"behat/mink-extension": "1.2.0",
"behat/mink-browserkit-driver": "1.1.0",
"behat/mink-zombie-driver": "1.1.0",
"hwi/oauth-bundle": "0.4",
"hipchat/hipchat-php": "dev-master",
"inori/banklink" : "0.2.4",
"exercise/htmlpurifier-bundle": "*"
},
这里的composer.json需要部分:
np.linalg.inv(X)