Welcome Guest, Not a member yet? Register   Sign In
Trying to use codeigniter in an existing project
#1

[eluser]wwendorf[/eluser]
Hello all,

I'm trying to implement CodeIgniter into an existing web application that has been around for about 8 years. Let me first start out by saying that this application needs a major rewrite as it's the same code base that started with PHP3. Integrating code igniter is an attempt at bringing some structure into the application.

That being said, there are portions of the old site that I need to be able to use from within CodeIgniter. One of the first issues I am finding is that there is a file called logincode.php and menu.php on the existing site. login_code.php loads the security settings into an array called $repdata, which menu.php reads and displays the menu based on security privileges.

In trying to implement this functionality into a new install of codeigniter. I'm currently using the welcome controller and welcome view just to test.

In order to get these menu items to load, I have had to do:
include("login_code.php");
include("inc/menu.php");
in the welcome_view.php file.

Would this be the best way to do this, or does anyone else have any other suggestions?

Thanks,
Wade
#2

[eluser]n0xie[/eluser]
Can't you copy the functionality and make it into a library or model?
#3

[eluser]wwendorf[/eluser]
Yes, it could be done, but not if I don't want to have to edit the menu in 3 separate locations to add 1 new menu option.

They tried using Zend framework already, which didn't work out well, and that's what they had to do was edit 2 different menu config files in 2 different locations.

I'm trying to reuse their existing code for functions that are already in place, and use CI for new functionality, and eventually migrate everything to CI. It's HUGE application and will take a long time to migrate, hence trying to get it running simultaneously.

Thanks,
Wade
#4

[eluser]Fabdrol[/eluser]
I've done some rewrites of existing applications, and in my experience it's faster to rewrite the entire app in codeigniter (also for future updates) than to try to combine parts. If you still want to do so, I'd recommend using CI on different pages, so that CI and your old code don't sit in the same page..

Fabian
#5

[eluser]wwendorf[/eluser]
Like I said, you haven't seen the size of this application or the inter-relation of code and data between different portions of the site. A full rewrite is not feasable. However, a gradual migration is.

We are using CI for new development, and when we have downtime, we will rewrite existing code into the CI framework.

That being said, I still need the ability to use existing arrays of data from the old codebase inside of models, controllers or views. The only way I can seem to figure out how to do it is to run the include("login_code.php") in the area that I need the data from $repData in order to make the data local to the function that I'm within.

Thanks,
Wade
#6

[eluser]Fabdrol[/eluser]
Well in that case..
I'd write a 'connect' library. You include all the dependencies in that library, and write getters and setters for the necessery data. (in a way, you treat the 'old' code as if it's a data source, like a database). That way you'll have the data available in CI - in a CI way.

When the time comes you migrate completely, you can easily adapt the 'connect' library to get and set data directly from the DB, in stead of via the old system.

I hope this helps,

Fabian
#7

[eluser]wwendorf[/eluser]
That's an interesting idea.

So, if you are saying that I have an include file that is raw, non function based code, such as the login_code.php file is (it runs where you include it) that I should put it inside of a model or something, then after it runs, assign the $repData array to a CI array for passing back and forth inside the framework?

Wade
#8

[eluser]Fabdrol[/eluser]
Could you post the code in login_code.php? Then I'll be able to show you how to get started.

Fabian
#9

[eluser]wwendorf[/eluser]
Here is the source code. Be warned, it is NOT pretty.

Wade

<attachment removed>
#10

[eluser]Bart v B[/eluser]
hmm.. in this case i would recommend to start building from scratch.
first write the code on a dev server, and then when it's working on the live server.
I mean, the old code is still working.

Sound a little strange, but why mixing old code with new?

As far as i see from the downloaded code, it would be that much more work when it's a better code right?
Maybe it's more work now, but in the future you have the bennefit that you need to write less..

If it's a money or time question, ok then i did not say anything offcourse.




Theme © iAndrew 2016 - Forum software by © MyBB