0

FOSP For Developers Part 1: Intro to Bonfire and HMVC

To begin developing with the Fox open sports platform, I need to first throw out a few helpful and important prerequisites:

So….MVC, CodeIgniter, Git and github? Wow, that’s a daunting list, huh? Well, yes and no.

The good news is all of these prerequisites come with lots of very, very good documentation and tutorials (see all the links above). And if you get stuck, Google for some help and you are going to find it. StackOverflow.com may become your new best friend.

Next, every item on the list is complimentary to one another. So once you learn the basics of OO programming and MVC for example, CodeIgniter and HMVC will make a lot of sense and should be relatively easy to pick up as well. And if your light on GIT or code versioning, no worries. Well cover that more in depth in part 2.

I promise, learning these things will only benefit you as a developer if they’re not already in your wheelhouse.

Let’s meet Bonfire

Bonfire is the foundation of the OOWP infrastructure. Its base controllers, models and libraries provide a host of helper functions and shortcuts on top of the already impressive set you get from CodeIgniter itself. To work with the OOWP effectively, it is important to understand the basics of how Bonfire works on top of CodeIgniter and provides the architecture for an admin dashboard area.

I highly recommend spending a little time at the Bonfire Learning Center to get up to speed. Once you learn how Bonfire works, it can be a highly effective tool in writing expandable and reusable code and tools.

Bonfire is very well coded and easy to learn. The Bonfire team has video tutorials (which will need updating once 0.6 is released but are still appicable to the library) and the aforementioned help guide available on their site to help. The team is also available via their web site and quite active on Github to answer questions and provide help if needed. I myself have made code contributions to the Bonfire core projects 0.6 release and can likely help answer some questions as well.

Understanding HMVC Modules

In the Bonfire world, modules are simply collections of MVC based functionality stored in the modules folder. They are implemented in Bonfire using a library calledModular Extensions. This is an open source mod created for CodeIgniter by wiredesignz. It allows controllers to be more integrated into the site and available the way other classes are (such as $this->controller->function()) or to be called like helper function (via modules::run()).

NetTuts has a great introduction to HMVC and the usage of this mod in their HMVC Introduction and Application tutorial.

The structure of modules mimics the basic folder structure of any Codeigniter application, so knowing how a CodeIgniter app folder looks, give a basic understanding of modules in Bonfire.

By default, any module can have the following folder structure (required folders are italics)

  • assets
    For storing any module specific CSS or JavaScript files
  • config
    For the config.php file and other config items (routes being an example)
  • controllers
    Stores the controllers that respond to http page requests
  • helpers
    Stores helper files that act like PHP includes
  • language
    (english, et all…) Contains language files that are used for supporting text translations. English is always called by default
  • libraries
    Any shared or third party classes required by the mod to run
  • migrations
    For Database Migrations files
  • models
    Stores all data models used to interact with the database and other data elements
  • views
    The HTML UI presented to the user. May include CSS and JS as well.

Each module should almost be able to function as a standalone CodeIgnitner application. Meaning, you should be able to drop it into any “bonfire/modules” folder and it should be ready to go the next time you refresh your web browser (baring any database requirements or dependencies on other modules). As such, many of the basic rules that apply to CodeIgniter applications also govern Bonfire modules as well. So as I said in the beginning, learning one thing benefits you later on.

So that’s a basic review of Bonfire and the structure of the modules you’ll be building on top of it.

To get an idea of what some modules look like, check out the listing of modules in the Bonfire forums.

In part 2 of the developers overview, we will set ourselves up with Git version control and checkout the source code of an existing OOWP module from github.com, the Online League Manager.

Download the FOSP Today!
Download the latest stable release version from the official FOSP web page. All the documentation you need is available in the installation and setup guide.

Contribute to the development and help the FOSP grow
The FOSP is a 100% free and open source project. The source code is publicly available on GitHub.com. If you want to contribute to the development, simply head over to my official Github page, fork the related projects, hack the code and send pull request with your updates. It’s that simple.

If you’ve built an FOSP module let me know and I’ll add it to the "Built on the FOSP" list.

Want to help test?
Testing assures everything works as expected and that everyone gets the best fantasy experience possible. Simply download and test the site and log issues on the official Github issues pages. Each portion of the site has its own page and issues list so be sure to log the issue in the appropriate module portion of the site.

Donate
While the FOSP is free to download and use, we do very much appreciate any donations made towards its development.

jfox015

Jeff Fox is an over twenty-year web developer and digital user experience technology leader. Jeff cut his teeth in the Web's early days and is mainly self-taught in his professional skills. Having worked for a broad number of companies has helped build skills in development, organization and public speaking. In addition to being a passionate developer and technical speaker, Jeff is a dedicated tech and sci-fi geek gladly indulging in Doctor Who and Star Wars marathons. He is also a talented musician, writer and proud father of three little Foxies. And don't get him started about his San Francisco Giants.

Leave a Reply

Your email address will not be published.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.