Wednesday, October 30, 2013

Re: Cake 2: Very confusing docs/tutorials... Is there another foolproof source?

With regards to admin routing, it looks like you're interested in doing prefix routing.  

As listed here [http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing], you'll need to do the following:

Set up admin as a routing prefix in app/Config/core.php

Add the admin_ prefix to any controller functions that should only be accessible via the admin URL (i.e. /admin/users/index would have a admin_index() in UsersController, and corresponding app/Views/Users/admin_index.ctp)

That is all you should need to do, though if you want to set up /admin to default to a specific page, then use the second code example in the link (the one setting up Router::connect('/admin', ... ).

Should I have a separate login code for my administration section ?

That's an application specific question, rather than a framework question.  A framework question would be "How can I implement distinct authentication for my admin routes?" (assuming you've decided that is what you want to do).  That one I can't answer, because I've never had to do it.  I usually have roles associated with the user, and if they have an Administration role, or something similar, I will redirect to the /admin URL when the user logs in.  Development is easier if there's just one list of users, however, if you have a business requirement for seperate logins, you may even want to consider having a separate administration app and use plugins for functionality that is common between the public and the admin apps.  By having individual apps, you won't need to be concerned with admin routing, either.

Should I be creating an AdminController or do I still admin functions in all my controllers  (aka admin_index,admin_edit,admin_delete).

For the sake of argument, lets say you are sticking with a single app for public and admin, and you have prefix routing working, then you shouldn't need an AdminController.  It should be enough to just prefix controllers. Plus, if you has an AdminController that handled all admin actions, it would end up being a bit of a god object, and when it comes to maintenance, you will have a bad time. You'd have to have an index for each model you want an index for, and that would start to break convention, and get you in a bad mood when nothing works they way you expect it to work.

How to build a category manager in the administration section ?   Should I be using someone's plugin/helper from github ?

If you can find a category manager that does the job for you, does what you want/need and has the appropriate license, then use it! If you find a helper that does what you need or help, use that too!  As with any software, it's your judgement call as to other things like support, and trustworthyness.  At the very least, have a look at the source code to see how it works, and if it is doing anything nefarious or has security holes.

I've found the examples in the book very handy.  I've also found the tests in CakePHP handy, if you're wondering how to use a particular function.

CakePHP is a tool. It's a mallet, it's a brick, it's a trowel, it's mortar, it's wood, it's nails. It's up to you to put those things together make the application.  I'd welcome you to take a look at other MVC frameworks such as Symphony2, Code Igniter, ASP.NET MVC and Django (to name a few), and see if they give you the same answers you're after with CakePHP.  MVC development is all much of a sameness, with quirks between the different frameworks.  I reckon CakePHP does a lot of things right, and gets better with each release.



On Wed, Oct 30, 2013 at 11:41 PM, Silver Troy <educatedrisk@gmail.com> wrote:
I have been reading the cakephp book, looking on youtube, googling any examples I can for the past 3 weeks. 
Feel like I am banging my head against the wall and could easily do this stuff outside the framework.

The documentation is lacking real examples that beginners could actually build on.

I have hacked together a front end to my test website, a front end user section and an admin section (still can't route  to
it properly). 

Should I have a separate login code for my administration section ?

Should I be creating an AdminController or do I still admin functions in all my controllers  (aka admin_index,admin_edit,admin_delete).

How to build a category manager in the administration section ?   Should I be using someone's plugin/helper from github ? 

They should really attempt to put together a tutorial site that shows more than the blog example. 
A website that has a user registration, login, profile section.  Listing of products or articles and an administration
section would be something very valuable to all beginners.

 I do see the potential benefits of cakephp but finding decent best practices (examples)  on the internet is pretty bad.  Considering
cakephp 2.x was released 2 years ago or so? 

Not to mention I am already reading about cakephp 3.0   .   Maybe a concentrated effort to develop 20,50, 100 best practice examples for
cakephp 3.0  would be very beneficial.




On Wednesday, October 30, 2013 6:45:02 AM UTC-4, euromark wrote:
Silver Troy: Mark Story != dereuromark ;)

Most beginners find the book sufficient - and properly explaining the basics.


Am Mittwoch, 30. Oktober 2013 05:30:20 UTC+1 schrieb Silver Troy:
I have to agree with the above comments about trying to find real examples with cakephp 2.x.

The cakephp youtube channel doesn't give you any video examples on simple concepts.

The documentation has a lot of useful information, but little examples to put them into action.

Doing the blog tutorial example was pretty quick and easy.  Adding authentication the Andrew perkins
youtube videos were good. 

But seriously Cakephp you need to develop some real world simple examples.  Cause its frustrating
as a php developer to be attempting to figure out how to properly code inside of cakephp's framework.

I read the documentation, the bakery, youtube videos, google for tutorials. 

But can I find a simple menu building example ?
How to build an admin section with proper routing ?
How to connection with hasOne, hasMany ?
Building a category tree that lists products in each level with paging ?

Oh I have read over Mark Story's Tree Behavior article and attempted to install his "Tools" plugin ..
but trying to get a working example .... sigh.   Should I really have to install someone else's plugin
to build a category system in a website ?

Quite the frustration is trying to learn this framework ... spinning my wheels.

Yes I tried the irc channel and basically the first person to respond made me feel like an idiot ... not impressed
and then basically linked a bunch of the book.cakephp.org sections .. which I have already read that don't give a proper working example or stop just short of the basic functionality.

 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/j9Oi4GJQl_0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: