SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    0 Post(s)
    0 Thread(s)

    I think I need some help for creating my own router

    May you see CleanMVC. That is the MVC that I created before 1-2 weeks.
    Now I'm trying to create a router for CleanMVC.

    Here is the router class that doesn't run yet.

    And using of router is below:
    PHP Code:
    require_once '../library/router.php';
    $router = new router();

    $router->add(array('controller'=>':example''-''function'=>'saffet''-''data'=> ':variable' ,'.html'), function(){
    'just try';

    I'm still getting url as /controller/function/data. This must run as example-saffet-$1.html. In a sense, if url will be example-saffet-exdataaa.html it must run like /example/saffet/exdataaaa. But this is just an example user will can create url whatever they want.

    I wish I can tell. My purpose is creating a router like codeigniter's..


    Now, when I add this:
    PHP Code:
    $router->add(array('controller'=>'example''-''function'=>'saffet''-''data'=> ':variable' ,'.html'), function(){
    'just try';
    I get:
    Array ( [data] => exxdataaa )
    exxxdataaa is the what match with :variable section.

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    45 Post(s)
    13 Thread(s)
    Hi Derpost,

    I had a look at your router class, but I found it difficult to follow the logic in the submit method so I thought I'd rewrite it to try and understand how it works. I ended up refactoring the whole class just as an exercise.. my version is at

    You're welcome to use any of the code if helps at all, and If you've got any questions feel free to ask.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts