Pim-community-dev: Doctrine proxy class not generated after adding a custom category property

Created on 15 Jun 2017  ·  15Comments  ·  Source: akeneo/pim-community-dev

I'm asking a Question

Hi,

I followed the cookbook to add a non translatable property to the category entity in 1.7.5 CE (ORM).

Everything works fine in the dev environment, but after switching to prod I'm facing app/cache/prod/doctrine/orm/Proxies/__CG__PimBundleCatalogBundleEntityCategory.php): failed to open stream: No such file or directory.

I tried to manually warmup the cache, but this only generates a doctrine proxy class for my new custom category entity that extends the BaseCategory. The only solution I found so far is to copy this proxy class to __CG__PimBundleCatalogBundleEntityCategory.php which is probably not exactly best practice ;-)

Could you give me a hint what I'm missing?

Thanks!

question

Most helpful comment

Hello @DavidFeller,

You can try to warm up your prod cache with the following command:
php app/console cache:warmup --env=prod --no-debug

Most of the time it fix cache issues.

Regards

All 15 comments

Hello @DavidFeller,

You can try to warm up your prod cache with the following command:
php app/console cache:warmup --env=prod --no-debug

Most of the time it fix cache issues.

Regards

Hello @momoss,

thank you for the quick answer! :)

Unfortunately that's what I tried several times already. It seems to work (no error output), but __CG__PimBundleCatalogBundleEntityCategory.php is still missing afterwards.
Additionally I checked the entity mappings via php app/console doctrine:mapping:info.

I know that this is rather a doctrine or symfony problem than really akeneo related, but I guess I'm missing a little detail in the AcmeCatalogBundle configuration in terms of overriding the BaseCategory.

Or do you think it's worse a try to downgrade php to 5.6?

Hello @DavidFeller,

After discussion with @damien-carcel, he advise me that there was missing something in the documentation, we have updated it yesterday.

Can you check in your Category class, maybe a method is missing:

public function getTranslationFQCN() { return CategoryTranslation::class; }

Regards

Hello @momoss,

Ah ok, I'll check that. I thought this method was only needed for the second part of the docs (translatable properties). Since I only added a checkbox I "ignored" that part. ;-)

I think I'll try to start over and create a translatable property.

Thanks for your help and regards,
David

I have got the same problem with the newest version 2.0. Exactly the same problem and I have followed the same docs.

And I have added the field as translatable. It is added to the database, but it still doesn't work in the production environment.
This is what I got from the productions server itself and I come up with the same error. ""Compile Error: require(): Failed opening required '/opt/bitnami/apps/akeneo/htdocs/var/cache/prod/doctrine/orm/Proxies/__CG__PimBundleCatalogBundleEntityCategory.php'

Hello @Nebojsaa .

Sorry to hear this cookbook doesn't work for you. I just fully tested it from a pim-community-standard, it works for me, there is only one mistake in the FormType regarding the widget: the old notation does not work anymore with Symfony 3.4.

You can see my code in this pull request https://github.com/damien-carcel/pim-community-standard/pull/1. The mistake I am talking about is in the last commit. I will update the documentation as soon as possible.

I didn't fully follow the cookbook: everything is placed in AppBundle and all services and parameters declared in services.yml. I also added PHP 7.1 typehint. But this doesn't change the validity of the cookbook (except for the textarea problem of course).

Please try to compare your code with mine, you probably forgot a service/parameter override.

Also, don't forget the code examples in the cookbook can be scrolled. I missed the setDescription method in the CategoryTranslation class at first.

Finally, don't forget to both clear your cache (fully remove it with rm -rf var/cache/*), restart FPM and only then update your Doctrine schema.

You can also have cache issues if the Akeneo queue daemon (for the imports/exports) is running: it will prevent your APC cache to be cleaned, and then pollute your Symfony cache again. If you are using the queue daemon, then the correct procedure is:

  • stop the daemon
  • rm -rf var/cache/*
  • restart FPM
  • start the daemon again
  • update your Doctrine schema

Btw, please do not post on closed issues, because nobody usually answer/see it. I only saw your comment because I was tagged in the conversation and had a GitHub notification about it. Please prefer opening a new issue and link the original one.

Let me know is this helped you.

Regards,
Damien

Hmmm, that's odd. I have done everything as suggested, but I can't get it to work. Also I am trying to add the category without translation. So I think that this didn't bother me.

[2018-01-12 05:55:50] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Compile Error: require(): Failed opening required '/opt/bitnami/apps/akeneo/htdocs/var/cache/prod/doctrine/orm/Proxies/__CG__PimBundleCatalogBundleEntityCategory.php' (include_path='.:/opt/bitnami/php/lib/php')" at /opt/bitnami/apps/akeneo/htdocs/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php line 209 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Compile Error: require(): Failed opening required '/opt/bitnami/apps/akeneo/htdocs/var/cache/prod/doctrine/orm/Proxies/__CG__PimBundleCatalogBundleEntityCategory.php' (include_path='.:/opt/bitnami/php/lib/php') at /opt/bitnami/apps/akeneo/htdocs/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:209)"} []

Regards,
Nebojsaa

pim_enrich.form.type.category.class is wrong, you are using Acme instead of your bundle.

Everything else is OK. I just used your bundle with a pim-community-standard 2.0, remove the routing (it is useless) and configure the entity override in app/config/config.yml. I was able to edit and save a category with your new fields without any issue.
I also needed to deactivate your validation on your field, or I couldn't install the icecat fixtures (you validate that your fields cannot be blank, but they don't exists in my fixtures 😉).

So I really think the problem comes from your server. And looking at the error in your previous post, it looks clearly as a problem of PHP cache. Something could be running on the bitnami server that prevent the cache from being cleared when you restart FPM.

Regards,
Damien.

Hey Damien,
All right, I was never a sys admin in my life. Now is the time.

Maybe some tips except those from up.
Do you know where how can I stop and start the daemon and restart fpm ?
I am using php 7.1.
Do you know which commands should I use ?

For restarting FPM, it will depend on your server. What Linux distribution are you using on it? Most of them now use systemd as init, so you should be able to restart FPM by running sudo systemctl restart php7.1-fpm (the name of the FPM process can change from a system to an other).

The queue is a simple php process that you can launch manually or using a supervisor. You can find detailed instructions here: https://docs.akeneo.com/latest/install_pim/manual/daemon_queue.html.

Hmm, have succeeded in the meantime.
Now it is displaying "Hello World!" - My Default index.html.twig ??

Oh yeah. Normal. You use the generate:bundle command, right?
You need to remove the view Default/index.html.twig, the controller and the routing from your bundle (don't forget to remove it from app/config/routing.yml too). They are useless.
Then it should work.

Next error :-D
No I am just joking..
Thank you very much.

buenos dias, saludos a todos. tengo un pequeño problema, estoy trabajando en un proyecto con Symfony 4, tengo la base de datos de mi proyecto en postgressql, instale dicho gestor, y estableci conexion con el con dicho framework, pero cuando trato de generar las entidades a partir de esa base de datos con el comando php bin/console doctrine:mapping:import "App\Entity" annotation --path=src/Entity , me da el siguiente error :

In ImportMappingDoctrineCommand.php line 151:

Warning: file_put_contents(src/Entity/"tsubtipoanestesia".php): failed to open stream: No such file or directory.

quisiera saber como solucionarlo.
gracias.

Was this page helpful?
0 / 5 - 0 ratings