I am learning form your tutorial, I had also watched your cake php blog tutorial and learned how to create any application through cake bake (tut_blog2).....by the reference of that video I have created cakeauth application but in your video how could cakeauth folder contains 'app' folder as in starting of Cakephp Auth Component Tutorial Part 1 you mentioned that you had created this through cakebake application so how app folder could show inside yr cakebake folder..
@Erkotak Hi, I didn't bake a new application, I only baked the models/views/controllers for the Auth tutorial. There's a variety ways to bake. You can use bake to create a new application. Or you can just download the framework and bake individual things like models/views/controllers. Thats why you see the app and cake folders. When you bake a new application it only gives you the contents inside the app folder. When you download the framework and just bake your m/v/c's you retain the app folder
@Cathythan Well cakes conventions require that you have some type of field in your table that is an int, primary key, autoincrementing field. The only exception really is in a hasAndBelongsToMany association. In a HABTM you don't need a primary key in the HABTM table. You could modify your table to just add an ID field as the primary key AI. I don't think there is any way around this as when cake does a find using last_insert_id or something. You'll save yourself a lot of headache just using Id.
@Cathythan Yes its because you have no id field. You can set a model's primary key using its member variable var $primaryKey = 'jobTitle'. But usually the primary key is an integer and autoincrements rather than varchar.
hi Andrew, i followed accroding your Cakephp Auth Component tutorial. But, the problem is ...AppController. I created AppController (/app/app_controller.php), then declare "var $components=array('Auth','Session'). But, that Auth component doesn't work at all. Also,i can't access functions that is written in AppController.
That's why, i tried another way, I put "var $components=array('Auth','Session') and functions in the UsersController, it works. Please help me, what is wrong with this?
@Cathythan Hi, it should work. Double check that your UsersController extends AppController. Double check that the AppController that you made extends Controller. You may also try putting parent::beforeFilter(); in your UsersController beforeFilter function to make sure it has all the functionality of the AppControllers beforeFilter. It sounds like you might just have something not named properly. You can also send me your AppControlelr and UsersController code and I'll look at it.
My starting point is to write the registration page itself. Next I went to the author sign with auth component. This is the problem. In the registration page. Password box. Whenever I press the button to submit. Whether in the field is populated or not. A password automatic appears. I recognize the problem because I am before I could use auth component not problem
@taqman001 I'm not sure why that would be happening. Try setting the password field to null or a blank string in the controller. Maybe you have a saved password for localhost and this is displaying the saved password in your password field while developing.
I am confused about AppController , first in the blog tutorial you inherited post_controller with AppController present in the "cake" folder , and now you have created Appcontroller class yourself in "app" folder, so which "Appcontroller" will the post_controller be inherited, the one u created yourself or the one present in cake folder. ?
@khatritariq The AppController that we made in the app folder is your applications controller in which you can put code in that all your other controllers inherit from. The AppController itself inherits from the Controller class in the cakephp libraries. The AppController that we created in the app folder overrides the AppController thats inside of the cake/libs/controller folder.
@logart00 I did it this way so that people wouldn't feel that they needed to watch 14 other videos to get started with Auth. They can just bake a new application and get started right away.
followed all your videos on cakephp, fanastic videos very well explained i thought i was finished until i seen these 3 videos on the Authcomponent,
Anyone know where you can get a copy of cakephp 1.3 cant find it on the official site only 2.0.
irishbloke99 1 month ago
It should be I LOVE IT btn :-) Great job!
martajohnsson 1 month ago
means through following steps u made your application ?
1. u have copy pasted the downloaded framework inside 'cakeauth' folder.
2. Then u had create 'cakeauth' database with 2 tables i.e. 'posts' and 'users'.
3. Then u had probably make database.php from database.php.default and update the value of $default array. (also changes 2 values in core.php file)
4. Then through cmd prompt you changed directory to yr 'cakeauth' folder' .
5. And finally u had just bake M-V-C for both tables
right????
Erkotak 8 months ago
Hi Andrew
I am learning form your tutorial, I had also watched your cake php blog tutorial and learned how to create any application through cake bake (tut_blog2).....by the reference of that video I have created cakeauth application but in your video how could cakeauth folder contains 'app' folder as in starting of Cakephp Auth Component Tutorial Part 1 you mentioned that you had created this through cakebake application so how app folder could show inside yr cakebake folder..
Erkotak 8 months ago
@Erkotak Hi, I didn't bake a new application, I only baked the models/views/controllers for the Auth tutorial. There's a variety ways to bake. You can use bake to create a new application. Or you can just download the framework and bake individual things like models/views/controllers. Thats why you see the app and cake folders. When you bake a new application it only gives you the contents inside the app folder. When you download the framework and just bake your m/v/c's you retain the app folder
andrewperk 8 months ago
Actually, i don't want id field in my table as an primary key. Is there any way
to fix my problem?
Cathythan 9 months ago
@Cathythan Well cakes conventions require that you have some type of field in your table that is an int, primary key, autoincrementing field. The only exception really is in a hasAndBelongsToMany association. In a HABTM you don't need a primary key in the HABTM table. You could modify your table to just add an ID field as the primary key AI. I don't think there is any way around this as when cake does a find using last_insert_id or something. You'll save yourself a lot of headache just using Id.
andrewperk 9 months ago
@andrewperk I meant a save.
andrewperk 9 months ago
Hi Andrew!
i have another problem.
Warning (512): SQL Error: 1054: Unknown column 'Usergroup.id' in 'where clause' [CORE\cake\libs\model\datasources\dbo_source.php, line 684]
The usergroups table has 2 fields: jobTitle & groupId.
Both are VARCHAR type. jobTitle is primary key. no id field and no association to any other table.
i baked this table, then, I can add new usergroups and can see the list.
but, when i access view and edit, this error appeared. Is it because of without id field?
Cathythan 9 months ago
@Cathythan Yes its because you have no id field. You can set a model's primary key using its member variable var $primaryKey = 'jobTitle'. But usually the primary key is an integer and autoincrements rather than varchar.
andrewperk 9 months ago
Hi Andrew, do you have the source codes for this like your blog tutorial?
PhantomHitman07 9 months ago
hi Andrew, i followed accroding your Cakephp Auth Component tutorial. But, the problem is ...AppController. I created AppController (/app/app_controller.php), then declare "var $components=array('Auth','Session'). But, that Auth component doesn't work at all. Also,i can't access functions that is written in AppController.
That's why, i tried another way, I put "var $components=array('Auth','Session') and functions in the UsersController, it works. Please help me, what is wrong with this?
Cathythan 9 months ago
@Cathythan Hi, it should work. Double check that your UsersController extends AppController. Double check that the AppController that you made extends Controller. You may also try putting parent::beforeFilter(); in your UsersController beforeFilter function to make sure it has all the functionality of the AppControllers beforeFilter. It sounds like you might just have something not named properly. You can also send me your AppControlelr and UsersController code and I'll look at it.
andrewperk 9 months ago
hi adrew
My starting point is to write the registration page itself. Next I went to the author sign with auth component. This is the problem. In the registration page. Password box. Whenever I press the button to submit. Whether in the field is populated or not. A password automatic appears. I recognize the problem because I am before I could use auth component not problem
Thank for suggest beginner
taqman001 10 months ago
@taqman001 I'm not sure why that would be happening. Try setting the password field to null or a blank string in the controller. Maybe you have a saved password for localhost and this is displaying the saved password in your password field while developing.
andrewperk 10 months ago
Comment removed
jimboandkris 1 year ago
Why is that the AppController is not in the controllers folder? Isn't it also site wide?
TubePoster1 1 year ago
@TubePoster1 This is just how Cakephp has things structured. The app_controller.php belongs in the app folder.
andrewperk 9 months ago
I am confused about AppController , first in the blog tutorial you inherited post_controller with AppController present in the "cake" folder , and now you have created Appcontroller class yourself in "app" folder, so which "Appcontroller" will the post_controller be inherited, the one u created yourself or the one present in cake folder. ?
Please answer
khatritariq 1 year ago
Comment removed
TubePoster1 1 year ago
@khatritariq The AppController that we made in the app folder is your applications controller in which you can put code in that all your other controllers inherit from. The AppController itself inherits from the Controller class in the cakephp libraries. The AppController that we created in the app folder overrides the AppController thats inside of the cake/libs/controller folder.
andrewperk 1 year ago
Thanks Andrew, this is excellent.
nigelmccourt 1 year ago
Typically you would write the _isAdmin method like this:
function _isAdmin()
{ return $this->Auth->user('role') == 'admin';
}
For verbal explanations within a tutorial context the long version is ok,
but I wouldn't like to see something like that checked in :S
I think most people also would like to see a ACL tutorial :D
Yes I know this could get complicated...
And nice auth tutorial Andrew!! Thanks!
teckyify 1 year ago
Hey Andrew,
Just curious why you didn't continue the Auth tutorial from the blog tut code base instead of creating a new app?
logart00 1 year ago
@logart00 I did it this way so that people wouldn't feel that they needed to watch 14 other videos to get started with Auth. They can just bake a new application and get started right away.
andrewperk 1 year ago
@andrewperk Ah, got it.
logart00 1 year ago