Hello and welcome to our forums!
If I follow your code examples, you donāt need laminas-di.
Sure, use the reflection-based factory of laminas-servicemanager which is already present in a laminas-mvc application. For your controller example this means:
return [
'factories' => [
Controller\AdvertController::class => \Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory::class,
],
];
The second example contains some more preparation therefore a separate factory class is recommended here. Then the configuration can also be cached.
You can find more examples of the usage of the reflection-based factory in the tutorials:
Then Mezzio is the right candidate, because it has a low entry and can handle the migration from ZF1. See: