How to develop a laminas module and use it at the same time? Thanks!
There’s this repository you could use for your own module.
Then, add a composer dependency to your projects pointing to the module.
Whether it’s local (through file://) or through packagist is up to you. I would go for a local dependency for development. Once the module is stable, publish it and change the local composer dependency to a proper one going through packagist
You probably want to change the namespace of the module, though:
instead of laminas/laminas-thing name it altamash/laminas-thing or something similar.
I don’t know how, uh, “zealous” the laminas/ maintainers “protect” their namespace lol
Thanks for your answer @makxk. Have you downloaded the mentioned module yourself and tested it? It has no release version on GitHub. Also, by module I meant MVC-Module.
Is this what you are looking for?
Thanks, @makxk for letting me know how to create a module. I’ll rephrase my question here and will edit the question as well. I wanted to ask how to create a public distributable module and use it at the same time. For example, LmcUser is a module for Laminas-MVC. To develop it inside a Laminas MVC skeleton app where the skeleton is also in a git repository. How will you maintain such a public module?
Here’s an example module (+MVC) that’s meant for Laminas, which I develop and also use (your use case). GitHub - Saeven/zf3-circlical-user: Turnkey Authentication, Identity, and RBAC for Laminas and Zend Framework 3. Supports Doctrine and Middleware.
The steps are pretty simple:
- Develop your module. Write tests, start from there.
- (Understated, but you must commit/push to a Github repo)
- When you’re done, have good tests to show how the system works, etc. submit your package to Packagist (https://packagist.org) - you can read more about this on packagist itself (can dig deep here, setting up auto-publish hooks to update and so forth)
Take a sec to read up on semver as you travel this road.
Then switching to the app that wants to ‘use’ what you have developed, you’ll add the package name (established at step 3, above) into your composer.json and essentially pull the package you built.
Good luck!
Thanks, @Saeven for taking the time and answering my question. I have got a public module myself here. But this is not what I meant. I want to maintain multiple repositories under one directory. Meaning I’ve something like the below structure of the composer.json file.
{
"require": {
"php": "^7.3",
"laminas/laminas-component-installer": "^1.0 || ^2.1",
"laminas/laminas-development-mode": "^3.2",
"laminas/laminas-mvc": "^3.1.1"
...
},
"autoload": {
"psr-4": {
"Application\\": "module/Application/src/",
"FirstModule\\": "devmodules/FirstModule/src/"
"SecondModule\\": "devmodules/SecondModule/src/"
}
}
}
Now, the problem with the composer is that it has to load modules from devmodules directory which is not in git. Once I’ve tested the module I’ll add it through composer require command. So, can you tell me how to add my module under this directory structure and maintain it? Thanks!