Yii skeleton app

This is a skeleton application that it a good reference for beginners.

Disclaimer

I am not advertising these methods of programing as "best practices" for Yii.

Download

http://code.google.com/p/yii-skeleton-app/

[b]

Live demo (old version)[/b]

http://yii.cubedwater.com

You may login with admin/admin

You may use this code in any way you wish. You can use it as your own skeleton app, or use it as a reference, or for ideas, or to get a better under standing for Yii, or some part of it. Whatever you want.

If anyone has any comments on it that would be great.

Very nice indeed!

I noticed that GroupController::actionList() is using the old code. Perhaps it should be updated to be consistent with that in UserController.

Today I checked in a minor enhancement to access control filter. You can use specify an exp​ression in the rule. Perhaps that may eliminate the need for you to extend the existing access control filter?

Awesome!

What do you think about getting this code under revision control and allowing people to update it as a reference application?

That way, it can be updated for best practices and additional functionality.

Maybe a SF project?

Thanks

very useful - I especially like the included debug features.

One small point, when creating a new user and trying to verify the email address I seeing 'Page Not Found    The requested controller "users" does not exist'.

This is an example verify link;

http://localhost/yii…2x6vakny34juzn3

Is there a typo in the link or something I'm doing wrong?

I have attempted to see what's going on myself, but am very new to Yii!

thanks in advance.

Quote

very useful - I especially like the included debug features.

One small point, when creating a new user and trying to verify the email address I seeing 'Page Not Found    The requested controller "users" does not exist'.

This is an example verify link;

http://localhost/yii…2x6vakny34juzn3

Is there a typo in the link or something I'm doing wrong?

I have attempted to see what's going on myself, but am very new to Yii!

thanks in advance.

Try replacing users with "user". I haven't looked at the code yet but that's probably the bug there. Or there may not be a view for the page.

Yes I did try this, which results in the following;

'Page Not Found    The system is unable to find the requested action "verify".'

Quote

Yes I did try this, which results in the following;

'Page Not Found    The system is unable to find the requested action "verify".'

Yeah, Doesn't look like the verify action is there. >.>

@qiang

Thanks :)

I just updated the groups controller to not use the "old" code.  I'll try to upload today…

And yes, the enhancement you made to the access control feature destroys the need for me to extend it, I still like my extension of it better as it requires less typing when setting access controls, so I think i’ll leave it.  You can see I commented in documentation as to how it works in the AccessControlFilter.php .  I also put in some instructions to un-extend it (just now).

Quote

One small point, when creating a new user and trying to verify the email address I seeing 'Page Not Found    The requested controller "users" does not exist'.

Oops!  Sorry, I totally forgot to implant that part of the application.  I'll try to get that in the next update.

@meanpenguin

This may sound absurd but I'm still learning my revision control.  I have mixed feeling about putting it under SVN because I know different people have different needs for a skeleton app (for instance I extended the access control filter and I think a lot of people would not like that for themselves personally).

In any case, if anyone would like to fork the project that's fine.

I'll try to get an update in today

Quote

@meanpenguin

This may sound absurd but I'm still learning my revision control.  I have mixed feeling about putting it under SVN because I know different people have different needs for a skeleton app (for instance I extended the access control filter and I think a lot of people would not like that for themselves personally).

In any case, if anyone would like to fork the project that's fine.

I'll try to get an update in today

Well We could always setup a few branches of it. If you like I can setup a google code project and If you want you can just E-mail me the updates and I'll manage Uploading them and such for you. Might be a bit easier if you've never done SVN before.

Of course people have different needs but a 'clean'-ish starting point is always the best for people to work off.

I need to learn it anyways so I think i'll give it a try myself when I get time.  I just uploaded an update but now I got to get some other work done off the computer.

Anyways, the update includes:

  • Replaced "old" code in group controller

  • (btw, the group create view now has some JS that might be interesting to some)

  • Added a few more comments/documentation here and there

  • Added user verification action

  • Added User::get/setActivated() and User::getActivationCode()

  • Depreciated use of User::unconfirmEmail() in favor of $user->activated = true/false;

  • This list is from memory and may not include everything

Quote

If you like I can setup a google code project and If you want you can just E-mail me the updates and I'll manage Uploading them and such for you. Might be a bit easier if you've never done SVN before.

Of course people have different needs but a 'clean'-ish starting point is always the best for people to work off.

Please do it, for I found following message when I clicked the tab of Users.

Quote

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'User.group_id' in 'on clause'

thanks for fixing this so promptly.

the user verify link works!

however, when i try and log in with the newly created user/pass I'm told that the password is incorrect.

The password has been stored in the DB as a md5 hash, and (i think) the user input password is being md5() hashed before comparing them.

I tried changing the password on the Admin account, and logging in with the new password - and this works.

any ideas where the problem might be occurring?

Quote

Quote

If you like I can setup a google code project and If you want you can just E-mail me the updates and I'll manage Uploading them and such for you. Might be a bit easier if you've never done SVN before.

Of course people have different needs but a 'clean'-ish starting point is always the best for people to work off.

Please do it, for I found following message when I clicked the tab of Users.

Quote

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'User.group_id' in 'on clause'

I’ll only do so with Jonah permission which I don’t have yet. But as soon as he consents I’ll be happy to set it up and get a bug system going. :)

@mocapapa

I don't see any obvious reasons that you are getting that area.  Can you confirm that your user table actually does have the group_id column? It should.  Did it spit out any other debug info that might help me?

@creator

fixed and uploaded.  The problem is that when the user verified his account, it rehashed his password.  So now it makes sure the password actually changed before hashing it, unless it is a new user in which case it hashes it anyways

btw, do you also get the error that mocapapa gets?

@Bios Element

You have permission to do whatever you want with it, but I wont send the the patches directly to you (but you could theoretically still do it).  I will try to get a svn up myself pretty soon (hopefully).

Hi Jonah,

Quote

@mocapapa

I don't see any obvious reasons that you are getting that area.  Can you confirm that your user table actually does have the group_id column? It should.  Did it spit out any other debug info that might help me?

I found that there already was a table named 'user' and it conflicts the new one.

I changed the database and created the new tables. Though I have to rename the table ‘user’ to ‘User’ and ‘group’ to ‘Group’, it begins to work. Sorry for bothering you. :)

BTW, is this expected behavior when I lost my password and tried to recover by entering my e-mail address?

Quote

.: Dumping email

The email extension is in debug mode, which means that the email was not actually sent but is dumped below instead

Email

To: mocapapa@pugpug.org

Subject: User Recovery

You have requested us to recover your login credentials at My Web Application (http://yii.localhost/demos/yiiSkeleton).

Your Username: mocapapa

Unfortunetally we are not able to recover your password as it is encrypted

Additional headers

Content-Type: text/html; charset=utf-8

MIME-Version: 1.0

I know there is no way to recover encrypted password though…

For me it works with the tables as under-case… And I'm not sure why Yii is making the first letter capital, within the app all the tables are written in lower-case.

Could it be a mysql setting that turns on case-sensitivity?

Also, I can't think of any way for a user to be able to recover his password, because it is encrypted in the database.  Not sure what I'm going to do about that, but i'll probably remove that silly little message and instead have a password reset option for those who correctly know their username and email (and then the new password will be sent to their email)

BTW thanks for reminding me

Update:

  • Added the ability for a user to reset his password

  • Removed auto-password encryption in beforeSave() (in favor of just directly calling a new method encryptPassword() ) - Note: this is not something you need to know unless you were messing around with the code I wrote

Quote

For me it works with the tables as under-case... And I'm not sure why Yii is making the first letter capital, within the app all the tables are written in lower-case.

Could it be a mysql setting that turns on case-sensitivity?

I am not sure about that. Would some one please describe this case sensitivity?

Quote

Also, I can't think of any way for a user to be able to recover his password, because it is encrypted in the database.  Not sure what I'm going to do about that, but i'll probably remove that silly little message and instead have a password reset option for those who correctly know their username and email (and then the new password will be sent to their email)

I have the same opinion. The system should generate a random password which is sent to end users and should be replaced by the one supplied by end users.

Quote

BTW thanks for reminding me

Thank you for this skeleton application as a common base for every Yii application. As I would like to extend this, I hope to have an open SVN system such as google code.

SVN online. http://code.google.com/p/yii-skeleton/

Anyone who would like access, PM me your Google account and I’ll set you up. :)