Generate entity in symfony 4 (methods) - symfony

when I tried to run the command php bin/console doctrine:generate:entities App:Center in symfony 4.0.6 I get this error:
Can't find base path for "App\Entity\Center" (path:
"/home/USER/foo/bar/src/Entity",
destination: "/home/USER/foo/bar/src/Entity").
the Center is my entity name!
how can I fix this?

Doctrine developers are deprecating the generation commands for Symfony 4. The reason why it doesn't work for you is because the command is hardwired to find the destination directory under
projectRoot/src/{namespace}/{App}Bundle/Entity/{Center.php}
but the Symfony 4 directory structure is different than that, hence it cannot find it. If you are dead-set on using the command, you could probably extend it and create your own, in which you could change the destination path(s) for your entities. You can just skip the command part and generate getters and setters on your own.
Doctrine issue: https://github.com/doctrine/DoctrineBundle/issues/729
Symfony issue: https://github.com/symfony/symfony-docs/issues/8893
From the maintainers of Doctrine:
https://github.com/doctrine/DoctrineBundle/pull/790

So, from the various questions, I think your first problem is files permissions...
Meanwhile, you need to first correct your files permissions.
Here is how to do it.
chown /home/alireza/Projects/www/ www-data:www-data /
find /home/alireza/Projects/www/ -type d -exec chmod 0755 "{}" \;
find /home/alireza/Projects/www/ -type f -exec chmod 0664 "{}" \;
find /home/alireza/Projects/www/ -type d -exec chmod g-s "{}" \;
find /home/alireza/Projects/www/ -type d -exec chmod g+s "{}" \;
As I assume that www/ is where all your projects are stored, I stopped the path at the www/ folder. It will thus correct files permissions for all of your projects.
Also, make sure to add your current user to the www-data group.
usermod -a -G www-data user_name
Try this, and tell us if you still have your problem.

Related

An error occured in the upload. Please try again later

enter image description hereHow to fix these errors when I'm trying to upload an image.
provide me s solution of this problem
You've got permission errors on your web server. Navigate to your webroot in terminal and change the folder and file permissions
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
Then make sure apache owns the wp-content folder: (Substitute your apache user. Its most often "apache" or "www-data")
chown <apache-user>:<apache-user> wp-content

How to reset Read write permission in AWS lightsail for wordpress

Have a look at this image : http://prntscr.com/iadnrl
Adding new theme to Wordpress after deleting all tables and data. While activating new theme getting this mentioned error of connection FTP.
I already tried following commands , seems does not worked.
sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs
sudo passwd bitnamiftp
Hosting is on AWS Lightsail.
Please share your views.
TAKE A BACKUP BEFORE RUNNING THESE COMMANDS. I am not responsible for any error.
The following command worked for me. Make sure to replace the bitnami to the proper user.
Change to proper permissions of all files:
find /opt/bitnami/apps/wordpress/htdocs -type f -exec chmod 0644 {} \;
find /opt/bitnami/apps/wordpress/htdocs -type f -exec chown bitnami: {} \;
Change to proper permissions of all folders:
find /opt/bitnami/apps/wordpress/htdocs -type d -exec chmod 0755 {} \;
find /opt/bitnami/apps/wordpress/htdocs -type d -exec chown bitnami: {} \;

AWS EC2 Ubuntu File permissions issue

I'm running a EC2 instance with:
Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-119-generic x86_64)
Bitnami LAMP 5.6.30-5
My problem
I have a Wordpress site that isn't working very well on the backend, so I decided to update and I get an error "Can not create the directory..." when updating. So I did a research and it's related to file permissions. So I get to this conclusion:
I having the following issues with the file permissions:
Can't write files from server
I used is_writable() (PHP) to detect if server can edit and it returns false.
Can edit files from Filezilla
I login to the server with the "bitnami" user and everything works good.
I tried
sudo chown -R bitnami:www-data htdocs/
I added the default user "bitnami" to the www-data group and changed the /htdocs owner.
And, yes the user is in the www-data group.
find htdocs/ -type d -exec sudo chmod 2775 {} +
Changed directory permissions
find /var/www -type f -exec sudo chmod 0664 {} +
Changed the files permissions
How to solve this?
I tried all that and also giving the owner to root:root, www-data:www-data and bitnami:bitnami.
If someone knows the original user and group owner of the /htdocs folder I could try a test, but I forgot.
I would appreciate if anyone can help me to solve this. I just want to be able to write/edit files from server side.
Many thanks.
I solved this by doing the following:
Set htdocs owner to bitnami:bitnami
sudo chown -R bitnami:bitnami htdocs/
Inside /htdocs, changed file and directories owner to bitnami:daemon
sudo chown -R bitnami:daemon
Changed files and directories permissions
sudo find * -type d -print0 | xargs -0 chmod 0755 # for directories
sudo find . -type f -print0 | xargs -0 chmod 0644 # for files
Changed wp-content directories permissions to 775
sudo find wp-content/ -type d -exec chmod 0775 {} \;
And with that now I'm able to edit and upload via FTP and in the WP admin dashboard.

Modify permissions for scripts recursively

Trying to set permissions recursively for multiple scripts:
chmod -R /export/home/*.sh
But some files do not have .sh extension, e.g. .ksh and some scripts have no extension at all.
How can I make all scripts/files executable? (any type, extension or not)
This command should do the trick:
find /export/home -type f -exec chmod +x {} \;
However, I don't think you really want to make all files executable - there is significant security risk in this. You'd be better off just determining what files should be executable, or putting them in a "bin/" subdirectory, which you could then search for:
find /export/home -type d -name bin -exec chmod -R +x {} \;

What permissions should a wordpress installation have to be secure but functional?

I've already read http://codex.wordpress.org/Hardening_WordPress but I can't get my head around it. What are the permissions that shall be set and by who shall it be owned by? Right now I have set as the result of the following commands:
# reset to safe defaults
find /usr/share/wordpress -exec chown www-data:www-data {} \;
find /usr/share/wordpress -type d -exec chmod 755 {} \;
find /usr/share/wordpress -type f -exec chmod 644 {} \;
# allow wordpress to manage wp-config.php (but prevent world access)
chgrp www-data /usr/share/wordpress/wp-config.php
chmod 660 /usr/share/wordpress/wp-config.php
# allow wordpress to manage .htaccess
chgrp www-data /usr/share/wordpress/.htaccess
chmod 664 /usr/share/wordpress/.htaccess
# allow wordpress to manage wp-content
find /usr/share/wordpress/wp-content -exec chgrp www-data {} \;
find /usr/share/wordpress/wp-content -type d -exec chmod 775 {} \;
find /usr/share/wordpress/wp-content -type f -exec chmod 664 {} \;
After this configuration the installation is unusable. Any tips?
Here's a quick recap of how I manage permissions on my servers:
Anybody can read files and directories
Nobody can write anything outside of the /wp-content/uploads directory
PHP scripts can not be executed inside the /wp-content/uploads directory
PHP scripts can not be executed directly in /wp-includes and /wp-content
So it doesn't matter who owns the .php files, as long as the apache user can read them. Allowing the apache user to modify these files is a risk, even .htaccess. The downside of all of this is that you'll need to provide WordPress with FTP credentials to do things like install or delete a plugin, update a theme or core, etc. That's something I can live with.

Resources