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

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.

Related

Issue unlink with Drupal 9.0.3

I'm new here, i have a problem with Drupal 9.0.3 and I'm not that much of a Drupal expert either.
The problem is this: after i do "drush cache-rebuild", this happen
[warning] unlink(/bitnami/drupal/sites/default/files/css/css_GBUUzqz5ceINiDlSQ1o7Z8ZvirKTZAlcfXIJ2cvHW6Q.css.gz): Permission denied FileSystem.php:124In FileSystem.php line 324: Failed to unlink file 'public://css/css_GBUUzqz5ceINiDlSQ1o7Z8ZvirKTZAlcf XIJ2cvHW6Q.css.gz'.
I also tried to play a bit with the permissions but nothing happens. I honestly don't know which module or modification of the last ones will have led to this sudden error. Thank you for all kinds of support.
You got that warning because the user you are logged in does not have write permission on the folder /bitnami/drupal/sites/default/files/css/. So, drush (running as that user) cannot delete the aggregated css files while rebuilding the cache.
To solve this, you need to set the permissions of that folder to 775 and make sure that the user you are logged in with belongs to the group-owner of it.
I solved with sudo drush cache-rebuild
However, thanks equally to both you guys.

Laravel 5.2 : file_put_contents (xxxxxxxxxxxxxxx.php) failed to open stream: Permission denied

I have installed fresh Xampp, And set the virtual host, When i accessed the site, The following error came up.
file_put_contents(/b237142d7ac388af2fe193a8361f611a83409dff.php): failed to open stream: Permission denied.
I searched for the issue, Folk says that its /storage permission issue i have changed the permission to sudo chmod -R 777 /site-name/storage.
But the issue still remains.
Am i missing something ?
In the storage folder,app, framework folders were missing, By adding them the issue is gone and now things are working like a charm.
I had the same problem with a Laravel 5.2 project. I already had the folders app and framework in storage folder. Then I found that in framework folder you need to have three folders: cache, views and sessions-- and make sure storage folder has the write permission.
This answer helped to solve the problem finally.

laravel 5.1 file_put_contents wrong path

So I am using laravel 5.1 on ubuntu with nginx and php-fpm, I am having a little issue with my sessions. I have done all the permissions (chown to nginx/php user and group and chmod 777 on storage) however I think there is another issue.
The session file is created as I can see it on the server however when laravel is trying to write to it I don't think it can find the file see bellow:
at HandleExceptions->handleError('2', 'file_put_contents(/54dc94489b4c137d744f0427ce2c7e5e): failed to open stream: Permission denied',
Is there an issue with laravel finding the session path ? I am not really sure what to do, I have edited the filtsystem class and hard coded the path to the session directory however that isn't the correct solution.
I had to create 'storage/framework/views'

Laravel Permissions

I did an installation of laravel, and copied the files to a xampp hosted folder on the same machine. When I try to visit my index.php file however, I'm getting the following error:
Error in exception handler: The stream or file "/Applications/XAMPP/xamppfiles/htdocs/TestManagement/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/TestManagement/bootstrap/compiled.php:8969
I'm always a bit hesitant about changing permissions, as I've done some pretty bad chmodding before. Was wondering if there was a rule of thumb or expected behavior for this. Should this be 777 or 755?
The Laravel and Monolog documentation appear to contain no reference to the 'right' permissions. You can make it work with restrictive permissions, but be aware of all of the users that need access:
the web server user
cron user (if you run artisan commands via cron)
anyone who manually runs artisan commands.
They will each need read/write permissions to the log files.
Always use 777 on app/storage folder

Symfony Deploying Project on Distant Server ContextErrorException

I am trying to upload my project on the distant server, I simply uploaded the files on the distant server, checked the config.php, which says that all is good. I have removed the if conditions for only local access. But when i try to open the app_dev.php or app.php i keep getting this error
ContextErrorException: Warning:
file_get_contents(C:\wamp2\www\Symfony\src\Les\CouvertsBundle/Resources/views/Couverts/index.html.twig)
: failed to open stream: No such file or directory
in /homepages/26/d367595533/htdocs/Symfony/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 130
i have not found any answers to this question, maybe not looking for it properly. But could anyone explain to me why would this error is occuring? Why is symfony looking for the files with the local address?
I followed this tutorial to deploy project in production http://fr.openclassrooms.com/informatique/cours/developpez-votre-site-web-avec-le-framework-symfony2/deployer-son-site-symfony2-en-production. The steps seem pretty straight forward, but maybe i am missing something.
This is really frustrating, because my project is ready but i can't seem to put it online due to this problem.
The problem seemed to be the command php app/console cache:clear and php app/console cache:clear --env=prod didn't completely clear the cache folder.
It can happen if the user running the command hasn't the permission to delete files/folder in app/cache/ Manually removing the content of this folder can solve the issue (rm -rf app/cache/*).
Just clearing the cache manually at (projectname/app/cache) instead of the command line worked for me (version 2.8).

Categories