简体   繁体   中英

Symfony3 : Warning:copy([…]Entity/User.php~): Permission denied

The exact error is the following

 [Symfony\Component\Debug\Exception\ContextErrorException] Warning:copy(/Applications/MAMP/htdocs/Project/src/MR/UserBundle/Entity/User.php~): failed to open stream: Permission denied 

on my Symfony3 command :

 'php bin/console doctrine:generate:entities'

Does anyone ever had this warning ? or see what may cause the problem ?

I don't know if it's related to that, but I made a terrible mistake this morning, 'rm'ving my User directory (on OS X) with -R option.. a nightmare. I had to reinstall mysql, and did the same with MAMP. My symfony project was intact because of its location in the 'htdocs' directory.

I had the same problem with my var/ directory but solved it with this tutorial from the official website.

Hoping for a solve, because I cannot work on the project now..

Thanks in advance !

When Symfony generates entities, it makes a backup, and in your case the file it is backing up is called 'User.php~'. So for some reason when you run the command:

php bin/console doctrine:generate:entities

It doesn't have permission to write to that particular folder. Maybe do you have to use sudo ? Or maybe you have to login as a different user? Regardless, it's a permission problem of writing the backup file.

By the way, the new file would be 'User.php', and the backup once the command completes is renamed 'User.php~'.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM