I was debugging something the other day with a friend of mine, and I made a request for a CFC directly from my browser. My friend had never seen that before, so I thought I’d blog the technique in case others might have missed it, as well.
If your CFCs are located in your web root, you can reference them directly from your browser like this:
A request like this will redirect you to a component called cfcexplorer.cfc (you will be required to authenticate while being redirected) which will auto-generate documentation for your component similar to Javadoc. It’s a great way to browse your API.
Another technique you can use is to actually invoke a function from your browser, like this:
A request like this will not redirect you to the cfcexplorer, but will actually invoke the method specified as the value of the “method” parameter (note that the method’s access must be specified as remote). This is a great way to test your CFCs, or even to write entire applications (though latter would be an unusual architecture). If output is enabled in both your component and your function, you can output HTML from your components.
I should add that outputting HTML from your components is an unusual practice, and typically presentation logic is contained in CFM and HTML files rather than CFCs, but occasionally it’s worth doing. I should also note that a new instance of the CFC gets created on every request, so although that happens very quickly and efficiently, it is something to take into consideration while designing your overall architecture.