Welcome Guest, Not a member yet? Register   Sign In
Switching from plain PHP to CodeIgniter
#1

[eluser]Scared[/eluser]
As per the title, I am looking at switching from writing plain PHP to CodeIgniter.

However, being very very busy I don't really have time to spend weeks (or even days) fiddling around - I really need to get stuck in.

I just wondered how other people did this. Currently I don't have a "framework" as such, but I do have lots of classes, functions, bits of code and templates that I re-use amongst projects. This means that for a new project I can make progress pretty quickly.

I'm worried that being new to CodeIgniter it's actually going to take me far, far longer than normal to develop a project. The temptation is to just stick with my current method which is fast at the moment, but long term not as good as using a framework.

Any advice or suggestions gratefully received.
#2

[eluser]ivantcholakov[/eluser]
It is possible a plain PHP site to be rewritten using CodeIgniter gradually, not in one rush. I did such tasks several times. I still have 3 relatively complex sites, which have public side totally rewritten in CodeIgniter and administration side still in "mixed" state. And nothing forces me to hurry up.

I am in process of publishing my "bag of tricks" here: https://github.com/ivantcholakov/starter...-edition-3. This is a unfinished work yet, but what you are looking for is ready.

See the example "The Playground / Non-MVC Page Demonstration", the technique is explained there, also have a look at source.

Here is how I make transition on a development machine:

1. I place the platform inside the site.
2. On a common initialization point (usually where database connection is made) I insert code that initializes the platform too.
3. I make a duplicate database connection in the platform.
4. I scan for SQL queries within the site and create models based on those queries. And then I replace the queries with model method calls. At the end i remove the old database connection and code related to it.
5. I make templates according to HTML code.
6. I group the legacy functions from the site in corresponding helpers, I also have a place to paste classes that can be loaded automatically.
7. After that I replace the pages with based on them controllers+views. The controllers extend a base controller. I start this replacement from the home page. I delete the old pages.
8. Having nice Error 404 page is good.
9. The links should be updated. Assets (css, javascript, images) may be cleaned and relocated.
10. If it is necessary, I make Google friendly redirections: old links -> new links.

When you do such a transition, avoid implementation of new ideas. Separate technological innovation from the next conceptual innovation, otherwise you will get in the middle of a mess.

Last thing: Start with the developers' version of CodeIgniter 3. The older version 2.4 technically is too old.
#3

[eluser]Scared[/eluser]
Thanks for your reply.

I created a login script this evening. It took me quite a while and much of it was "copy and pasted" from examples I found on the web - without those examples I wouldn't have been able to do it.

I'm torn between just doing what I know and getting the job done, or doing it properly with CI. I know as soon as I run into something where there aren't examples on the web I'm going to be totally stuck.

I wish I was better at this stuff...
#4

[eluser]Alucemet[/eluser]
You should read the documentation. Once you have done this, you will find CodeIgniter to be very simple to work with. When you have problems, refer to the documentation, search Google for an answer, or come here and ask a question.
#5

[eluser]ivantcholakov[/eluser]
@Scared

It is the year of 2014, not 2004. You have to find a way to adopt to MVC methodology for making maintainable code with quality. Otherwise you would waste your time. Just copy/pasting snippets from web - it doesn't work this way.
#6

[eluser]jonez[/eluser]
[quote author="Scared" date="1389402491"]Thanks for your reply.

I created a login script this evening. It took me quite a while and much of it was "copy and pasted" from examples I found on the web - without those examples I wouldn't have been able to do it.

I'm torn between just doing what I know and getting the job done, or doing it properly with CI. I know as soon as I run into something where there aren't examples on the web I'm going to be totally stuck.

I wish I was better at this stuff...[/quote]
Everybody starts somewhere. My best suggestion is to continue using examples until you start to see the flow of how CI operates. After a week or two it will make a lot more sense. Once you feel more comfortable start rewriting your modules from scratch, check the documentation it's quite good and covers just about any question you can have. If you run into a problem you can't find an example post it on here and someone will likely point you in the right direction.




Theme © iAndrew 2016 - Forum software by © MyBB