Welcome Guest, Not a member yet? Register   Sign In
How to include CodeIgniter functionality in non-CI PHP files?
#1

[eluser]Starovich[/eluser]
Hello! I hope this is not a dumb question, but I have been unable to find an answer by searching.

I have an old control panel software, which is not coded in codeigniter, and since I'd like it to have the same authentication module that I use in my current CI projects, I would like to know the easiest way to include codeigniter functionality in my old PHP files. The preferable way would be by making an include() statement, and then have access to the functionality by $CI-> or something along those lines.

Any ideas? Thanks!
#2

[eluser]Peter Drinnan[/eluser]
I was forced to do the same thing. One of my clients had applications built in a VC (view controller with no modeling separation) format spanning thousands of lines of code so migrating that stuff to the same format as a typical CodeIgniter app was impractical. What I did was use the subclass feature of CodeIgniter to create a custom loader allowing me to use the $this->load->.. functions within all those old clients files. It worked out pretty well and now I have all the functionality of CodeIgniter available within the clients old applications.

Migrating an non MVC application to be compatible with an MVC framework is always challenging but I'd say CodeIgniter is a best choice because of its simplicity, flexibility and extendability.

Good luck!
#3

[eluser]Starovich[/eluser]
[quote author="Peter Drinnan" date="1279368681"]I was forced to do the same thing. One of my clients had applications built in a VC (view controller with no modeling separation) format spanning thousands of lines of code so migrating that stuff to the same format as a typical CodeIgniter app was impractical. What I did was use the subclass feature of CodeIgniter to create a custom loader allowing me to use the $this->load->.. functions within all those old clients files. It worked out pretty well and now I have all the functionality of CodeIgniter available within the clients old applications.

Migrating an non MVC application to be compatible with an MVC framework is always challenging but I'd say CodeIgniter is a best choice because of its simplicity, flexibility and extendability.

Good luck![/quote]

Hello! Thank you for your post, but I have been having a hard time recreating your wrapper idea, would you mind posting the code for the wrapper lib, provided of course you are not under NDA or similar.

Thank you again.
#4

[eluser]Peter Drinnan[/eluser]
I made a subversion of the loader class. You can do that in CodeIgniter.

Can't actually post it here because it is too big, but here's the pastebin link:

http://pastebin.com/wjAvaCft
#5

[eluser]manisha[/eluser]
Where can I put the file of code and how can Use the code you have for this?
Do I need create the subclass? If yes,, then what should be the name of that subclass... and how can include or use this subclass in my PHP script which is outside CI ?




Theme © iAndrew 2016 - Forum software by © MyBB