Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to learn Fuelphp routing
  • OK, it is important to understand URI routing, especially for beginner. I had started to learn and use this framwork one month ago. And first a few hours, for routing touble. :D And a few days ago, I had a trouble about this. So to understand routing and kill my bugs, I tried to find good idea. Then, I got an idea, made one small controller like this:
    <?php
      class Controller_Testroute extends Controller &#123;
        function action_index() &#123;
            Debug::dump($this->request->route);
        }
    }
    

    And temporary all controllers and actions changed to this class/action on app/config/routes.php. This small code show information to debug/understand routing of fuel. Specially 'path' show matched pattern. Now the time to use your eye-balls(for docs) and hands(to type) and a head(to understand) with Fuelphp routing. Try those: Q1: This code don't work to intend. Why? and How correct it? in routes.php... ':year' => 'calendar/yearly',
    ':year/:month' => 'calendar/monthly',
    ':year/:month/:day' => 'calendar/daily', Q2: If you successfully corrected Q1 pattern, add route to 404 when more than 4 segments specified. Q3: Alter with Q1 pattern. This also don't work. Why? How correct? 'blog' => 'blog/index',
    'blog/(:any)' => 'blog/anything/$1',
    'blog/post/(:num)' => 'blog/create/$1', Q4: Now Fuelphp version.1.1, your_domain.com/Hello and/or .../HELLO, and/or .../HeLLo don't match this. How specify a pattern like non case-sensitivity? (Basically, capital URL is not good by historical reason about old file name system. So just try as funny question.) (Tips : It is just regular expression problem.) 'hello' => 'welcome/index', Q5: What segment match with this route pattern? (not only abc/def/xyz patter. fine more. Tips: Which difference between :any and :segment?) 'abc/(:any)/xyz' => 'dummy/things/$1', Q6: Final question. Correct this to work properly. (Non defined patterns must go to 404.) ':categorya' => 'index/show/1',
    ':categorya/:categoryb' => 'index/show/2',
    ':categorya/:categoryb/:categoryc' => 'index/show/3',
    ':categorya/:categoryb/(:num)' => 'index/showboth/$3',
    ':categorya/:categoryb/:categoryc/(:num)' => 'index/showall/$4',
    'blog' => 'blog/index',
    'about' => 'blog/about',
    'signup' => 'user/create',
    'login' => 'user/login',
    'logout' => 'user/logout',
    'blog/post' => 'blog/create',
    'blog/post/(:any)' => 'blog/create/$1', For beginner, use your hands, use your eyes, use your head. There are funny questions to solve. And you can get a lot of idea about routing. Change all controller/action to testroute/index in routes.php and try them. Have a fun! P.S.
    I'm not good English writer, so sorry to understand my writing. ML Hirohisa Kawase
  • On my first post, I gave some question about fuelphp routing. Before I used named parameter like ':area1', ':area2' on some questions. But it made error. So now changed to 'areaa', 'areab' to prevent errors. What I did. I never said it was any error, because no explain I can use numeric character on named parameter. Just correct my code(questions).
  • So if I understand correctly, the issue is that ":area1" doesn't give an error, but simply doesn't work, because it has a number in it?
  • Yes. But I don't know 'doesn't work'. The document don't say I can use number in name. And someone want to know about fuel routing see this topic, and find they can't use number in their named parameter. ;) That's all.
  • We'll have a look at why it doesn't work. Probably the way the name is detected.
  • Um.... There is bug on this forum system. A character '[' changed to '{' after repeated edition on the post.
  • We know. Will be fixed shortly...
  • I used named parameter with num like 'area1', but it is not able to. An error happen. So I changed named parameter included all alphabetic character on Q6.
  • Can you explain exactly what you mean? What did you do? What didn't work?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion