Symfony2 doctrine:generate:entities chmod operatio

2019-07-15 05:34发布

Recently upgraded from 2.3.1 to 2.8.7 on a dev machine. All has been going fine until I needed to create a new table. Managed to generate the yml fine via doctrine:mapping:convert

When I come to create the getters and setters via doctrine:generate:entities I get this:

[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: chmod(): Operation not permitted

And nothing else. Which isn't very helpful. Is it a chmod which I need to add an @ to somewhere? I am executing the command as www-data and the log folder files are also www-data, so I don't believe it is a debug file permission issue.

Also, is it related to something which needs upgrading. Here is my composer file:

"require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.8.*",
        "doctrine/orm": "2.5.*",
        "doctrine/doctrine-bundle": "1.6.*",
        "twig/extensions": "1.3.*",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "symfony/assetic-bundle": "~2.8",
        "sensio/distribution-bundle": "~5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "snc/redis-bundle": "dev-master",
        "predis/predis": "1.0.*",
        "symfony/class-loader": "v2.8.*"
    },
    "require-dev": {
        "sensio/generator-bundle": "~3.0",
        "symfony/phpunit-bridge": "~2.7"
    },

I just wish the debug was slightly more helpful in regards to what it was doing it at the time. Or what file/line the error occurred at.

2条回答
相关推荐>>
2楼-- · 2019-07-15 06:06

This is more of a work around than a fix.

Basically in the version change they added code which wants to modify repository files. Since these are auto generated, most of the time it is fine. If you have added code to any of them, which you are meant to do, especially if you are modifying the code as a user other than www-data, it breaks things.

So now, when I come to do getters and setters part of a databsse structure update, I run this:

sudo find ./src/MyBunddle/SiteBundle/Entity -name '*.php' ! -name '*Repository.php' -exec chown www-data \{\} \; -print

Not idea, but gets the job done.

If you need to changes things back for any reason, you can do it with

sudo find ./src/MyBundle/SiteBundle/Entity -name '*.php' ! -name '*Repository.php' -exec chown youUser \{\} \; -print

You can see them discussing the issue here:

https://github.com/doctrine/doctrine2/commit/caf30b889bb898620d843d1ec4940d01fa1d8877

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-07-15 06:27

Check the cache folder ownership as well. If its same user, it shouldn't be a concern. Still do a double check.

Additionally, if this doesn't work, please disable safe_mode for time being and check once again.

查看更多
登录 后发表回答