I have custom MVC framework in PHP and my controller file has about 5000 lines.

The question is, is it a big concept flaw?

It is structured code with kiss method and quite maintainable.

Are there any rules that specify how large the controller should be?

And offcourse could it have some bad influence on web performance?

1 Answer 1


While there are no hard rules about the size of a controller, 5000 lines is clearly beyond any reasonable size for a hand-coded class. Chances are this class is violating the Single Responsibility Principle (SRP) and therefore is flawed. You most likely have several methods in there that can logically be grouped together. See if you can't extract methods off into separate controllers: you are very likely to end up with a larger number of controllers with fewer lines of code per controller and well-defined responsibilities. Or package up code into separate classes that your controller can call into.

I can't see where performance would be a problem, and I doubt performance of your code would be anything but the last reason you would want to split up a 5000 line class...

  • you're right i try to split the file into smaller controllers grouped by same functions.
    – JTC
    Commented Jul 31, 2015 at 10: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.