我有一个小项目,我使用symfony di component.now,我需要一个orm,所以我使用doctrine2 orm。当我调用EntityManager :: create()方法时,它将花费2秒!它是如此之慢,但我不热衷于解决它
我只使用symfony / dependency-injection,symfony / yaml,symfony / config和doctrine / orm
这是symfony yml文件:
services:
doctrine.config:
class: \Doctrine\ORM\Configuration
factory: ['\Doctrine\ORM\Tools\Setup',createAnnotationMetadataConfiguration]
arguments: [[<?php echo __DIR__?>'/models'],true]
doctrine.orm.em:
class: \Doctrine\ORM\EntityManager
factory: ['\Doctrine\ORM\EntityManager',create]
arguments: ['%database%','@doctrine.config']
这是我的bootstrap.php
require "vendor/autoload.php";
use EastSea\Kernel\Kernel;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
$app = new Kernel();
$loader = new YamlFileLoader($app, new FileLocator(__DIR__));
$loader->load('services.yml');
$app->compile();
return $app;
这是我的app.php部分:
$before = microtime(true);
require_once(__DIR__.'/../../dhsource/bootstrap.php');
$apkModel = new \Model\AndroidApk($entityManager);
$allApks = $apkModel->findAll();
$after = microtime(true);
echo ($after-$before). " admincp\n";