FEATURE:Use concatenated url instead of rewrittin urls

Hi! I am planning to actively use an mvc pattern for a big project that is coming up. I had a look at many framework but wanted something as small and simple as possible (didn't want to rely on someone else's extensions to the framework) then decided to start my own little thingy then found out about picora. I am really impressed so far and I think I'll use it instead of writing something from scratch that would closely resembles picora in basic features but would lack the same level of tweaking, planning, security and code-to-solve-unanticipated-problems due to my lack of experience :)

I am a little bit nervous though to use rewritten url with POST forms in the administration part. I would also like to have the possibility to 'turn off' url rewriting and have picora's dispatcher understand something like this: PicoraDispatcher::addRoute(array( '/' => array('Page','index'), '/$name/' => array('Page','page'), '/index.php?controller=page' => array ('Page', 'page') )); So I could use concatenated url and rewritten url and don't change a thing my controllers and view. Is that possible with current version of Picora?

Thank you!

Posted April 5th, 2007 at 8:10am by nolan

Couple of seperate issues here...

So first, why so nervous? Try it out, it should work just fine. If not, email me a bug report. A couple of apps are running tens of thousands of requests a day, many of them POST, with no problems. I'm not putting a 1.0 label on it yet, mainly because it hasn't been tested on a ton of platforms, but so far it seems pretty solid.

Second, the url rewriting only looks at the part of the string before "?", and it has to stay that way for a variety of reasons.

Third, you can have multiple php files run the same application. It isn't designed to be the easiest way to do things, but you can always do something like:

PicoraController::call(array($_GET['controller'],$_GET['action']),array_merge($_GET,$_POST),array());

in any file. Messy, especially since you can't use getUrl(), but it will work.

Can you elaborate on your fears with the POST requests?

Posted April 5th, 2007 at 11:10am by ryan

BTW, Picora is designed so that you can drop in your own PHP files into any part of the application that will run totally independently of the Picora app.

Posted April 5th, 2007 at 11:13am by ryan

Hi, Thanks for your answering so fast and sorry for my not getting back to you sooner.

Sorry for the vague post, I was (and still is but things are getting better) a bit fuzzy and sleepy. As I mentioned it in my first post I was working on my own little mvc script (which is really crude and not oo at all, would you be kind enough to give me your advice on it by the way?) and got some of my concerns about mvc, picora and my cooking all mixed up.

So: -The post thingy: I was afraid to have problems with the 'action' attribute of a form when the page was finally rendered: would the form direct its input values to a non existent file located at http://localhost/method/controller/ when using rewritten url? Will I have to hack something so the 'action' link can be transformed to index.php?controller=xx&method=xx? Finally I just realised that the controller is taking care of that all by itself (by its nature) since the application dispatch it accordingly. Keep in mind It was the first time I was using rewritten urls with pages holding forms that change something important to the db. Hence my nervousness but everything is fine now.

-The url rewritting: Does it mean I can't use both rewritten urls and concatenated url? The dispatcher will silently fail if the url looks something like index.php?controller=blog&method=edit&id=tag:domain.com, ?

-The multiple files: Not sure I totally understand this point, isn't every url requests in the folder where the application lives redirected via .htacces to index.php which includes picora?

Well! Hope I was clearer than last time! I think I am going to play a little bit more with my own script to wrap my head around the whole logic of the mcv/rewritten ways and then use picora since it's code is much more robust than my script (can't wait!).

Posted April 7th, 2007 at 6:03pm by nolan

I don't have time to do an in depth walkthrough for you, but in a nutshell, if you stick within the system, everything including POST requests will work with no problem. . htaccess does redirect all the requests to index.php which includes picora. You can call index.php if you want, but it's not the recommended way of doing things. Essentially you want to stick within the Picora way of doing things (look at the sample apps) or build your own seperate PHP files and reference those. You can pick either or both. Picora is not meant to be a jack of all trades and will play nice with other systems.

Good luck! - Ryan

Posted April 8th, 2007 at 9:09pm by ryan

Thank you! I will convert one app to picora and see what's coming up to get a better idea of things.

Posted April 12th, 2007 at 12:02pm by nolan

Login or Register to Post