Welcome Guest, Not a member yet? Register   Sign In
Where should logic go [edited]

(This post was last modified: 02-19-2017, 12:01 PM by ciadmin. Edit Reason: Modify example )

Hi, I'm building my CI structure. Is it a good practice to separate the logic in the controller? My goal is to make controller act like a router and just use the logic classes with namespace support.

Here is my build: https://github.com/marksagal/CodeIgniterPlus.git

- You will have to point your DocumentRoot to ./public
- You will have to manually create ./application/cache/views/


- CodeIgniter-minify
- Blade template engine

How to create logic? create a file in logic folder in Studlycase (Myclass.php). The class can be namespaced, then use your class by adding use yournamespace\Myclass in your controller  and just instantiate it and its ready to be used.
e.g: ./application/logic/Store/Car.php = \Store\Car::myMethod()
(Convention: every Capital letter in class and filename considered another level of directory)

Please suggest ideas because I will be building a longterm project. I prefer the best practices.
God Bless CI Contributors Smile

Messages In This Thread
Where should logic go [edited] - by marksman - 02-19-2017, 06:41 AM
RE: CodeIgniter 3.1.3+ - by albertleao - 02-19-2017, 09:39 AM
RE: CodeIgniter 3.1.3+ - by marksman - 02-19-2017, 02:05 PM
RE: Where should logic go [edited] - by cartalot - 02-20-2017, 12:29 PM

Theme © iAndrew 2016 - Forum software by © MyBB