Welcome Guest, Not a member yet? Register   Sign In
SVN + CodeIgniter
#1

[eluser]nertos[/eluser]
hello,

how do you deal with editing a page using SVN, e.g. in eclipse. When the address during editing is http://localhost/~nertos/catalog1/catalo...ass/method, and after moving to server it changes to: http://my-domain.com/class/method. Then the whole code stops working, because locally in the php code i use $id = $this->uri->segment(4,1); and after moving to server I must use $id = $this->uri->segment(2,1);. there are lots of cases like this in my code. Do you have any idea s how to solve this problem? I would like to obtain a detailed explanation of editing SVN for CI.

Thanks in advance.
#2

[eluser]WanWizard[/eluser]
That doesn't look like an SVN question, but an application design (or an SVN repo structure) question.

How do you manage to have your application structure change when you move your code from development to production?
#3

[eluser]cahva[/eluser]
How have you structured your code? I've seen a lot of beginners doing this:

Somecontroller
Code:
function show()
{
    $id = $this->uri->segment(4,1);
    if (!$id)
    {
        return FALSE;
    }

    // Do something
}

Assuming that id would have come after the /show/ this would been better done like this:
Code:
function show($id = FALSE)
{
    if (!$id)
    {
        return FALSE;
    }
    
    // Do something
}

That way it doesnt matter what url you are on..

Other thing that you should consider is giving your projects a proper urls in your local dev machine. For example I always add vhost to my webserver and add a domain pointing to my localhost. Something like this:

- production server: www.mysite.com
- local server; local.mysite.com

To get the "local.mysite.com" to point to my own devserver, in windows environment I add this line to C:\WINDOWS\system32\drivers\etc\hosts file:
Quote:127.0.0.1 local.mysite.com

After that the directory structure will be the same on both:
Quote:http://www.mysite.com/class/method
http://local.mysite.com/class/method
#4

[eluser]Nick_MyShuitings[/eluser]
[quote author="cahva" date="1283368976"]
Other thing that you should consider is giving your projects a proper urls in your local dev machine. For example I always add vhost to my webserver and add a domain pointing to my localhost.[/quote]

Cahva hit it right on the spot. Regardless of whether you refactor, you should definately take the ten minutes necesary to create a vhost so that you have the same structure .com/path/to/controller/method both locally as in your intended dev.

This issue is only more critical due to the fact that you are using uri segments.




Theme © iAndrew 2016 - Forum software by © MyBB