This topic may seem like (very) old news to many readers, but there are still folks (perhaps thousands) who for one reason or another have some CFML app where they have still not made the shift from using application.cfm to application.cfc for defining their CF application framework. (The former has been around since the dawn of CF time in the mid-90’s, while the latter was introduced with CF7 from 2005).
It may just be a matter of an app that’s not received attention for years. Indeed, someone asked me about this topic just yesterday, and I decided to create this post for their benefit and for others in that boat.
And there are certainly benefits to using application.cfc, in terms of the various methods (onapplicationstart, onsessionstart, onrequeststart, etc.), and while this post is not about those I do point to some resources to help you there also, if needed.
But when you’re converting an old procedural application.cfm to the more “modern” application.cfc approach, you may struggle a bit to figure which parts go best into the various newly available methods. So I share here resources with more on that, and some comment on them, to help get you going.I realize some may wish I was going to point them to tool to “just do the job” for them. Sadly, it’s not that simple. Nor always is the matter of making the conversion (or else people wouldn’t be needing help).
Resources on converting from application.cfm to application.cfc
Fortunately, over the years there have been various resources that addressed the topic. Some are more elaborate than others, and some more modern, but basically the concepts and steps have not changed. Here are a few to get you started:
- https://helpx.adobe.com/coldfusion/developing-applications/developing-cfml-applications/designing-and-optimizing-a-coldfusion-application/migrating-from-application-cfm-to-application-cfc.html
- this is a well-meaning but terse list of 7 bullet points, from a page in the current CF docs on the topic. For some, it may well be all they need.
- https://forum.hostek.com/showthread.php?724-Converting-to-Application-cfc
- while the url may lead you to think it’s a forum thread, it reads like a blog post. And while the formatting of the page may lead you to think you’ve found a dead end, just scroll down a page or two to see the content, which goes into a bit more detail than the above (from 2012)
- http://www.coldfusioncookbook.com/entries/How-do-I-migrate-from-Applicationcfm-to-Applicationcfc.html
- this is a rather brief blog-post-like discussion of the topic, from Ray Camden (in 2006)
Resources on why you should use application.cfc
And for those wondering, “why WOULD I want to convert to using application.cfc”, the following resources address that:
- https://helpx.adobe.com/coldfusion/developing-applications/developing-cfml-applications/designing-and-optimizing-a-coldfusion-application/defining-the-application-and-its-event-handlers-in-application-c.html
- This is the Adobe docs chapter on using application.cfc. This and the next items really don’t talk about “conversion” of the old to the new way, but help you understand how the new way works and why you may want to use it
- http://www.learncfinaweek.com/course/index/section/Application_cfc/item/Application_cfc/
- This is the chapter on application.cfc from the great, “Learn CF In A Week” resource
- https://www.bennadel.com/blog/726-coldfusion-application-cfc-tutorial-and-application-cfc-reference.htm
- Ben Nadel did his usual compendious discussion of the topic, with examples (of course). Though from 2007, again it’s still as relevant today.
Granted, there have been some changes to application.cfc over the year. CF8 added the onmissingmethod method, for example. And what one can define WITHIN application.cfc has evolved (more properties in the this scope, some of which can’t or are more challenging to set in application.cfm), but again most of those resources above are just as valuable now as when written.
Finally, FWIW, there’s even a post from Ray Camden in reply to someone who asked instead how to convert FROM application.cfc back to application.cfm. What Ray shares is useful even for the current topic.
Hope something above may be helpful for some readers.
The post On converting from application.cfm to application.cfc appeared first on ColdFusion.