Have you ever copy-pasted custom code, from one admin panel to another? It didn't feel right, did it? You knew there's a better way to...
Have you ever copy-pasted custom code, from one admin panel to another? It didn't feel right, did it? You knew there's a better way to do that. And you knew exactly what you should have done - create a Composer package that encapsulates that bit of logic, then re-use the package in both projects. That way, when you improve it in one project, it'll get improved in the other one too. It's code-reuse 101. After all... if it's general enough to be used in multiple projects, it's general enough to have its own package. So why didn't you?
Was it because you've never created a Composer package, and it felt scary? If that's why - I have great news for you. We've just finished writing a tutorial that assumes zero knowledge about creating Composer packages. It not only explains every bit that matters, but the way we teach you to do it also automates the stuff package creators dread doing. There's quite a bit of innovation there in terms of Developer Experience - and I think you'll like it and learn some small things that will make you a better developer. So if you reuse some logic across admin panels, and you want to create a package for it, but have never done so - just follow one tutorial, the very last link in our docs, "How to Create an Add-on". Make sure you reserve about 60 minutes for it - 30 min to actually create the package, then 30 min to write its docs, put up a screenshot, test it... etc.
Or... was it because you've done this before, and you know creating a new Composer package takes too much time? If that's the case - I have great news for you too. The exact same tutorial will do wonders to you too, reducing the time and stress of creating a package... by a lot! Just speed-read it and you'll see that:
AddonServiceProviderthat works like magic; remember all the wiring you normally need to do inside the ServiceProvider, to register views/langs/configs/commands etc? where one character can ruin everything and take hours to debug? well... you no longer have to do any of that; if you dropped your files into the right folders, then
AddonServiceProviderwill register them for you, automatically; you'll absolutely love it!
To wrap it up, we're pretty proud of how much easier we've made creating a package that contains admin panel logic. If you've ever been to scared (or too lazy) to do it - I heavily recommend giving it a go. Just read the very last section in our docs, called "How to Create an Add-on".
And yes, you can use this same tutorial for closed-source packages too, you don't have to share them with the world if you can't or don't want to. We tell you how to do that too.
No matter what you've built, let us know about it - we're eager to see it. And feel free to submit a PR to the docs if you find ways to improve the tutorial. We've run through it 10+ times and it works like a charm, but there's nothing quite like a fresh perspective.
PS. You'll also notice we've added comments to our blog articles. Feel free to use that too :-)
What do you think about this?
Wondering what our community has been up to?