Status of GET and querystrings in CodeIgniter?

#21
[eluser]stommert[/eluser]
This is my last reply. I agree with n0xie. I'll just resume the arguments on why querystrings should or should not be supported by default.

Pros on querystring
- other frameworks use it (I don't see it as an argument but ok)
- search engines use query strings (I don't see what that has to do with CI).
- better with forms (I don't see why GET is better then POST except cross site, but why would you want that)
- proper web programming (WHY, what makes you believe that query strings are a part of proper webprogramming?)
- some services require it (you just turn it on).
- Ray Fielding would agree with you (have you asked him)

Cons on querystring
- 99 procent of the time you don't need it (ok I made the percentage up, but think about it when do you need it)
- faster
- more save
- more SEO friendly

And still this is a discussion on something that can be turned on by toggling a boolean.

You started this discussion with
Quote:It really is quite surprising that CodeIgniter does not support querystrings by default. I imagine that this deficiency alone is a show-stopper for many potential users
this statement. Imagine what if people might think you are right and CodeItniter should do things like other frameworks. As a framework and as individuals we should think before we copy the implementations of others.

And still, this discussion is about a default value in the config file.

Ps. I'am nog insulting you, its not personel.

#22
[eluser]Unknown[/eluser]
I ended up on this thread while searching for how to get querystring support in my app. Search is the easy, obvious example of where querystring-based approaches are more elegant, but there are many other usecases, such as needing to receive oauth callbacks from other sites, etc. Furthermore, any good search url on a site should be usable directly from the address bar given you know the params, a la ?q=myquery&page=1. This is a de-facto standard, and IMO everyone should use it in the absence of a compelling reason otherwise.

I think a good portion of the confusion surrounding this issue could be cleared up by providing better implementation details than simply saying "it's a setting, just turn it on."

My app needed twitter oAuth support, and my experience was that turning on querystrings in CI is a 3-step process:

1) enable query strings in config:
Code:
$config['enable_query_strings'] = TRUE;
2) use PATH_INFO for routing
Code:
$config['uri_protocol']    = "PATH_INFO";
3) update .htaccess
This is what I was missing in the other examples I found. The default .htaccess I had sends the whole uri path as a get string, so
Code:
RewriteRule ^(.*)$ /index.php?/$1 [L]
just needs to be changed to
Code:
RewriteRule ^(.*)$ /index.php/$1 [L]
in both rewrite rules.

After making those changes, I was able to keep my path-based routes intact, and access get vars through $this->input->get() with no problems.

Hope this helps save someone some time. It probably won't work on non-Apache-like servers, but as most of us are using Apache, should be helpful for most.

#23
[eluser]ocdcoder[/eluser]
[quote author="dndrnkrd" date="1267831412"]Hope this helps save someone some time. It probably won't work on non-Apache-like servers, but as most of us are using Apache, should be helpful for most.[/quote]

It works on Lighttpd. I did something similar when i wanted to provide keys for my REST api.

#24
[eluser]SlimDeluxe[/eluser]
[quote author="dndrnkrd" date="1267831412"]Hope this helps save someone some time. It probably won't work on non-Apache-like servers, but as most of us are using Apache, should be helpful for most.[/quote]
Good man, saved me =)
Thank you.

#25
[eluser]WeeJames[/eluser]
[quote author="dndrnkrd" date="1267831412"]Hope this helps save someone some time. It probably won't work on non-Apache-like servers, but as most of us are using Apache, should be helpful for most.[/quote]

I was just about to agree with the OP until I read this. Query Strings now working as required, this info should be put into the User Guide.

Main reason I want query strings is that I prefer them for pagination and for searches. I know I could change to the uri segment method but that's the pattern I want to follow.

#26
[eluser]SlimDeluxe[/eluser]
Just a note, on my hosting (bluehost) PATH_INFO would not work but ORIG_PATH_INFO does.
(btw check my CI based e-store http://playtech.si )

#27
[eluser]Zack Kitzmiller[/eluser]
[quote author="dndrnkrd" date="1267831412"]

3) update .htaccess
This is what I was missing in the other examples I found. The default .htaccess I had sends the whole uri path as a get string, so
Code:
RewriteRule ^(.*)$ /index.php?/$1 [L]
just needs to be changed to
Code:
RewriteRule ^(.*)$ /index.php/$1 [L]
in both rewrite rules.

[/quote]

THANK YOU! This has been plaguing me for months. Can I buy you a beer?!

#28
[eluser]pbreit[/eluser]
Is there any chance of querystring enablement being considered for 2.0? Despite the beating I've taken on this thread, I continue to believe that querystrings are an important aspect of web development and should be supported by default in a framework.

#29
[eluser]Clooner[/eluser]
[quote author="pbreit" date="1277810242"]Is there any chance of querystring enablement being considered for 2.0? Despite the beating I've taken on this thread, I continue to believe that querystrings are an important aspect of web development and should be supported by default in a framework.[/quote]
I vote for a movement to have all the other frameworks have their built in support for querystrings turned off...

But seriously like Noxie said, it is supported by default. You just have to turn a configuration setting on. Even with that troublesome thing(???). It's not different than how you will hide your index.php file in your url. This is also a configuration setting.

Now stop *%#&%^@%1 us around!

#30
[eluser]pbreit[/eluser]
Yeah, but then you lose segments. You should be able to use segments for most of your site and querystrings for the queries. I'm not sure why this is under dispute.

Yes, it would also be nice if index.php did not exist "out-of-the-box". My guess is that this is trickier with all the hosting and web server variations.

I thought this would go without saying but frameworks should make things *easier*, not harder.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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