开发者

File Structure + Shared Features Between Controllers

So im stuck with a file structure problem, i'm trying to find the best way not to repeat things. Im trying to get features shared with each extra section (Music, Movies, Shows etc). The Features being Likes, Recommendations, Tags and List. I'm looking for advice on how to structure it so there will be minimal repeating of code and easy secure access to the features for each section. The details are below. Also I am using Fuel PHP framework: http://fuelphp.com/

There are listings: Music, Movies, Shows. (http://domain.com/music/view/1) Each listing supports Tags: (http://domain.com/music/tag/view/rock)

So far that's easy, but features like 'likes' and 'recommendations' confuse me, as in I could have 'likes' in each listing's controller. Example (http://domain.com/music/like/1) or in its own controller (http://domain.com/like/music/1).

Also each listing has 'recommendations' which list similar listings with reviews and 'Likes' for each recommendation. So 'likes' can be for listings and recommendations.

Music (Model_Music)[one-to-one Model_List]

-- L开发者_如何学编程ikes

-- Tags (many-to-many)

-- Recommendations (cross-reference by UNION)

-- List (in this case all tracks and the song name) [one-to-many]

Shows (Model_Shows)[one-to-one Model_List]

-- Likes

-- Tags (many-to-many)

-- Recommendations (cross-reference by UNION)

-- List (in this case all episode names and number)[one-to-many]

As you can tell most of it will be the same code just with different URL structure and some changes on which table to use. I'm just not sure how to handle things best, just need a more experienced view on handling all these additional features to each listing music.php, shows.php, movies.php any any others that will be added.


I would recommend creating a base controller to build all your specific listings from.

So you would create a listings folder in your controller directory, and also a listings.php as a base for all controllers in the listings directory.

You just extend the base controller in all your listings controller and any functionality that is in the base controller is inherited.

more details on how to structure base controllers in fuel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜