Welcome Guest, Not a member yet? Register   Sign In
Trying to use PHP5 "helper classes" with Custom CodeIgnitor Library
#1

[eluser]Unknown[/eluser]
I'm working on a custom CI library.

I wrote a couple helper classes that use PHP5 syntax for the custom CI library I'm working on. The helper classes can't be libraries because they are singleton classes that use the PHP5 design pattern of making the constructor private. The CI library loading class doesn't like this.

Is it considered sloppy coding from a CI standpoint to have the custom CI library directly include the PHP5 helper classes rather than loading the helper classes as libraries?

Should I just create another directory outside of the CI system directory where I put all these PHP5 helper classes that don't need to be libraries?

Has anyone done anything like this before? I just want to make sure this isn't some horrible design decision that is going bite me in the butt later on. As of right now I'm pretty sure the helper classes will not need to be directly used inside any controllers.

Thanks for any advice!
#2

[eluser]bradym[/eluser]
When using outside code I create a helper, plugin or library (depending on which one fits my situation best) and just include() the existing code. Then I build functions to use the outside class. There's no reason not to use the include function where needed.

For example, I built a plugin to use the google maps class I use. It does an include() and then inside the function I use the google maps object to create the code for the map, which is returned from the plugin. When I need a map, I use the plugin.

HTH,

Brady




Theme © iAndrew 2016 - Forum software by © MyBB