I'm trying to customize the Taxon entity in Sylius, following this documentation : http://docs.sylius.org/en/latest/customization/model.html
In dev environment, no problem, everything works as planned.
But when I switch to the prod environment, I get the following :
[Symfony\Component\Debug\Exception\FatalErrorException]
Compile Error: require(): Failed opening required '/var/www/webshop/var/cache/prod/doctrine/orm/Proxies/__CG__SyliusComponentCoreModelTaxon.php'
It seems that the overridden class is still needed by someone, but I can't figure how to solve this. And I don't understand why the behaviour is different in dev and in prod...
Maybe I'm missing something ?
Thanks for any help.
I answer to my own question : ...the problem was on my side... (as often :-) )
I have on this project overridden also the Channel entity, and have a Channel.orm.yml file which stores the relationship with the Taxon entity.
This file had to be modified so that the targetEntity is the new (i.e. overridden) entity, and not the one from the Sylius core.
(AppBundle/Resources/config/doctrine/Channel.orm.yml)
...
targetEntity: AppBundle\Entity\Taxon
...
instead of
(AppBundle/Resources/config/doctrine/Channel.orm.yml)
...
targetEntity: Sylius\Component\Core\Model\Taxon
...
try to run php bin/console cache:clear -e prod. It should to refresh var/cache directory with new configuration.
Related
After releasing Symfony 4.0, there is no support for SensioGeneratorBundle. hence the command php app/console generate:doctrine:crud is not available.
They suggest to use MakerBundle, but I could not find appropriate replacement for CRUD generation.
Could anyone help?
You can use the make command in Symfony4+ (and it's quite an improvement!), from the MakerBundle:
php bin/console make:crud
It'll prompt you for which entity you want the crud for. It generates a controller with index, new, update, view and delete methods in /src/controller, with matching templates in /templates.
Useful to know: If you run make:entity, and later run that command again and enter an existing entity, it responds with:
Your entity already exists! So let's add some new fields!
At the moment MakerBundle supports just a few core commands. You can see the list here. Unfortunately there's no CRUD generator. But there some discussion about it in the issues so you can follow what will be done.
If what you need is just a generator for boilerplate code and not a more structured solution like EasyAdminBundle you should consider creating your own maker.
Symfony4 (thanks to #jelle)
composer require symfony/maker-bundle --dev
composer require symfony/form symfony/validator symfony/twig-bundle symfony/orm-pack symfony/security-csrf
php bin\console make:crud
The class name of the entity to create CRUD (e.g. BravePuppy):
>
first install pre-req packages
composer require twig-bundle security-csrf
and then you can run
php bin/console make:crud
after that just enter your entity name which you want to curd
The class name of the entity to create CRUD (e.g. BlogPosts):
>
I'm using Mogenerator to help with my Core Data implementation and for the most part it works great. However, sometimes when I add new attributes, build, and run the project, I get the following error whenever I try to access the property:
[MyObject myAttribute]: unrecognized selector sent to instance
After looking into the machine generated class, it looks like Mogenerator creates getters/setters for some of my new attributes but not ALL of them. What am I doing wrong? How can I still get/set these new attributes when Mogenerator doesn't give me access to these methods?
What I've tried:
1. Synthesizing each new attribute in my Human generated file (this gets rid of the errors at least, but doesn't actually save anything to Core Data)
2. Writing a custom getter/setter for each missing attribute in my Human generated file (same results as above)
Okay, I forgot to follow rule #1 of resolving computer problems... delete and re-install.
I'm using BitBucket to host my repository so I just deleted my local copy and cloned the project back to my machine. It runs fine now. I'm calling this issue "closed" for now, but any thoughts on why this would happen?
I'm trying to use the yii migration system but I'm stuck on this error when I execute this commande:
yiic migrate create add_table_test
I get this error:
exception 'CException' with message 'Property CConsoleApplication.defaultController" is not defined'
(CCompenent.php:173)
But I've defined a defaultController in my config file:
'basePath'=>$rootPath,
'defaultController' => 'person/index',
'homeUrl'=>array('/me'),
I spent hours looking on Google, but I can't find a solution.
Does anyone have an idea about this problem?
The problem is, that you've actually defined the property defaultController in your config/console.php but as the error message says the CConsoleApplication has no such property.
So just remove defaultController from your console config.
(this is actually an answer given by OP (Michaƫl). I'm putting it here, because he put it into question)
It turned out, that the problem was on my side. I did a really bad thing.
Problem was solved by:
Replacing in yiic.php line $config=dirname(__FILE__).'/config/dev.php'; with $config=dirname(__FILE__).'/config/console.php';.
Create a console.php file in the config directory, without defaultController and theme option.
I'm working on a Symfony project in a Win7/Apache 2.2/ZendStudio environment and I have some trouble getting my file uploads to work properly.
My goal is to let the user create a new entity which can contain arbitrary many "Documents" (based on the article found at http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html). I have a form type containing one field of type 'collection' (based on the article found at http://symfony.com/doc/current/cookbook/form/form_collections.html). So far so good. Via jQuery I can add arbitrarily many forms as subforms which works fine. But when I submit my form, very often (but not always!) I get the following exception:
Warning: rename(C:/Programming/Servers/Apache2.2/htdocs/Symfony/app/cache/dev/doctrine/orm/Proxies\__CG__MyMainBundleEntityRecruiter.php.507bf02e30df69.85090364,C:/Programming/Servers/Apache2.2/htdocs/Symfony/app/cache/dev/doctrine/orm/Proxies\__CG__MyMainBundleEntityLecture.php): Zugriff verweigert (code: 5) in C:\Programming\Servers\Apache2.2\htdocs\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Proxy\ProxyFactory.php line 194
Zugriff verweigert is German for Access denied. Weirdly, the files seem to get renamed and saved at the right location nevertheless.
Why do I get this exception, does it have something to do with my environment and how can I fix it? I guess this issue is related to Symfony Warning : rename (../app/cache/dev , ../app/cache/dev_old ) : Access Denied . (Code : 5), but not quite sure whether it's the same as it happens in another context. I do also encounter the problem described in this link, though.
Thanks in advance.
I've been running into the same exact issue recently. I don't really have a good sense of why the problem is happening, but the problem is coming from a step in the process where Doctrine is trying to generate proxy classes.
In my config.yml file, under the ORM section of the Doctrine configuration, I changed the value of auto_generate_proxy_classes from %kernel.debug% to false. I've played with it for a while since making the change and haven't been able to reproduce the issue since.
Found this while looking for same answer, it seems to be a windows + Doctrine issue.
Doctrine Ticket with more detailed info
TLDR: Basically the proxy is trying to rename a file that's still being used, works in Linux but not always on windows.
Go to the file that renames the file, then replace it with a windows compatible rename function
private function renameWindowsCompatible($oldfile,$newfile) {
try {
rename($oldfile,$newfile);
} catch(\Exception $e) {
if (copy($oldfile,$newfile)) {
unlink($oldfile);
return TRUE;
}
return FALSE;
}
return TRUE;
}
I learned about proxies and saw that it is used with lazy loading.
I had an entity A with a one to one relationship to B.
B was the problem is the proxies directory
I just had fetch="EAGER" annotation in A entity
/**
#ORM\OneToOne(targetEntity=B::class, fetch="EAGER")
*/
private $b;
Then the B proxy was not generated and no more problem with rename.
Hope this help.
I posted in the Yii forum with no luck. I am hoping someone in this community got this extension working because I really need it!
I used the yiic docs check command, and all the models seem to finally pass the check. So, I proceeded to executing this command:
yiic docs C:\path to my site\protected\models
And at first this appears onscreen:
Building.. : MyApplication Class Reference
Version... : 1.1.7
Source URL:
And then this error pops up:
Building model...
PHP Error[2]:include<GxActiveRecord.php>: failed to open stream: No such file or directory in file C:\path-to-my-app\yii\framework\YiiBase.php at line 396
Where, at that line, I have the following code:
include($className.'.php');
I don't understand why it is looking for a class I do not have!! I found it here, but I don't know in what specific folder that class should reside, or better yet why I should have to download it separately when it's not specified in the instructions. Thanks.
Looks like you've generated models from giix which have GxActiveRecord as a base class and the doc parser does not find this base class, usually you've defined this as an import in your application config, so this may be an expected behavior.
You could try importing something like 'ext.giix.components.GxActiveRecord' in every one of your model classes or copy GxActiveRecord into your models directory just for generating the docs.