Skip to main content
Inspiring
November 16, 2011
Question

application.cfc vs application.cfm

  • November 16, 2011
  • 2 replies
  • 7458 views

My CF version is 8 but since I came to this company and inherrited the codes, it looks like previous programmer did not use much of CF8 features.

I started to take advantage of CF8 features including cfc. One thing that I notice is all the existing apps. are using application.cfm and none uses application.cfc

I have sort of a portal web application where under this app. there are a bunch of different applications

The portal application has application.cfm that is encrypted so whenever I create a new app, I created my own application.cfm each with a different name set on the cfapplication tag

So it sort of to look like this:

Portal app

  application.cfm (encrypted)

     application_1

       application.cfm

     application_2

      application.cfm

  

     application_3

       application.cfm

I want to experience the CF8 application.cfc and from what I read, if I use application.cfc I can't use application.cfm because application.cfc replacing application.cfm and OnrequestEnd.cfm

when application.cfc is present both application.cfm and OnrequestEnd.cfm are going to be ignored.

My concern is, when I start creating application.cfc on my sub application, will the application.cfc ignoring Portal's application.cfm (the encrypted application.cfm) eventhough it is

on a much higher up in the directory tree?

So can i do the following without messing up the whole application?

Portal app

  application.cfm (encrypted)

     application_1

       application.cfm

     application_2

      application.cfm

  

     application_3

       application.cfm

     application_4

       application.cfc  <<< (?)

This topic has been closed for replies.

2 replies

Inspiring
November 17, 2011

when I start creating application.cfc on my sub application, will the application.cfc ignoring Portal's application.cfm (the encrypted application.cfm) eventhough it is on a much higher up in the directory tree?

Yes. In that respect, it is no different than an Application.cfm file. CF starts searching within the directory of the requested script for the first Application.cfc it finds (or if none exists, Application.cfm). As soon as it finds one, CF processes it and stops searching. So it is not even aware of any application files higher up in the directory tree.  

You can find more details about how CF processes application.cfc/cfm files in  the documentation.  The example at the bottom of the page describes an application structure very similar to yours.

mega_LAuthor
Inspiring
November 17, 2011

Would it matter if I created application.CFC on my subfolder application and then include the application.CFM from the main app. using cfinclude (see below)

The reason I'm asking is, I'm pretty sure some variables are set in the Main's application.cfm and also some java codes are written in there. All of them are encrypted. I'm afraid in order for my new app to work properly I may need the main application.cfm. So it'll be prefect if I can include the Application.cfm from the main app in my new application.cfc

I can't test it in my local machine. When I tried it I got a bunch of java errors.

This is my application.cfc:

<cfinclude template="/Application.cfm">

Inspiring
November 18, 2011

Yes, that would make a difference.  I have never cfincluded an application.cfm file from another appplication file. So I am really not sure what the results would be.  I imagine there is no technical reason you could not do that inside one of the Application.cfc methods, but without knowing what the main file does it would be tough to know where to include it or even what the results would be.  What variables/scopes does it affect? Also, what do the sub folder's application files do other than including the one from the parent directory?

Inspiring
November 16, 2011

What happened when you tried it?