0

Here is the problem : I don't succeed to install stof bundle with symphony 2.0

How I proceed :

I add this lines in deps file :

[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

Then I run the command

php bin/vendors install --reinstall

All is fine.

Then I activate extensions in concerned files

# 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', 
    [...]
    ));

At last, I add my entity Category, as in this tutorial http://gediminasm.org/article/tree-nestedset-behavior-extension-for-doctrine-2#including-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;
}

But when I run the command php app/console generate:doctrine:entities MyProjectMyBundle:Category, I have the following error :

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

And sometimes this one :

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

What do I do wrong ?

Carlos Granados
  • 11,273
  • 1
  • 38
  • 44
Reveclair
  • 2,399
  • 7
  • 37
  • 59
  • Can you convert this in Megabytes? Also, if you get no stack trace, then please install xdebug – greg0ire Oct 13 '12 at 15:10
  • It's on your local machine? Or on the server? – Max Małecki Oct 13 '12 at 17:20
  • Not sure it has nothing to do, but the documentation says"Adding DoctrineExtensionsBundle to your mapping is not needed if you use the auto_mapping setting" and "The mapping is only needed when using the Translatable or the Loggable behaviors. If you don't use any of them, you can disable it to avoid creating the tables even when using auto_mapping". So I woul use `StofDoctrineExtensionsBundle: false` – Carlos Granados Oct 13 '12 at 17:40
  • I wonder why you get an error at XmlDriver.php if you are not using XML mappings and are using annotations. Or are you using XML somehow? – Carlos Granados Oct 13 '12 at 17:44
  • Why do you use those specific versions of the libraries? – Carlos Granados Oct 13 '12 at 17:45

2 Answers2

1

I would say that these errors have nothing to do with Symfony nor Doctrine. To me it's more like a PHP configuration issue.

You can try to increase the memory_limit value in your php.ini file. A memory limit of 128MB should suffice in most cases but if your project is handling a lot of data it may need more.

Juan Sosa
  • 5,262
  • 1
  • 35
  • 41
0

Try to load only the tree extention:

doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    gedmo_tree:
                       type: annotation
                       prefix: Gedmo\Tree\Entity
                       dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
                       alias: GedmoTree # this one is optional and will default to the name set for the mapping
                       is_bundle: false

As the documentation says: https://github.com/stof/StofDoctrineExtensionsBundle/blob/master/Resources/doc/index.rst#add-the-extensions-to-your-mapping

Max Małecki
  • 1,700
  • 2
  • 13
  • 18