Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TheDigitalOrchard's avatar

Content Management System using Laravel 5 - looking for advice

I have been struggling to get Laravel's approach to code organization clear in my mind. I'm developing a CMS which will support templates and plug-in modules.

  1. Each template will be packaged up as a library so they can be installed via composer (from a private Git repo). I have this part clear in my mind.

  2. The CMS will also support "modules", essentially plug-n-play functionality to be added to the system and the exact modules will vary from site to site. Each module will be a Laravel package installable via composer.

What I'm not clear on is exactly how to model and namespace the different components. Since I want the CMS to enforce some consistency across all templates and all modules, I was thinking of having a Contract for each.

/vendor/package/src/CMSServiceProvider.php
/vendor/package/src/Contracts/Module.php
/vendor/package/src/Contracts/Template.php

Templates will only have public assets, no controller or other code. Modules, however, will have the full MVC complements.

Where my head begins to hurt is that each module, for example, is a full L5 package, so how do I incorporate the Module contract so that the module itself is governed by it? Do I "implement" the contract as part of the ServiceProvider class? Do I have a "ModuleServiceProvider" interface instead of just "Module" so that it's self-documenting? I don't like to mix terminologies and conventions. If something is related to ServiceProvider, then it makes sense to follow the Laravel naming convention.

Your feedback is very much appreciated here.

0 likes
3 replies
TheDigitalOrchard's avatar

I appreciate your suggestion @alenn. I did review that Modules package previously. I'm not looking for site-wide modules, but rather modules within the scope of my CMS. See the difference? I might back-peddle on that stance, but for now I'd just like to get Laravel conventions clear in my mind. Between namespaces, custom names for things that already have a name (Contracts for interfaces), and composer, it's been a whole new world for me in building a PHP application. My own framework is so much easier compared to this, but also far less "modern" and complex.

martinbean's avatar

@TheDigitalOrchard Have a package that contains the interfaces etc. needed for modules, called something like [vendor]/module-base. Then, in each module package, import this “base” package and you will have your interfaces and whatnot available.

1 like

Please or to participate in this conversation.