coldfusioncoldfusionbuilder

Getting Started with ColdFusion?


I just downloaded ColdFusion Builder (CFB), and now I'm trying to write a simple "Hello World" app. But I need some sort of server first, don't I? Now what exactly am I looking for here? Is "ColdFusion" like a module that would run on top of Apache, or is it a server itself? What's this JRun I see in CFB? Context Root? RDS User Name? I'm trying to Google for tutorials, but all I'm finding are new languages features in CF9 which don't really help me, and stuff that relates to "MX" which is from 2003 I believe.

Databases. Does ColdFusion use it's own database schema, or does it interface with something like MySQL?

What about frameworks? I understand CFML offers HTML-style tags and such, but does it offer any sort of MVC framework for developing websites?

I understand LAMP and Python/Apache/WSGI to some degree, but I'm not quite grasping this CF yet. Can someone point me in the right direction?


Solution

  • Coldfusion is a script processing server written in Java. Coldfusion requires a Java Server (like JRun), a web server (like Apache), and prior to Coldfusion 9, a database server if you will be using a database. Thankfully the Development Edition comes with all of that built-in for you.

    For production, you'll need a separate web server such as IIS or Apache, as the built in web server is development-only. Most likely you'll need a separate database server such as MySQL or Microsoft SQL too. But unless you have a specific need, you can probably get along with the built in JRun Java server and not worry about that aspect of Coldfusion for now.

    If you've done any PHP, Coldfusion will be somewhat similar in the way it is setup on the server and how the code and HTML is integrated together in a script page. (YES, there are differences, but that's a good enough comparison as opposed to the .Net setup)

    Coldfusion has it's own built in database or you can choose from a wide variety of other databases. You should setup a connection to the database, called a 'datasource' in the Coldfusion Administrator and then it'll be really, really simple to use after that using the cfquery tag.

    If you are new to Coldfusion, I would skip all the third party frameworks until you have a good handle of how Coldfusion and your existing app works first. That all adds unnecessary complexity if you're new and the documentation for the frameworks is a little sparse.

    Look over the source code. Ask individual questions on here about what it means.

    The fastest way to find the docs for a particular Coldfusion function is to Google:

    'Coldfusion 8 cftagname' (e.g. 'Coldfusion 8 cfquery' or 'Coldfusion 8 cfqueryparam')

    or

    'Coldfusion 8 cffunctionname' (e.g. 'Coldfusion 8 structKeyExists')

    Click on the resulting livedocs.adobe.com link. (Google works WAY better than the site's internal search engine and Coldfusion 8 seems to be the best linked to Google)

    The cfdump tag is handy for simple debugging.

    Finally, here's an example of Hello World:

    index.cfm (standard Coldfusion pages use the .cfm extension)

    <!--- All coldfusion tags begin with <cf
         ...and Coldfusion comments have three dashes.
         These comments will be removed on the server side
         before being sent to the browser
    --->
    
    <!--- Set a greeting variable using standard cfset tag --->
    <cfset greeting = "Hello World!!">
    
    
    <!--- Begin HTML --->
    <html>
    <head>
    </head>
    <body>
    
          <!-- Normal HTML comment -->
          <p>I could just say hello world with HTML</p>
    
          <!--- In order to output Coldfusion within HTML,
                wrap with the cfoutput tag. Variables in HTML are wrapped with hash marks:
                Example: #varName#
          --->
          <cfoutput>
                <p>More HTML, blah, blah, blah...</p>
    
                <!--- Outputs: Hello World! --->
                <p>#greeting#</p>
    
                <!--- Or apply a Coldfusion function to the variable.
                      Wrap the variable name with a function name and
                      then wrap the function with hash marks to tell
                      the Coldfusion server to process the statement
                --->
    
                <!--- Outputs: HELLO WORLD! --->
                <p>#ucase(greeting)#</p>
    
          </cfoutput>
    
         <!--- And another way to view the contents of a variable as a developer --->
         <cfdump var="#greeting#>
    
    
    <body>
    </html>
    

    Hope that helps.