Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CF: Application.cfc Example With DI/1 #snippet
component { = hash( getCurrentTemplatePath() );
// Do not use datasource attribute in cfquery
this.datasource = "myDSN";
this.sessionManagement = true;
* /model/beans/ contains transient CFC's
* All others are singleton CFC's
* All singletons have their folder singular name appended to the file name. (Example: userService)
* Use "application.BF.getBean('userService')" as an example to get a bean
* Set properties with accessors in the CFC with the names of the CFC to be injected
boolean function onApplicationStart() {
// Use only on cfstoredproc datasource attribute
application.DSN = this.datasource;
// DI/1 Bean Factory
application.BF = new model.ioc( "/model" );
return true;
boolean function onRequestStart( required string targetPage ) {
if( structKeyExists( URL, 'init' ) and URL.init == 'true' ) {
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.