I am looking some example How to Write MVC code without Any Framework in PHP.

any one has any idea ?

    9 days later

    Hi

    for a starter, there are a few nice articles around at devshed.com by Alejandro Gervasio. Depends on what you want to achieve...

    You might end up writing your own micro-framework. That's what I ended up with at least (and still am in the middle of). Very good project to get into php and web and stuff.

    Bjom

      Can you plz send me the link of that topice .

      [unrelated link deleted -- MOD]

      can you send me link the topice with this author .

        21 days later

        You will almost definately need some kind of a framework, at a bare minimum your going to need some kind of template system, beacuse in the heady world of MVC separation of content from code is paramount.

        As bjom states, you may likely end up writing your own mini framework that contains just the functionality you need.

        You will also have to read up on configuring your web server too. Most MVC style web applications use url's like the following:

        http://my.web.app/home/start

        or

        http://my.web.app/products/display/1

        To achieve this your going to have to set your web server up to recognise the url format and then pass it to the appropriate php script. Under Apache this can be performed quite easily using mod_rewrite.

        Just writing an MVC app on a page by page basis in pure PHP without making at least a mini framework, is going to be a big job, if you don't want to use any particular framework, i would at least suggest that you reuse smaller components of other frameworks, things such as the Smarty template engine and an inline editor for page creation.

          No

          I have done all and written my own php liberries but onlny looking for URL Routing system to keep track those page.

          Rest I have done and looking some way to do work wihout framework.

          Thanks

            Ah....

            well as i say, you'll want to look closley at using mod_rewrite if your using apache, if not and your using some other web server then you'll need to consult the documentation. EG:

            IIS5 thru IIS6 cannot do native URL handling, even with the MVC extension kit, IIS7 in native mode however can.

            Cheers

            Shawty

              I m on Apachee and having experice of URL Rwrite as well .

              But for url-rewriting for mvc is bit differnt and difficlyt i think

                Heh.. yea.... I'm not gonna kid you, mod_rewrite is difficult, and not for the feint hearted but what your aiming to do is best done using mod rewrite... consider this...

                You want to use URL:

                http://my.web.app/products/display/1

                but your PHP script is called

                products.php

                and it takes 2 parameters, action and id, example:

                http://my.web.app/products.php?action=display&id=1

                You need mod_rewrite in order to transform your URL's like this, it cannot be done in PHP alone.

                  mod_rewrite is not THAT hard. Definitely not the hardest part of the whole MVC thing.

                  Have a look at a Zend Framework tutorial, like Rob Allen/Akrabat's tutorial, to see what they are doing and you'll quickly get an idea of what to do.

                  BTW: This is related not so much to MVC as such, but to the so called "Front Controller pattern" which can be part of MVC approach but does not necessarily have to. (I chose not to implement it, because of its redundancy, see here: http://www.phppatterns.com/docs/design/the_front_controller_and_php)

                  So whether or not you even need to rely on mod_rewrite a lot is up to you.

                  Bjom

                    Write a Reply...