I started to rewrite very monstrous (and old) web application. It runs on PHP 5.3, the design is completely mad - Models and Viewers, no controllers etc. I have been able to refactor the code to work with PHP 7, bend the autoloader to start using Composer and I want to start refactoring the core.

What I basically need right now is an application structured into framework itself , modular system and a "wrapper?" which defines the application. I would like to create the modular system and define the layers properly without needing to rethink them again in a year or so. Unfortunately I cannot start from scratch, the code itself contains a huge amount of business logic which needs to be separated into modules and this can be done only by digging into it.

HMVC is the only thing I was able to find so far, is that the right approach? I generally need a push into right direction when it comes to sources.

  • "Unfortunately I cannot start from scratch, the code itself contains a huge amount of business logic ..." Then you need to be very careful. Old code may be creaky and ugly, but it is normally doing the job (or at least what the job used to be). You might start by copying the current site/DB and just try to break out the business logic, maybe even in PHP 5.3, regression test it against current, and then port that whole mess over to PHP 5.7. Good luck. Aug 22, 2016 at 3:23

2 Answers 2


Be careful not to mix up things you read...

HMVC is not the same as "modular". It means "hierarchical", so you can always find the way back to the process that 'owns' it, some even holding the former and latter processes that may occur of have occurred (depending on which way you go). But, it isn't the same as splitting it up into pieces. Some make that mistake in naming their approach.

Modular, on the other hand, means it is split up into logical pieces, together forming a whole.

That been said, combining the two, you get the best out of both worlds... But it's very hard to master... ;)

Now to your question:

You can try to separate the business logic from everything else, put them in separate (controller-) helpers in the module you're building. You already stated you have to:

which needs to be separated into modules and this can be done only by digging into it.

... so there is a good start.

Try and understand how it is done in Zend Framework or Symfony. Those can give you a ton of ideas in how to break it up into workable pieces.

As for the autoloader: You can always build one yourself that works alongside the Composer one (either by prepending or appending through spl_autoload_register()). I would recommend trying to find out how you can utilize the Composer autoloader.


I started to rewrite very robust (and old) web application.

Question: Why?

Does it not work? Your "robust" adjective would suggest otherwise.

Is there some functionality missing?

Is it insecure? Unsupported?

Who is paying you to do this work and what do they want out of it at the end?

It's a very, very lucky Developer who's given a big pot of money and told to recreate what the business already has in some new, whizzy technology.

Just because you think code doesn't "look right" doesn't mean it's not right.

  • Changed the adjective properly now. There is tons of missing functionality and a huge load of unwanted mess. Insecure, unsupported and unmaintainable as well. I am mostly doing this in my free time, since I cannot work with it commercially. But I think we switched a topic a little bit in here. The question is not WHY should I do that but WHAT technology should I go for. Aug 23, 2016 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.