Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
607 views
in Q2A Core by

I am using q2a 1.7.5 largely customized by myself. In q2a 1.80 new controller and routing system was introduced.

How it works, whats new on it? What are its advantages comparing to old one?

I am trying to understand it thoroughly so that if it is beneficial I would to implement it to my q2a 1.7.5. 

I note that include/qa-base.php was moved to app/page.php. And function qa_page_routing() was modified and new function qa_routing_config() was introduced.

And qa-src directory established with controller files in it.

Q2A version: q2a 1.7.5 customized

1 Answer

+3 votes
by
selected by
 
Best answer

The best piece of information I can give you is that it is not part of 1.8 but rather 1.9 :)

How it works, whats new on it? What are its advantages comparing to old one?

It requires PHP 5.3. It uses namespaces. It's part of moving the PHP 4 structure the core has into something more object oriented. Not having a router class in any decent framework nowadays is a no-go. Entry points are easy to manage now as you can see in the qa_routing_config() function.

In short, there is now an application class that is basically a very simple container (finally!). It would eventually help for dependency injection but not for the time being. The container holds the router. The page file, when executed, loads the routes. At the moment not all pages are routed in the new schema. Each route understands how to be matched and where it should be redirected. That where is a specific controller for the given page. If you know Laravel you should get familiar quickly with the flow.

Another advantage of having controllers is that you can use middlewares. So I suggested adding them. Check this pull request for more information.

I tried to comment some relevant methods so that could help as well. If not, you can always ask for more clarifications :)

In Github there are a few threads and pull requests I had with Scott that might shed some light on this as well.

I am trying to understand it thoroughly so that if it is beneficial I would to implement it to my q2a 1.7.5. 

Firstly, upgrade to 1.8. Then consider that question :) Anyway, it doesn't really make sense to try to apply that in your core because, on one hand, it is unfinished and there is a long way to go and, on the other hand, it just changes how the core works and there are no new end-user-features added there.

by
thank you, when this new routing system will completed, then I will implement it.
...