• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing an Independent Application from Withing a CodeIgniter Application.

#1
I built a small database resource for a client using vanilla PHP several years ago. I have just completed a custom CRM for the client using CodeIgniter 3. The client wants to be able to access the database resource from within his CRM, instead of linking to it from his website.

I have three issues to solve:

1. Right now I have the resource in a directory independent of the CRM, and just link to it. Is it possible to place the resource directory inside the root folder of the CRM? Would there be an advantage there?

2. How can I piggy-back on the sessions of the CRM so that I can make sure a user is logged in to the CRM before he can access the resource, instead of directly?

3. How can I redirect the user back to the CI page he came from after he is finished with the resource? I have 5 roles in the CRM, one of which will go directly to the resource when they log in, the other four will go to the resource from a menu item on their particular home page in the CRM.

Best scenario would be to redo the resource as a CI application, and part of the CRM but I don't have time right now to do that. I have two weeks to get this done.

Thanks.
Reply

#2
The answers to your questions are more or less based on the code of your other project, not on CodeIgniter, though I can say that for #1, there's almost no benefit to putting something in the root folder of your CodeIgniter project.

In most cases, if I want to integrate an external PHP library or application with CI without doing some heavy modification of the library/application, I put it in the /application/third_party/ directory and write a library (in /application/libraries/) to interface my CI application to the external library/application. The exception would be if I could auto-load the library with Composer, in which case I would do that instead of putting it in the /application/third_party directory.

In some cases, you could put the library/application in your /application/libraries directory. The loader is pretty forgiving when you load libraries, but there are certainly cases in which this can cause more problems than it's worth.

#2 and 3 are not likely to be answerable without more information about the database resource and how you expect to access it. Additionally, a "vanilla PHP" application, especially from several years ago, could mean a lot of different things. The easiest way to get it to work with your CRM would probably be to refactor it into a CodeIgniter library or controller, or setup a controller and/or library to interface with it. Once you have something like that working, you could take your time refactoring the rest of it into your CI application.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.