Error when trying to create a controller using Gii

There was some error when generating the code. Please check the following messages.

Generating code using template "/var/www/yii/framework/gii/generators/controller/templates/default"…

generating controllers/HelloController.php

       Unable to write the file '/var/www/yii/framework/demo/protected/controllers/HelloController.php'.

generating views/hello/index.php

       Unable to create the directory '/var/www/yii/framework/demo/protected/views/hello'.

done!

Welcome to the Yii forum…

as the error say “unable to write/create…” it’s a permission problem… check that the web service has proper permissions on those folders…

What should I do in Terminal…

I’ve so far tried chmod +x * with no luck. which command would set the right permissions for all files and folders within?

Well, this forum doesn’t got a whole lot of traffic obviously. can anyone else help me.

I would say that the forum is very active… :D

problem is that you are asking very trivial questions and incomplete too… so I guess that is the reason why nobody responded…

Check the Guidelines for posting on the forum - http://www.yiiframework.com/forum/index.php/topic/19451-guidelines-for-posting-this-forum/

For example you did not mention on what system you are working… I can only guess it’s linux because you mentioned chmod…

I explained you what is the problem (permissions)… so now it’s just matter of googling how to set proper permissions for your system… and by doing that you will possibly learn how permission works so that you know in the future how and what to set them…

If anybody just gives you the command (solution) you could possibly just use that command and not learn anything from that…

I’m little late to the party. What worked for me is changing the ownership of the whole project, which probably isn’t a good idea for the security reasons.

Ubuntu 14.04

Position yourself in the project root and run a following command:


chgrp -R www-data *

if you are using apache web Server in linux you must specify the folder and files permission to allow YII write and create php scripts. For exmaple you have the followin error:
Unable to write the file ‘/var/www/yii/framework/demo/protected/controllers/HelloController.php’.

You must execute the following commands in the terminal
change directory
cd /var/www/YOUR_WEBSITE_FOLDER_/
change propetary and group folder’s
sudo chown $USER:www-data -R controllers
change the Directory permission’s
sudo chmod g+rwx -R controllers
and last restart the web server to changes take effect
sudo service apache2 restart

After this you must be able to create CRUD operations

Hi!

I has the same issue, and your solution makes sence to me, but I tried this and more and nothing at now, I don’t found at on document if this issue it’s some yii permission or apache permission.

When somebody knows will help me a lot.

Thanks!

ubuntu 18.04 it’s my system and the server it’s apache2 :v:

You should go directory.
You must allow your user and other users from the access rights.
Ubuntu 18.04 it’s my system and the server it’s apache2