Make your choice, adventurous Stranger, Strike the bell and bide the danger, Or wonder, till it drives you mad, What would have followed if you had

  • C.S. Lewis

Things today have been a bit crazy as I have decided to be a crazy person and start out to refactor the awesome Wardrobe CMS as a Composer package for general integration into Laravel 4 projects. The shift came as I began to look at integrating Wardrobe into iOffertory as product update blog within the platform.

The process so far has been relatively straight forward, but quite tedious. There are many things that differ in modular developement in comparison to general application development in Laravel or any project.

1. You have to worry about collisions.

This means that your controllers can't be sitting around with generic names that would be common in other projects. As a prototype, Wardrobe used the global namespace for much of its controllers and routes which had to be tweaked ever so slightly.

2. Routing woes

Since Wardrobe was traditionally developed to work on raw TLDs or Subdomains, there is a bit of a worry as to knowing where the routes are. Given that one of the goals of the refactor was to allow subdirectory installation, the code had to drop all raw URL::to calls in favor for URL::route which will hunt down and resolve URIs no matter where they may be located.

3. Package installation

To make package installation as simple as possible, one should be able to just grab the package off of Packagist and throw in their necessary Service Providers and Aliases and be up and running. To do this, all of the assets and configuration had to auto publish. Luckily, this was a simple addition to the installation script (accessible from the blog subdirectory).

However, this comes with some drawbacks, first is the fact that all calls to configuration and language have to be "package-ized" meaning that Config::get('wardrobe.*') has to be changed to Config::get('framework::*') not a big deal in complexity, but configuation calls are scattered throughout the code.

The codebase is incredible, but this are some standard issues one comes accross making code a bit more reusable and modular.

If you would like to follow along with the progress check out the project on github.