I'm trying to find a clean approach for a simple problem in php 5.3.
I'm not having implementation problems whatsoever, just thinking about the best method to setup a clean solution.
Here is my project:
- I request data from a public API.
- The data is JSON. I convert the JSON response into a php object
- I pass the php object to my view (template engine) where it is iterated over and both raw and mapped data is displayed.
This is my current state of code:
In index.php i require all classes and the configuration. I could write an autoloading class but i don't think this would make sense at all, since every class i require is always used.
I then read my config file and I create a Options object from it.
Also a Request object is created to which my Options object is passed via constructor injection.
In this object I perform the actual request to the API and I get the JSON back. Should I convert the JSON response in the Request object or should I write some Helper Class to perform this task, since the conversion has nothing to do with the actual Request?
Still in index.php I create the necessary View object and create a Controller object to which the View is passed and call its indexAction.
My folder structure looks like this:
A. Classes
AA.Controller
AAA. IndexController.php
AA. Service
AAA. Service.php
AA. Options.php
AA. Request.php
A. Configuration
AA. config.php
A. index.php
So, how do I setup my project for the cleanest solution possible?
Since I do not have a model I have no "M" part as in MVC. I only have these 2-3 Classes which I don't know a clean way to deal with.
Should Options and Request be classes on their own or should they be just methods of Service?
Should I completely remove Service and just create a Helper class since it is not really a Service Layer? Currently I only do some mapping from raw data to fixed values in Service
I am looking forward to hearing from you guys