I need to solve the next problem: - I have a - rather messy - directories tree on /www/todo, on a server, which contains files scattered in different non-standard directories, all called proposal.htm. - at the moment, I need to make it accessible from a browser with a series of well predefined URLs: root_url_name/(/d{3})_(OK|NOK)/todo/d{1}), with d{1}fixed between only 1 and 5.
Examples: ~~~~~~~~~~ · root_url_name/000_OK/todo/1 ==> returns the file www/todo/ + followed by a precise path which will be manually written in the routing map + proposal.htm. · root_url_name/742_NOK/todo/3 ==> returns the file www/todo/ + followed by a precise path which will be manually written in the routing map + proposal.htm.
This is " all ".
I've seen that Fuel uses a lot the class libraries, unlike other frameworks like ZF2 - the only one I know - where I have to set up a real application, with its events distribution loop (hashed URIs) leading to their controllers, using explicit declared objects that can be obtained from a global object called a " objects \ components service manager", which creates the objects \ components we want to use. But I find it "heavy" for my problem.
With Fuel, is it possible to use class libraries (using the offuscation of objects through the use of class libraries, while still using the object confluence of Fuel), to quickly set up an emulation of the application object, around my problem?
Is this the only fuctionality this app needs to perform?
If so, create a Controller that deals with retieving and returing the file, and a route that directs all requests to that controller. You don't even need to use a regex in that route (but you can if you want).
In that controller, you use the Uri class to access the URI segments used in the request, and use those to locate the correct proposal.htm. And if not found, throw HttpNotFoundException to generate a 404.
> > Is this the only fuctionality this app > needs to perform? >
Yes, that's all I have to do: that's why using a real php application (a real application with its events loop distribution, etc) with a such small application, seems an overkill with ZF2.
I'll study your recommendation about the class Fuel::controller (I already studied the smart class Fuel:router which looks a lot like the one in ZF2, but which is more enclosed, autonomous). I'll do some tests, and I'll post a feedback if it's an adequate solution, or if there are still some more complicated "aside" to complete a lite solution.
ps: ZF2 does the job, but the problem with ZF2 is that its Classes are still very interrelated: each Class is still very interlinked with the need to use other Classes. This is the goal of ZF3 or Lavarel3 or Symphony3: each Class must have one and only one precise role, and should be instantiated alone.Thus, each ZF3 Class must be in its own Java-like directory. Other frameworks follow this road towards the ".3" version, so that within a Framework can easely use Classes from other frameworks: inter-frameworks interoperability.
There is no need to study classes, routing in Fuel is done through a config file, see the docs.
The same is true for a lot of other things, Fuel tries to keep things simple, compared to other frameworks where you spend most of your time moving class instances around.
If you want to study the anatomy of a Fuel app, this might give you some pointers: https://github.com/jhuriez/fuelphp-blogMVC. A bit dated but useful, it also has some good routing examples...