Search code examples
phpstructuredirectory-structure

What distinguishes a model, library and helper class?


What is the difference between a model and a library class, and helper class?

How do I know when a class is a helper class and not a library?

I'm intersted in this information so I can properly organize and place my class files into the correct folders in my php MVC structure.


Solution

  • Based on summary of the Helper versus Library definition here difference between libraries and helpers in php frameworks, but adding in the Model aspect:

    Helper - often a set of related functions, rather than classes, that help with,make it easier to, work with some existing functionality/component, eg. arrays, strings, urls, etc. for example - http://laravel.com/docs/helpers

    Library - A larger collection of utility classes/methods that provide some sort of coherent functionality, eg. image manipulation, external api access, etc.

    Model - in general a model would represent some aspect of the domain that you are 'modelling' in your application. A model could represent a single entity within your domain, eg. if you are writing a project management tool you might have separate models for Organisation, Project, TeamMember, etc.