NODEFONY CONFIGURATIONS
Nodefony configurations Files :
Nodefony manage differents config files that you can find throughout your development.
Manage framework configuration
./config/config.js
Manage Application configuration in app bundle
./app/config/config.js
Manage bundle configuration
./src/bundles/my-bundle/Ressources/config/config.js
Framework Configuration : ./config/config.js
Application Configuration : ./app/config/config.js
Bundle Configuration : ./src/bundles/my-bundle/Resources/config/config.js
Routing Configuration : routing.js
Services Configuration : services.js
Firewall Configuration : security.js
Webpack Configuration :
webpack.config.js
webpack/webpack.dev.config.js
webpack/webpack.prod.config.js
webpack.config.js
webpack/webpack.dev.config.js
webpack/webpack.prod.config.js
Nodefony Watchers :
In developement mode The bundle generation engine build bundle config with node.js watcher configuration is very usefull to auto-reload files as controllers , views , routing , translations without having to reboot the server. Bundle manage WATCHERS in config.js
module.exports = {
/**
* WATCHERS
*
* watchers Listen to changes, deletion, renaming of files and directories
* of different components
*
* For watch all components
* watch: true
* or
* watch:{
* controller: true
* config: true // only routing.js
* views: true
* translations: true
* webpack: true
* }
*
*/
watch: true
}
Nodefony kernel Don't reload config.js services.js security.js files,You must restart nodefony !!!
How to use Configuration :
There are different ways to access these configuration variables- In controller By Kernel Service Container
this.getParameters("bundles.App")
class defaultController extends nodefony.Controller { constructor(container, context){ super(container, context); }; indexAction (version){ // GET config bundle App let bundleAppSettings = this.getParameters("bundles.App") ; // GET config bundle http let bundleHttpSettings = this.getParameters("bundles.http") ; return this.renderJson(bundleAppSettings); }; };
- In Kernel you can find
this.settings
with framework configurationindexAction (version){ // GET kernel service and get config let kernelGlobalSettings = this.kernel.settings ; return this.renderJson(kernelGlobalSettings); }
- In Bundle you can find
this.settings
with bundle configurationindexAction (version){ // GET kernel service , get demo bundle config let demoGlobalSettings = this.kernel.getBundle("demo").settings ; return this.renderJson(demoGlobalSettings); }
- Everywhere you can find config variables by Kernel Service Container
class myService extends nodefony.Service { constructor (kernel) super("myService", kernel.container, kernel.notificationsCenter ); }; myFunction (){ let kernelSettings = this.kernel.settings ; let appSettings = this.getParameters("bundles.App") ; }; };