Welcome Guest, Not a member yet? Register   Sign In
confused about coding pattern

Hi, all, I have several questions about CI:
1. in java, we used to have business objects and data acces objects. Does the same apply here in CI? where models are actually data objects (no methods except getters and setters). What's the pattern in CI? where too put the files?
2. where can I get tutorial on CI's login mechanism? I'm talking about the full package, so once you're logged in, you may access the files in "protected" folders.
3. I saw that everytime you want to check whether a user is logged in or not, you need if(isset($_SESSION['user'])) on top of every "protected" pages. Is there any way to use the Filter pattern from Java in CI?

I'm trying to migrate from Java to PHP, so I have lots of confusion here. Thanks

1. PHP MVC frameworks in general don't make the distinction, a model contains both the business rules and the data access. In case of CI the models are also singletons, so they act more like helper classes instead of objects. You can implement a third-party ORM solution to implement your data access in an OOP way, and keep your business logic in CI models.

2. CI doesn't have a login mechanism. Again you need third-party solutions for that. There are several popular ones available, search the forums for Auth solutions.

3. CI doesn't implement the Filter pattern, but it's not to difficult to implement by extending the Router class, and do your checks before the request gets routed. This would require an authorisation system based on controller/method.

The CodeIgniter architecture carries a heavy PHP4 legacy (which wasn't really OO), which means CI isn't really OO either...

Could you explain more about point 3? I read somewhere I should use CI's helper class with hook mechanism. What alternatives do I have? my interpretation of your idea is to redirect all requests to one php file where the auth checking is done in the php file. if authorized, forward to requested URL, otherwise land the user back to login page. Am I getting this right?
I also have a case where it's like this. Let's say I put a controller file in application/controller/customfolder folder and the file name is custom_controller.php. How to access the controller? tried /index.php/customfolder/custom. didn't work. thanks

Redirecting requests to a single controller isn't possible in CI, because it lacks the possibility for controllers to call other controllers. You would need a third-party solution like Modular Extensions for that.

You can use this: http://www.slideshare.net/mirahman/acl-in-codeigniter as a start to implement an ACL hook.

As you your last question, read the user guide on how to name your files and classes.

Theme © iAndrew 2016 - Forum software by © MyBB