这是问题:我没有成功安装 stof bundle with symphony 2.0
我如何进行:
我在 deps 文件中添加了这一行:
[GedmoDoctrineExtensions]
git=https://github.com/l3pp4rd/DoctrineExtensions.git
target=bundles/gedmo-doctrine-extensions
version=e93fc1e0a0
[StofDoctrineExtensionsBundle]
git=https://github.com/stof/StofDoctrineExtensionsBundle.git
target=bundles/Stof/DoctrineExtensions/Bundle
version=6b2a8c74bd
然后我运行命令
php bin/vendors install --reinstall
一切皆好。
然后我激活相关文件中的扩展名
# config.yml
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
tree: true
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
mappings:
StofDoctrineExtensionsBundle: ~
# AppKernel.php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
[...]
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
[...]
);
# autoload.php
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Gedmo' => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib',
'Stof' => __DIR__.'/../vendor/bundles',
[...]
));
最后,我添加了我的实体类别,如本教程http://gediminasm.org/article/tree-nestedset-behavior-extension-for-doctrine-2#include-extension
<?php
namespace Myproject\MyBundle\Entity;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
/**
* @Gedmo\Tree(type="nested")
* @ORM\Table(name="Category")
* use repository for handy tree functions
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
*/
class Category
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @ORM\Column(name="title", type="string", length=64)
*/
private $title;
/**
* @Gedmo\TreeLeft
* @ORM\Column(name="lft", type="integer")
*/
private $lft;
/**
* @Gedmo\TreeLevel
* @ORM\Column(name="lvl", type="integer")
*/
private $lvl;
/**
* @Gedmo\TreeRight
* @ORM\Column(name="rgt", type="integer")
*/
private $rgt;
/**
* @Gedmo\TreeRoot
* @ORM\Column(name="root", type="integer", nullable=true)
*/
private $root;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
* @ORM\OrderBy({"lft" = "ASC"})
*/
private $children;
}
但是当我运行命令 php app/console generate:doctrine:entities MyProjectMyBundle:Category 时,出现以下错误:
Fatal error: Out of memory (allocated -1227096064) (tried to allocate 261900 bytes) in /home/user/Project/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php on line 75
有时这个:
Fatal error: Out of memory (allocated -1222901760) (tried to allocate 261900 bytes) in /home/user/Project/vendor/gedmo-doctrine-extensions/lib/Gedmo/Mapping/MappedEventSubscriber.php on line 176
我做错了什么?