laminas-api-tools / api-tools-admin

Laminas API Tools Admin module
https://api-tools.getlaminas.org/documentation
BSD 3-Clause "New" or "Revised" License
13 stars 21 forks source link

Error manage module.config.php with closures #41

Open michalbundyra opened 4 years ago

michalbundyra commented 4 years ago

Hi guys, today I put a closure in my module.config.php to write a factory and apigility put a wrong code in my module.config.php break the entire application.

The factory:

 'service_manager' => array(
    'factories' => array(
            'testClosure' => function(){},

The factory after some save operation on apigility ui:

 'service_manager' => array(
    'factories' => array(
            'testClosure' => Closure::__set_state(array(
))

Originally posted by @edipoReboucas at https://github.com/zfcampus/zf-apigility-admin/issues/236

michalbundyra commented 4 years ago

Hi @edipoReboucas,

I do not know if you already solved this issue but in order to help others I would like to answer it.

It sounds like a cache issue. Apigility has enabled the option 'config_cache_enabled'. But this option does not work when you have closure in your config because it is not possible to cache closure.

The solutions seems to create a factory class instead of a closure. You should not disable the config in order to fit your need because it is not a good way to work on zf2.

Regards


Originally posted by @dlevel at https://github.com/zfcampus/zf-apigility-admin/issues/236#issuecomment-203319254

michalbundyra commented 4 years ago

To use closures with cache on, probably I put closures via Module at the time.


Originally posted by @edipoReboucas at https://github.com/zfcampus/zf-apigility-admin/issues/236#issuecomment-205598103