{"id":19484127,"url":"https://github.com/htr3n/learn-lucee","last_synced_at":"2026-03-19T10:05:40.093Z","repository":{"id":94417952,"uuid":"199268389","full_name":"htr3n/learn-lucee","owner":"htr3n","description":"Learn mysefl some ColdFusion / Lucee / CFWheels / CommandBox","archived":false,"fork":false,"pushed_at":"2019-07-28T12:11:35.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T17:48:03.785Z","etag":null,"topics":["cfml","coldfusion","commandbox","lucee"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/htr3n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-28T09:38:55.000Z","updated_at":"2024-12-26T23:17:02.000Z","dependencies_parsed_at":"2023-04-23T05:34:52.281Z","dependency_job_id":null,"html_url":"https://github.com/htr3n/learn-lucee","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/htr3n/learn-lucee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htr3n%2Flearn-lucee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htr3n%2Flearn-lucee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htr3n%2Flearn-lucee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htr3n%2Flearn-lucee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htr3n","download_url":"https://codeload.github.com/htr3n/learn-lucee/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htr3n%2Flearn-lucee/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30078306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T08:01:56.766Z","status":"ssl_error","status_checked_at":"2026-03-04T08:00:42.919Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cfml","coldfusion","commandbox","lucee"],"created_at":"2024-11-10T20:19:30.451Z","updated_at":"2026-03-04T10:01:31.468Z","avatar_url":"https://github.com/htr3n.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Self-learning Cold Fusion / Lucee\n\n* [Adobe ColdFusion](https://en.wikipedia.org/wiki/Adobe_ColdFusion): web-application development platform, created in 1995 by J. J. Allaire\n* [Lucee](https://lucee.org) is an open-source [CFML](https://en.wikipedia.org/wiki/ColdFusion_Markup_Language) application server/engine\n\n## CF Applications\n\n* http://www.learncfinaweek.com/week1/Application_cfc\n* https://helpx.adobe.com/coldfusion/developing-applications/user-guide.html\n* https://modern-cfml.ortusbooks.com/rapid-app-development/applicationcfc\n\nColdFusion application is nothing more but a memory space reservation using the `this.name` property as the unique name for it.  It can contain the variables scopes like `application`, `session`, and `client` which are unique per this reservation name. This way two ColdFusion applications can have different persistence variable scopes and can even be embedded between each other:\n\n```\nwebroot\n├── Application.cfc   \t// root public app\n└── admin/\n    └── Application.cfc\t// embedded admin app\n```\n\n### Lucee `Application.cfc`\n\n* https://docs.lucee.org/guides/cookbooks/application-context-basic.html\n* https://rorylaitila.gitbooks.io/lucee/content/applications.html\n\nThe `Application.cfc` is a component you put in your web application that then is picked up by Lucee as part of the request. The `Application.cfc` is used to define context specific configurations/settings and event driven functions. Your website can have multiple `Application.cfc` files, every single file then defines an independent application context.\n\n* With the default setting Lucee always picks the \"nearest\" Application.cfc, so it searches from the current location down to the webroot.\n* The Application.cfc supports [multiple event driven functions](https://docs.lucee.org/guides/cookbooks/application-context-basic.html)\n    * [`onApplicationStart()`](https://cfdocs.org/onapplicationstart)\n    * [`onApplicationEnd()`](https://cfdocs.org/onapplicationend)\n    * [`onSessionStart()`](https://cfdocs.org/onsessionstart)\n    * [`onSessionEnd()`](https://cfdocs.org/onsessionend)\n    * [`onRequestStart()`](https://cfdocs.org/onrequeststart)\n    * [`onRequestEnd()`](https://cfdocs.org/onrequestend)\n    * [`onRequest()`](https://cfdocs.org/onrequest) -- If this function exists, Lucee only executes this function and no longer looks for the \"targetPage\" defined with the request. So let's say you have the call \"/index.cfm\", if there is an \"/index.cfm\" in the file system or not, does not matter, it is not executed anyway.\n    * [`onError()`](https://cfdocs.org/onerror)\n\n### Elements of a ColdFusion application\n\n#### Reusable application elements:\n\n* User-defined functions (UDFs)\n* CFML custom tags\n* ColdFusion components (CFCs)\n* CFX (ColdFusion Extension) tags\n* Pages that you include using the [`cfinclude`](https://cfdocs.org/cfinclude) tag\n\n#### Shared variables\n\n| Variable scope | Variables available                                    |\n| -------------- | ------------------------------------------------------ |\n| Server         | To all applications on a server and all clients        |\n| Application    | To all pages in an application for all clients         |\n| Client         | For a single client browser over multiple browser sessions in one application |\n| Session        | For a single client browser for a single browser session in one application |\n\n#### Application events and the [`Application.cfc`](https://cfdocs.org/application-cfc) file\n\n| Event             | Trigger                                             |\n| ----------------- | --------------------------------------------------- |\n| Application start | ColdFusion starts processing the first request for a page in an application that is not running. |\n| Application end   | An application time-out setting is reached or the server shuts down. |\n| Session start     | A new session is created as a result of a request that is not in an existing session. |\n| Session end       | A session time-out setting is reached.              |\n| Request start     | ColdFusion receives a request, including HTTP requests, messages to the event gateway, SOAP requests, or Flash Remoting requests. |\n| Request           | Immediately after ColdFusion finishes processing the request start event. The handler for this event is intended for use as a filter for the request contents. |\n| Request end       | ColdFusion finishes processing all pages and CFCs for the request. |\n| Exceptions        | An exception occurs that is not handled in a try/catch block. |\n\n#### Other application-level settings and functions\n\nIf you do not have an `Application.cfc` file, CF processes the following two pages, if they are available, every time it processes any page in the application:\n\n- The `Application.cfm` page is processed before each page in the application.\n- The `OnRequestEnd.cfm` page is processed after each page in the application.\n\n## CF Markup and Scripting Languages\n\n- ColdFusion (CFML) is an interpreted and dynamic ECMA Script like language that compiles to Java Bytecode directly, thus running in the Java Virtual Machine (JVM) and in almost every operating system.\n\n- ColdFusion is **case insensitive**\n\n- ColdFusion includes pages (`.cfm`) or components / classes (`.cfc`)\n\n- There are two ways to write ColdFusion:\n\n    - Using **tags**\n    - Using **script** syntax with [CFScript](https://cfdocs.org/script)\n\n- Modern CFML advises that view or presentation layers will use the **tag** syntax in `cfm` files whilst the model or business layers will be in **script** syntax in `cfc` files\n\n    - `cfm` - ColdFusion markup file, tag syntax is the default\n\n        `cfc` - ColdFusion Component file (Class or Object), script syntax is the default. \n\n### Comments\n\n- CFML: similar to HTML comments but with three dash `\u003c!--- a comment ---\u003e`\n- CFScript: similar to Java, JavaScript `//` for single line, `/* .. */` for a block\n\n### Variables\n\n*Variables* are the most frequently used operands in ColdFusion expressions. Variable values can be set and reset, and can be passed as attributes to CFML tags. Variables can be passed as parameters to functions, and can replace most constants. \n\n#### [cfset](https://cfdocs.org/cfset)\n\n```cfml\n\u003ccfset str = \"Hello\"\u003e\n\u003ccfset temp = 5\u003e\n```\n\n#### [cfoutput](https://cfdocs.org/cfoutput)\n\n* To convert the variable name into its value is to place pound signs around the variable name. The variable name and pound signs must be placed inside of a cfoutput tag.\n\n```cfml\n\u003ccfoutput\u003e#str# CF World!\u003c/cfoutput\u003e\n```\n\n* Can also perform calculations within the pound signs\n\n```cfml\n\u003ccfoutput\u003e#3 + 5#\u003c/cfoutput\u003e\n```\n\n#### [cfdump](https://cfdocs.org/cfdump)\n\nOutputs the contents of a variable of any type for debugging purposes. The variable can be as simple as a string or as complex as a cfc component instance.\n\nCFML\n\n```cfml\n\u003ccfdump var=\"#server#\" label=\"Server Scope\"\u003e\n```\n\nCFScript\n\n```cfc\nwriteDump(var = server, label = \"Server Scope\");\n```\n\n##### Lucee [dump()](https://docs.lucee.org/reference/functions/dump.html)\n\n```\ndump(var = server, label = \"Server Scope\");\n```\n\n#### [writeDump](https://cfdocs.org/writedump)\n\nOutputs the elements, variables and values of most kinds of CFML objects. Useful for debugging. You can display the contents of simple and complex variables, objects, components, user-defined functions, and other elements. Equivalent to the [cfdump](https://cfdocs.org/cfdump) tag, useful in [cfscript](https://cfdocs.org/cfscript).\n\n```cfc\nwriteDump(server);\n```\n\n#### [evaluate()](https://cfdocs.org/evaluate)\n\n* The `evaluate()` function shall evaluate a string expression at runtime\n\n```cfml\n\u003c!--- Evaluate the expression ---\u003e \n \u003ccfset first = \"ColdFusion\"\u003e \n \u003ccfset second = \"ColdFusion\"\u003e \n \u003ccfset op = \"eq\"\u003e \n \u003ccfoutput\u003e#evaluate(\"first #op# second\")#\u003c/cfoutput\u003e \n```\n\n* Since CF 6.1, highly recommend to use bracket notation instead\n\n```cfml\n\u003ccfset queryname[columnname][rownumber] /\u003e\n\u003ccfset x = \"foo\" /\u003e\n\u003ccfoutput\u003e#variables['x']#\u003c/cfoutput\u003e\n```\n\n#### Variable Lookup\n\n- Local (function-local, UDFs and CFCs only)\n- Arguments\n- Thread local (inside threads only)\n- Query (not a true scope; variables in query loops)\n- Thread\n- Variables\n- CGI\n- Cffile\n- URL\n- Form\n- Cookie\n- Client\n\n#### Session Variables\n\n* A session variable is used to allow variables to live beyond the life of the page in which they are created in but will die when the users session dies.\n\n* On every page of your application where you are going to use the session variable you need to include:\n\n```cfml\n\u003ccfapplication sessionmanagement=\"true\"\u003e\n```\n\n* This code should normally be placed in your `Application.cfm` file.\n\n* To set a session variable:\n\n```cfml\n\u003ccfset session.name = \"UserSessionVariable\"\u003e\n```\n\n* To get value on a different page called after that\n\n```cfml\n\u003ccfoutput\u003e#session.name#\u003c/cfoutput\u003e\n```\n\n### Data Types\n\n#### List\n\n* https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-by-category/list-functions.html\n* https://cfdocs.org/list-functions\n* https://docs.lucee.org/categories/list.html\n\nLucee has lists which are strings with a delimiter (default is a comma). Lists can only contain strings (and they are a string themselves), so use an Array to contain complex data types. Lists are not real objects in Lucee, and are simply strings that contain a delimiter. As such, any string can be a list that has a delimiter other than a zero length string.\n\nList functions are prefixed with `list` in their names to differentiate from string functions. \n\n##### Creating Lists\n\n```cfml\n\u003ccfset newlist = \"IL,MO,IA,MN\"\u003e\n\u003ccfoutput\u003e#newlist#\u003c/cfoutput\u003e\n```\n\n##### List Modification\n\n* [`listAppend()`](https://cfdocs.org/listappend)\n* [`listGetAt()`](https://cfdocs.org/listgetat)\n* [`listInsertAt()`](https://cfdocs.org/listinsertat)\n* [`listDeleteAt()`](https://cfdocs.org/listdeleteat)\n* [`listSort()`](https://cfdocs.org/listsort)\n* [`listLen()`](https://cfdocs.org/listlen)\n* [`listToArray()`](https://cfdocs.org/listtoarray)\n\n##### Looping\n\n```cfml\n\u003ccfscript\u003e\nmyList = \"one,two,three\";\nfor(val in myList){\n\techo(val \u0026 \"\u003cbr /\u003e\");\n}\n\u003c/cfscript\u003e\n\n\u003ccfset myList = 'Jeff,John,Steve,Julliane' /\u003e\n\u003ccfloop list=\"#myList#\" index=\"item\"\u003e\n\t#item#\u003cbr /\u003e\n\u003c/cfloop\u003e\n\u003ccfloop from=\"1\" to=\"#listlen(myList)#\" index=\"i\"\u003e\n\t#i#: #listGetAt(myList, i)#\u003cbr /\u003e\n\u003c/cfloop\u003e\n```\n\n#### Arrays\n\nLucee/CF array indexes **start at 1** and are **passed by reference**. If the elements in the array are Boolean, Numeric or Strings (simple values) they are passed by value. All other complex types are passed by reference.\n\n* https://cfdocs.org/array-functions\n* https://rorylaitila.gitbooks.io/lucee/content/arrays.html\n* https://docs.lucee.org/categories/array.html\n* https://helpx.adobe.com/au/coldfusion/developing-applications/the-cfml-programming-language/using-arrays-and-structures/basic-array-techniques.html\n\n##### Creating Arrays\n\n```cfml\n\u003ccfscript\u003e\n\tthreeElements = [\"one\",\"two\",\"three\"];\n\temptyArray = [];\n\u003c/cfscript\u003e\n```\n\n##### Appending Elements\n\n```cfml\n\u003ccfscript\u003e\n\texampleArray = [];\n\texampleArray.append(\"one\");\n\texampleArray.append(\"two\");\n\texampleArray.append(\"three\");\n\u003c/cfscript\u003e\n```\n\n##### Referencing (1-indexing)\n\n```cfml\n\u003ccfscript\u003e\n\tthreeElements = [\"one\",\"two\",\"three\"];\n\techo(threeElements[1]);\n\techo(threeElements[3]);\n\tindex = \"1\";\n\techo (threeElements[index]);\t// \"one\"\n\techo (threeElements[\"#index#\"]); // \"\"one\n\u003c/cfscript\u003e\n```\n\n##### Dumping\n\n```cfml\n\u003ccfscript\u003e\n\tthreeElements = [\"one\",\"two\",\"three\"];\n\tdump(threeElements);\n\u003c/cfscript\u003e\n```\n\n##### Others\n\n* [arrayLen(array)](https://cfdocs.org/arraylen)\n* [len(Object)](https://cfdocs.org/len)  \n\n##### Array Loop\n\nCFScript\n\n```cfc\nmyArray = [\"a\", \"b\", \"c\"];\n\n// For Loop By index for CF \u003c= 9.0\nfor (i = 1; i \u003c= arrayLen(myArray); i++) {\n    writeOutput(myArray[i]);\n}\n\n// For In CF9.0.1+ \nfor (currentIndex in myArray) {\n    writeOutput(currentIndex);\n}\n\n// arrayEach() member function CF11+\nmyArray.each(function(element, index) {\n    writeOutput(element \u0026 \" : \" \u0026 index);\n});\n```\n\nCFML\n\n```cfml\n\u003ccfset myArray = [\"a\", \"b\", \"c\"]\u003e \n\n\u003c!--- By index ---\u003e \n\u003ccfloop index=\"i\" from=\"1\" to=\"#arrayLen(myArray)#\"\u003e \n\t\u003ccfoutput\u003e#myArray[i]#\u003c/cfoutput\u003e \n\u003c/cfloop\u003e \n\n\u003c!--- By array ---\u003e \n\u003ccfloop array=\"#myArray#\" index=\"currentIndex\"\u003e \n\t\u003ccfoutput\u003e#currentIndex#\u003c/cfoutput\u003e \n\u003c/cfloop\u003e\n```\n\n#### Structs\n\nStructs in Lucee are containers for data where there is a 'key' that references a 'value'. \n\n* https://docs.lucee.org/categories/struct.html\n* https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-arrays-and-structures/about-structures.html\n\n##### Creating Structs\n\n```cfml\n\u003ccfscript\u003e\n\temptyStruct = {};\n\tnonEmptyStruct = {foo:\"one\", bar:\"two\", baz:\"three\"};\n\u003c/cfscript\u003e\n```\n\n##### Nested Structs\n\n```cfml\n\u003ccfscript\u003e\nnestedStruct = {foo:\"one\", \n            \tbar:\"two\", \n            \tbaz:{\n              \t\tkey:\"value\"\n            \t}\n};\n\u003c/cfscript\u003e\n```\n\n##### Creating Ordered Structs\n\n* Using [structNew()](https://cfdocs.org/structnew) with \"ordered\"\n\n```cfml\n\u003ccfscript\u003e\nmyStruct = structNew(\"ordered\");\nmyStruct.insert(\"foo\",\"one\");\nmyStruct.insert(\"bar\",\"two\");\nmyStruct.insert(\"baz\",\"three\");\n\u003c/cfscript\u003e\n```\n\n##### Inserting Items\n\n```cfml\n\n\u003ccfscript\u003e\nmyStruct = {foo:\"one\", bar:\"two\", baz:\"three\"};\nmyStruct.insert(\"key\", \"value\");\n\u003c/cfscript\u003e\n```\n\n##### Referencing Struct Keys\n\n* Object.property\n\n```cfml\n\u003ccfscript\u003e\nmyStruct = {foo:\"one\", bar:\"two\", baz:\"three\"};\necho(myStruct.foo);\n\u003c/cfscript\u003e\n```\n\n* Dynamic referencing -- associative arrays (structs as arrays with string indexes)\n\n```cfml\n\u003ccfscript\u003e\nmyStruct = {foo:\"one\", bar:\"two\", baz:\"three\"};\nmyKey = \"foo\";\necho(myStruct[myKey]); //outputs \"one\"\n\u003c/cfscript\u003e\n```\n\n##### Looping Structs\n\n```cfml\n\u003ccfscript\u003e\nmyStruct = {foo:\"one\", bar:\"two\", baz:\"three\"};\nfor(key in myStruct){\n  echo(key); //outputs \"foo\" then \"bar\" then \"baz\";\n  echo(myStruct[key]); //outputs \"one\", then \"two\", then \"three\"\n}\n\n// By structEach() \nmyStruct.each(function(key, value) { \n\twriteOutput(\"\u003cli\u003e#key# : #value#\u003c/li\u003e\"); \n}); \n\u003c/cfscript\u003e\n```\n\n#### Queries\n\n* https://docs.lucee.org/categories/query.html\n* https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-p-q/cfquery.html\n\n##### Creating Queries\n\n* [queryNew()](https://cfdocs.org/querynew) -- Creates a new query object. The query can be populated with data using functions [queryAddRow](https://cfdocs.org/queryaddrow), [querySetCell](https://cfdocs.org/querysetcell), or by passing it in to the rowData argument.\n\n```cfml\n\u003ccfscript\u003e\nmyQuery = queryNew(columns=\"col1,col2,col3\", \n\t\t\t\t   data=[\n\t\t\t\t   \t\t[\"one\",\"two\",\"three\"], \n\t\t\t\t   \t\t[\"foo\",\"bar\",\"baz\"], \n\t\t\t\t   \t\t[\"i\",\"am\",\"query\"]\n\t\t\t\t   ]);\ndump(myQuery);\n// query without data\nmyQuery = queryNew(\"col1,col2,col3\");\ndump(myQuery);\n\u003c/cfscript\u003e\n```\n\n##### Adding Rows\n\n```cfml\n\u003ccfscript\u003e\nmyQuery = queryNew(\"col1,col2,col3\");\nmyQuery.addRow([\"foo\",\"bar\",\"baz\"]);\ndump(myQuery);\n\u003c/cfscript\u003e\n```\n\n##### Adding Columns\n\n```cfml\n\u003ccfscript\u003e\nmyQuery = queryNew(\"col1,col2,col3\");\nmyQuery.addColumn(\"col4\", [\"foo\",\"bar\",\"baz\"]);\ndump(myQuery);\n\u003c/cfscript\u003e\n```\n\n##### Retrieving Data by Column\n\n```cfml\n\u003ccfscript\u003e\nmyQuery = queryNew(columns=\"col1,col2,col3\", \n\t\t\t\t   data=[\n\t\t\t\t   \t\t[\"one\",\"two\",\"three\"], \n\t\t\t\t   \t\t[\"foo\",\"bar\",\"baz\"], \n\t\t\t\t   \t\t[\"i\",\"am\",\"query\"]\n\t\t\t\t   ]);\ndump(myQuery.columnData(\"col1\"));\n\u003c/cfscript\u003e\n```\n\n##### Query For Loop\n\n```cfml\n\u003ccfscript\u003e\n\tmyQuery = queryNew(\"id,user\");\n\tqueryAddRow(myQuery);\n\tquerySetCell(myQuery, 'id', '1');\n\tquerySetCell(myQuery, 'user', 'Jeff');\n\tqueryAddRow(myQuery);\n\tquerySetCell(myQuery, 'id', '2');\n\tquerySetCell(myQuery, 'user', 'John');\n\tqueryAddRow(myQuery);\n\tquerySetCell(myQuery, 'id', '3');\n\tquerySetCell(myQuery, 'user', 'Steve');\n\u003c/cfscript\u003e\n\n\u003ccfloop query=\"myQuery\"\u003e\n\t#myQuery.id# #myQuery.user#\u003cbr /\u003e\n\u003c/cfloop\u003e\n```\n\nCFScript\n\n```cfc\n// CF \u003c 9.0\nfor ( i=1;i\u003c=myQuery.recordCount;i++ ) {\n\twriteOutput('#myQuery.id#: #myQuery.user[i]#\u003cbr /\u003e');\n}\n// (CF10+)\nfor ( row in myQuery ) {\n\twriteOutput('#row.id#: #row.user#');\n}\n```\n\n#### Dates\n\n* Lucee has a built in DateTime object\n\n* [createDateTime()](https://cfdocs.org/createdatetime)\n* https://docs.lucee.org/categories/datetime.html\n* https://rorylaitila.gitbooks.io/lucee/content/dates.html\n\n### Flow Control Structures\n\n#### If-ElseIf-Else\n\n* [cfif](https://cfdocs.org/cfif), [cfelseif](https://cfdocs.org/cfelseif), [cfelse](https://cfdocs.org/cfelse)\n\nCFML\n\n```cfml\n\u003ccfset count = 10\u003e \n\u003ccfif count GT 20\u003e \n\t\u003ccfoutput\u003e#count#\u003c/cfoutput\u003e \n\u003ccfelseif count EQ 8\u003e \n\t\u003ccfoutput\u003e#count#\u003c/cfoutput\u003e \n\u003ccfelse\u003e \n\t\u003ccfoutput\u003e#count#\u003c/cfoutput\u003e \n\u003c/cfif\u003e\n```\n\nCFScript\n\n```cfc\ncount = 10;\nif (count \u003e 20) { \n \twriteOutput(count); \n} else if (count == 8) { \n \twriteOutput(count); \n} else { \n \twriteOutput(count); \n}\n```\n\n#### Switch-Case\n\n* [cfswitch](https://cfdocs.org/cfswitch), [cfcase](https://cfdocs.org/cfcase), [cfdefaultcase](https://cfdocs.org/cfdefaultcase)\n\nCFML\n\n```cfml\n\u003ccfset fruit = \"\"\u003e \n\u003ccfswitch expression=\"#fruit#\"\u003e \n    \u003ccfcase value=\"Apple\"\u003eI like apples!\u003c/cfcase\u003e\n    \u003ccfcase value=\"Orange,Citrus\"\u003eI like oranges!\u003c/cfcase\u003e \n    \u003ccfcase value=\"Kiwi\"\u003eI like kiwi!\u003c/cfcase\u003e\n    \u003ccfdefaultcase\u003eFruit, what fruit?\u003c/cfdefaultcase\u003e \n\u003c/cfswitch\u003e\n```\n\nCFScript\n\n```cfc\nfruit = \"Orange\";\nswitch(fruit) {\n    case \"Apple\":\n        writeOutput(\"I like apples!\");\n        break; \n    case \"Orange\": case \"Citrus\":\n         writeOutput(\"I like oranges!\");\n        break; \n    case \"Kiwi\":\n        writeOutput(\"I like kiwi!\"); \n        break; \n    default: \n        writeOutput(\"Fruit, what fruit?\"); \n        break; \n }\n```\n\n#### For Loops\n\n* [cfloop](https://cfdocs.org/cfloop)\n\nCFScript\n\n```\nfor (i = 1; i \u003c= 10; i++) {\n    writeOutput(i); \n}\n```\n\nCFML\n\n```\n\u003ccfloop index=\"i\" from=\"1\" to=\"10\"\u003e\n    \u003ccfoutput\u003e#i#\u003c/cfoutput\u003e\n\u003c/cfloop\u003e\n```\n\n#### [While Loop](https://docs.lucee.org/reference/tags/while.html) (in Lucee)\n\n* [`cfwhile`](https://cfdocs.org/cfwhile)\n\nCFML\n\n```cfml\n\u003ccfwhile [condition=boolean] [label=string]\u003e\n\t\u003c!--- body ---\u003e\n\u003c/cfwhile\u003e\n```\n\nCFScript\n\n```cfc\n  while(condition) { }\n```\n\n#### Continue / Break / Exit\n\n* [`cfcontinue`](https://cfdocs.org/cfcontinue)\n* [`cfbreak`](https://cfdocs.org/cfbreak)\n* [`cfabort`](https://cfdocs.org/cfabort): stops processing of the current page at the location of the `cfabort` tag.\n* [`cfexit`](https://cfdocs.org/cfexit): controls the processing of a custom tag, and can only be used in ColdFusion custom tags.\n\n#### Exception\n\n* [`cftry`](https://cfdocs.org/cftry)\n* [`cfcatch`](https://cfdocs.org/cfcatch)\n\n* [`cffinally`](https://cfdocs.org/cffinally)\n\nCFML\n\n```cfml\n\u003ccftry\u003e\n\thello world\u003cbr/\u003e\n\t\u003ccfthrow message=\"threw on purpose!\" /\u003e\n\t\u003ccfcatch type=\"any\"\u003e\n\t\tCaught an exception\u003cbr/\u003e\n\t\u003c/cfcatch\u003e\n\t\u003ccffinally\u003e\n\t\tRan clean-up code regardless of error\n\t\u003c/cffinally\u003e\n\u003c/cftry\u003e\n```\n\nCFScript\n\n```cfc\ntry {\n\tx = 5/0;\n}\ncatch (any e) {\n\twriteOutput(\"Error: \" \u0026 e.message);\n}\n```\n\n## Closures \u0026 Lambda\n\n* https://rorylaitila.gitbooks.io/lucee/content/closures.html\n* https://modern-cfml.ortusbooks.com/cfml-language/closures\n\n### Closures\n\n\u003e A closure is the combination of a function and the lexical environment within which that function was declared.\n\n#### Assigning / Creating Closures\n\n```cfc\nfunction hello(){\n    var name = \"luis\";\n\n    var display = function(){\n        systemOutput( name );\n    };\n\n    display();\n}\n\nhello();\n```\n\n#### Returned Closures/High-Order Functions\n\n```cfc\nfunction makeAdder( required x ){\n    return function( required y ){\n        return x + y;\n    };\n}\n\nadd = makeAdder( 1 );\nsystemOutput( add( 2 ) );\n```\n\n#### Passing Closures\n\n* like `map()`, `reduce()`, `filter()`, etc.\n\n### Lambda Expressions (Lucee Only)\n\nAt the moment, only the Lucee CFML engine supports lambda expressions, which basically are a shorthand notation for defining closures.  \n\nLambda expressions reduce much of the syntax around creating closures. In its simplest form, you can eliminate the `function` keyword, curly braces and `return` statement. Lambda expressions implicitly return the results of the expression body.\n\n```cfc\n// Using a traditional closure\nmakeSix = function(){ return 5 + 1; }\n\n// Using a lambda expression\nmakeSix = () =\u003e 5 + 1;\n\n// returns 6\nsystemOutput( makeSix() );\n\n// Takes two numeric values and adds them\nadd = ( numeric x, numeric y ) =\u003e x + y;\n\n// returns 4\nsystemOutput( add( 1, 3 ) );\n```\n\n## Components and Functions\n\n### Components (CFC)\n\n* https://docs.lucee.org/categories/component.html\n* https://helpx.adobe.com/coldfusion/developing-applications/building-blocks-of-coldfusion-applications/building-and-using-coldfusion-components.html\n* https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-c/cfcomponent.html\n\nCFML\n\n* https://cfdocs.org/cfcomponent\n\n```cfml\n\u003ccfcomponent\u003e\n```\n\nCFScript\n\n```cfc\ncomponent displayname=\"myComponent\" {\n   function hello() {}\n}\n```\n\n#### Scopes\n\n* `variables` -- private scope, visible internally to the CFC\n* `this` -- public scope, visible from outside world\n* `static`\n\n#### Component Attributes\n\n* `accessors`  -- enables automatic getters/setters\n* `extends` -- inheritance\n* `implements` -- implements interfaces\n* `persistent` -- makes the object a Hibernate entity\n* `serializable` \n\n#### Properties\n\n* https://cfdocs.org/cfproperty\n\n```cfc\nproperty name=\"firstName\" default=\"\";\nproperty name=\"lastName\" default=\"\";\nproperty name=\"age\" type=\"numeric\" default=\"0\";\nproperty name=\"address\" type=\"array\";\n```\n\n### Functions\n\n* https://docs.lucee.org/reference/tags/function.html\n* https://cfdocs.org/cffunction\n* A function can take ANY amount of arguments\n* The default return type is `any` --\u003e can return any type of variable\n* The default visibility is `public`  (others are `private`, `package`, `remote`)\n* Functions in CFML are objects themselves. They can be added, removed, renamed even at runtime as CFML is a dynamic language.\n\nCFML\n\n```cfml\n\u003ccffunction name=\"\"\u003e\n```\n\nCFScript\n\n```cfc\npublic boolean function myFunction(required any myArgument) { }\n```\n\n#### Function Attributes\n\n* `output` \n* `description`\n* `returnFormat`\n\n#### Function Arguments\n\n* A function can receive zero or more arguments separated by commas\n\n```cfc\nfunction(\n \trequired type name=default attribute=value,\n \trequired type name=default attribute=value){\n}\n```\n\n#### Function Returns\n\n* A function must use the `return` keyword to return a value\n    * can be marked `void` to denote it does not return any value\n    * if a function has no return type or `any` and the body does not explicitly return a value, the function will automatically return `null`\n\n## Object-Oriented Programming\n\n* http://www.learncfinaweek.com/week1/OOP\n* https://rorylaitila.gitbooks.io/lucee/content/classes.html\n\n### Classes\n\nIn Lucee, classes are components and stored in files `.cfc`. Lucee supports OOP concepts like interfaces, inheritance, public and private methods.\n\n```cfc\ncomponent {...}\n```\n\n#### Constructors\n\nThe constructor method ~ function `init()`. There can be **only one constructor**, Lucee **does not support method overloading**.\n\n```cfc\ncomponent {\n  function init(){\n    return this;\n  }\n}\n```\n\n#### Methods\n\nComponents can define additional methods and they can have the following access levels:\n\n- Public - Accessible to all callers\n- Private - Accessible to only callers within this class\n- Package - Accessible to other Components in a package\n- Remote - Accessible to remote callers via web services, REST or invoking components from HTTP\n\n```\n[access] [return type] function [function name](){\n}\n```\n\n#### Method arguments\n\nIn Lucee, method arguments can be optionally typed, optionally required, and have default values.\n\n```cfc\ncomponent {\n\t// typed arguments\n\tpublic function myFunc(string argumentName1, struct argumentName2){...}\n\t// required arguments\n \tpublic function myFunc(required argumentName1, required argumentName2){...}\n \t// required typed arguments\n \tpublic function myFunc(required string argumentName1, required struct argumentName2){...}\n \t// default arguments\n \tpublic function myFunc(required string argumentName1=\"test\", required struct argumentName2={key:\"value\"}){}\n}\n```\n\n#### Instantiation\n\n* Using the [`new` operator](https://cfdocs.org/new), the CFML engine will instantiate the class and call the default constructor (if it exists)\n\n```cfml\n\u003ccfset bob = new Person()\u003e\n\u003ccfscript\u003e\n\tmyObj = new ClassName();\n\u003c/cfscript\u003e\n```\n\n* [cfobject](https://cfdocs.org/cfobject)  -- Creates a CFML object, of a specified type.\n* [createObject()](https://cfdocs.org/createobject) -- to instantiate CFC Components, but also Java, Com and SOAP WebService Objects. It also allows instantiating components with dynamic variable names.\n\n```cfml\n\u003ccfset bob = createObject( \"component\", \"Person\" ).init()\u003e\n\u003ccfscript\u003e\ntellTimeCFC=createObject(\"component\",\"appResources.components.tellTime\"); \n\ttellTimeCFC.getLocalTime();\n\u003c/cfscript\u003e\n```\n\nSOAP WS\n\n```cfml\n\u003ccfscript\u003e \n\tws = createObject(\"webservice\", \"http://www.xmethods.net/sd/2001/TemperatureService.wsdl\"); \n\txlatstring = ws.getTemp(zipcode = \"55987\"); \n\twriteOutput(\"The temperature at 55987 is \" \u0026 xlatstring); \n\u003c/cfscript\u003e\n```\n\n* [entifyNew()](https://cfdocs.org/entitynew)\n\n#### Component Lookup Rules\n\nWhen instantiating components they are found in the following ways\n\n- Any Components that are in the same directory as the script instantiating the component\n- Any Components imported into the script using the import keyword\n- Any Components pathed to using dotted notation, starting from the webroot\n- Any Components pathed to using dotted notation, that can be found from a mapping in `Application.cfc`\n\n### Interfaces\n\nLucee supports Interfaces which Components can implment multiple interfaces. Combined with the use of Mixins, Lucee Interfaces can help type check and document concise code.\n\nE.g. `IMyInterface.cfc`\n\n```cfc\ninterface {\n  public function myFunc(required string myString){ }\n  public function myOtherFunc(required array myArray){ }\n}\n```\n\n### Implementing an interface\n\n```cfc\ncomponent implements=\"IMyInterface\" {\n  public function myFunc(required string myString){\n    return arguments.myString;\n  }  \n  public function myOtherFunc(required array myArray){\n    return myArray;\n  } \n}\n```\n\n### Interface for Type Checking\n\n```cfc\ncomponent {\n\tpublic function init(required IMyInterface object){\n\t\t//Will error if the object passed in did not implement IMyInterface\n\t}\n}\n```\n\n## Databases\n\n* http://www.learncfinaweek.com/week1/Databases\n* http://www.learncfinaweek.com/week1/Intro_to_ORM\n* https://modern-cfml.ortusbooks.com/cfml-language/queries\n\n### Database Queries\n\nA query is a request to a database. It returns a CFML `query` object containing a **recordset** and other metadata information about the query. The query can ask for information from the database, write new data to the database, update existing information in the database, or delete records from the database.\n\n* Using the `cfquery` tag or function construct. (https://cfdocs.org/cfquery)\n\n* Using the `queryExecute()` function. (https://cfdocs.org/queryexecute)\n\nCFML\n\n```cfml\n\u003ccfquery name = \"qItems\" datasource=\"pantry\"\u003e \n SELECT QUANTITY, ITEM \n FROM CUPBOARD \n ORDER BY ITEM \n\u003c/cfquery\u003e \n```\n\nCFScript\n\n```cfc\nqItems = queryExecute( \n \"SELECT QUANTITY, ITEM FROM CUPBOARD ORDER BY ITEM\"\n);\n```\n\n#### Displaying Results\n\nCFML\n\n```cfml\n\u003ccfoutput query = \"qItems\"\u003e\nThere are #qItems.Quantity# #qItems.Item# in the pantry\u003cbr /\u003e\n\u003c/cfoutput\u003e\n```\n\nCFScript\n\n```cfc\nfor( var row in qItems ){\n systemOutput( \"There are #row.quantity# #row.item# in the pantry\" );\n}\n\nqItems.each( function( row, index ){\n systemOutput( \"There are #row.quantity# #row.item# in the pantry\" );\n\n} );\n\nfor( var i = 1; i lte qItems.recordCount; i++ ){\n systemOutput( \"There are #qItems.quantity[ i ]# #qItems.item[ i ]# in the pantry\" );\n}\n```\n\n#### [Query Functions](https://cfdocs.org/query-functions)\n\n\n\n## Testing\n\n* [TestBox](https://www.ortussolutions.com/products/testbox)\n\n## [CFWheels - MVC](https://cfwheels.org/)\n\n- https://guides.cfwheels.org/docs\n- Controllers  (`controllers`)\n    - `Controllers.cfc`  --\u003e root controller\n    - New controller --\u003e `component extends = \"Controller\" {...}`\n- Views (`views`)\n- Models (`models`)\n- Routes\n    - root --\u003e `/` --\u003e Controller = wheels, Action = wheels\n    - `/[controller]` --\u003e action `index`\n    - `/[controller]/[action]`  \n        - e.g.   `/say/hello`  --\u003e `controllers/Say.cfc`  + `function hello() {}`  + `views/say/hello.cfm`\n\n## [CommandBox](https://www.ortussolutions.com/products/commandbox)\n\n* Operation System integration for executing commands\n* Ability to create and execute commands built using ColdFusion (CFML)\n* [ForgeBox](https://www.coldbox.org/forgebox) integration for cloud package management and installations\n* ColdBox Platform, TestBox, and CommandBox CMS Integrations\n* Can spin up an ad hoc, lightweight, ColdFusion server (Lucee or Adobe ColdFusion) in any directory from the command line\n    * change the working directory to the root of the app\n    * type `server start` / `server stop`\n* Extensible via ColdFusion (CFML)\n    * CommandBox is small, lightweight, integrated at the operating system level, but actually running on CFML powered by [WireBox](https://www.ortussolutions.com/products/coldbox).\n\n## References\n\n* https://cfdocs.org\n* [Learn CF in a Week](http://learncfinaweek.com)\n* [CFML Tracks](https://exercism.io/tracks/cfml)\n* [Lucee Book](https://rorylaitila.gitbooks.io/lucee)\n* [Learn Modern ColdFusion (CFML) in 100 Minutes](https://modern-cfml.ortusbooks.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtr3n%2Flearn-lucee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtr3n%2Flearn-lucee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtr3n%2Flearn-lucee/lists"}