Versioning code in codeigniter |
[eluser]Unknown[/eluser]
This is my current setup -site --webroot --app --controllers --v1 --home.php --users.php --v2 --home.php --users.php --models --v1 --home_model.php --users_model.php --v2 --home_model.php --users_model.php --views --v1 --home.php --users.php --v2 --home.php --users.php The issue that I am trying to resolve is how to do i have to versions of the code live at the same time without changing the url this is my current routes file $route['default_controller'] = "v1/home"; $route['v1/(:any)'] = "v1/$1"; $route['(:any)'] = "v2/$1"; $route['404_override'] = ''; this is my current .htaccess file RewriteEngine on RewriteRule ^v1/(.*)$ $1 RewriteRule ^v2/(.*)$ $1 #RewriteRule ^v1/(.*)$ /$1 [L,R=301,QSA] #RewriteRule ^v2/(.*)$ /$1 [L,R=301,QSA] RewriteCond $1 !^(index\.php|public|user_guide|robots\.txt) RewriteRule ^(.*)$ /index.php?/$1 [L]
[eluser]CroNiX[/eluser]
Why would you want to do that? Just use git and create a new branch for v2 or something.
[eluser]Unknown[/eluser]
I want to access both the code versions e.g. /v1/users/get_users -> /users/get_users (Read and process data from v1) /v2/users/get_users -> /users/get_users (Read and process data from v2) I dont want the url's to reflect the version id but want the routes to determine which version it is and appropriately process the business logic based on the version
[eluser]CroNiX[/eluser]
[quote author="shethvarun" date="1411501144"]I dont want the url's to reflect the version id but want the routes to determine which version it is and appropriately process the business logic based on the version[/quote] But routes determine where to send the request based on the current url, so it would have to be in the url wouldn't it? You could always use a query string, ?v=1/?v=2, and have the models/controllers load the appropriate versioned code. Or a dropdown in a menu that appears on every page, which sets a session variable or something. Personally I would have just created a separate project on it's own vhost, so you could go to http://project1.dev or http://project2.dev because you're going to have a bunch of temporary code now that you're going to have to add and then remove when you're done doing it this way. |
Welcome Guest, Not a member yet? Register Sign In |