cfenv

Share your local CFML dev site to your colleagues with Forward

Share your local CFML dev site to your colleagues with Forward

Let’s say you’ve started a new CFML app project in your ~/Projects/my_cfml_project directory.

You’re in Terminal (or Cygwin on windows) and have a version of Ruby / RubyGems installed on your system.

On Mac OS X and most Linux distributions, Ruby / RubyGems is already installed.
For Windows Ruby Installations, you can follow this guide on Forwardhq.com

Assuming you’ve done all that, however…

You’ve already defined a Railo CFML version for your project with cfenv of course… 😉

The Problem

But you have a problem that has came up…
You would LOVE to send your boss and colleague a link to your LOCAL codebase as it exists right now to show them.
If you send them your current URL at http://localhost:8888/my_awesome_file.cfm they will get nothing but nothing.

So… that’s where Forward comes in.

Open up another Terminal Window / Tab or Console screen.

Install Forward with RubyGems

Getting Forward on a system is so easy with RubyGems.

$ gem install forward

Or with sudo gem install forward if you need permissions.

Tunneling your CF / Railo site with Forward

Now that it’s installed, you can use it to give your colleagues web access to your working directory.

Make sure you’re in your project directory.

$ cd ~/Projects/my_cfml_project
$ forward 8888
Forwarding port 8888 to [https://yourcompany.fwd.wf][8]
Ctrl-C to stop forwarding

It’s even under an SSL, awesome right?

But what if my web app has subdomains like http://johnsmith.localhost.dev/?
Well, Forward handles that out of the box too!
Simply go to https://johnsmith.yourcompany.fwd.wf/.

That’s it!

I think it is so awesome that there are niche services out there to make our lives as web developers even better than it already is.

Let me know if you use this technique on a project!

Developing a Mura CMS v6 site locally with cfenv!

Developing a Mura CMS v6 site locally with cfenv!

I want to start by saying… I’ve been using cfenv for my projects now for the past two days and am loving it tremendously. It’s so nice to not have to worry about downloading and configuring railo express versions for each and every app I’m running. I can choose which version of Railo I want to run on a per-project basis or globally for the entire system. Anyway…

Expectations

Let’s get started.

We’re going to open up Terminal (or cygwin on Windows)

Install a Railo Version with CFENV

Let’s install a version of Railo globally (if you haven’t already done so in a previous installation guide).
Going to start by listing out the available versions since I cannot remember what my options are…

$ cfenv install -l
Available versions:
  3.0.2.001
  3.0.3.000
  3.3.3.001
  4.0.4.001
  4.1.1.000
  4.1.1.009

Let’s go with the latest (4.1.1.009)

$ cfenv install 4.1.1.009

Our Project Directory

Create our project directory if we don’t already have it and change into that directory.

$ mkdir -p ~/Projects/my_mura_project
$ cd ~/Projects/my_mura_project

Let’s set our local project directory Railo version to 4.1.1.009 for good measure.
This will ensure our mura project always runs in our consistent Railo 4.1.1.009 because that’s what this particular cms will be running in production.

$ cfenv local 4.1.1.009

Download Mura CMS v6

Now, we still have an empty project directory.
Let’s download and extract the latest Mura CMS version.

$ curl -L --output muracms.zip http://getmura.com/currentversion/
$ tar -zxvf muracms.zip

For good measure, we will remove the muracms.zip file.

$ rm muracms.zip

Create a Database

You’re going to need a database / datasource for Mura to work correctly so open up MySQL or your favorite SQL database system and create one now.
Don’t worry… I’ll wait…

Once you’ve done that, make sure you know the db name, server, user, and password of the database so we can create the datasource.

Run Railo

Now let’s start the Railo server to begin developing our new project.

$ railo_init

Create Datasource

Open up Railo’s Admin Panel in your web browser. http://localhost:8888/railo-context/admin/web.cfm

Setup a password for this web context since it’s your first time running.
Make it easy so you don’t have to sweat it later… this is only development after all.

Click on Datasource on the left menu under Services.

create the datasource

Proceed with giving it a name, and type.
Click create.
Then finish setting it up by entering the server, db name, username, and password of the database in their respective fields and then save & verify it.

Finish Mura Setup

Browse to your webroot at http://localhost:8888/ and fill in the form with the settings above.
You only need to enter the Datasource Name, Super Admin User, Super Admin Password, and Admin Email.
Click ‘Save Settings’

Now click ‘Login to Mura’

Enter your Super Admin Username / Password if you changed it from the default.
Otherwise, it’s:

  • Username: admin
  • Password: admin

Shutting down the app

When you are finished developing for the day, you can CTRL+C on the Terminal window that is running Railo.
This should shut everything down and clear your RAM / CPU.

You’re all set!
Enjoy!

Installing CFENV on Ubuntu

Installing CFENV on Ubuntu

On Ubuntu, it is necessary to use the Git / GitHub method for installation.

1.) Install Git

$ sudo apt-get install git

You should already have Git though, RIGHT??!?

2.) Install Dependencies for legacy Railo versions.

Are you running 64bit version of Ubuntu? Please verify these dependencies are installed first by typing:

$ sudo apt-get install libc6-i386 lib32gcc1 lib32z1 lib32stdc++6

3.) Install CFENV Check out cfenv into ~/.cfenv.

$ git clone https://github.com/joshuairl/cfenv.git ~/.cfenv

Add ~/.cfenv/bin to your $PATH for access to the cfenv command-line utility.

$ echo 'export PATH="$HOME/.cfenv/bin:$PATH"' >> ~/.bash_profile Add

cfenv init to your shell to enable shims and autocompletion.

$ echo 'eval "$(cfenv init -)"' >> ~/.bash_profile

Restart your shell so that PATH changes take effect. (Opening a new terminal tab will usually do it.)

Now check if cfenv was set up:

$ type cfenv // "cfenv is a function"

Upgrading CFENV

If you’ve installed cfenv manually using git, you can upgrade your installation to the cutting-edge version at any time.

$ cd ~/.cfenv
$ git pull

To use a specific release of cfenv, check out the corresponding tag:

$ cd ~/.cfenv
$ git fetch
$ git checkout v0.0.6

Using CFENV on a New Project

If you just now have a fresh installation of cfenv then you will need to install a Railo version.

$ cfenv install 4.1.1.009

I personally store all my working projects in a directory called ~/Projects

$ mkdir -p ~/Projects/my_new_cfml_project $ cd ~/Projects/my_new_cfml_project

Let’s set this project’s Railo Version to 4.1.1.009.

$ cfenv local 4.1.1.009

Now let’s create a little test cfml file so we have some output when we start our server.

<cfscript> 
writeOutput('Hello, from your new cfenv context!!!'); 
writeDump(SERVER); 
</cfscript>

Save that file as index.cfm. Now we need to startup our server.

$ railo_init

Visit http://localhost:8888/ in your browser.

With any luck, you should see your test cfml file we created nicely printing out. That’s really all there is to it…

Find more information at: https://github.com/joshuairl/cfenv

Installing CFENV on Mac OS X

Installing CFENV on Mac OS X

Using Homebrew

The first and most common way to install is using Homebrew.

If you don’t know what Homebrew is, visit http://brew.sh/.

I won’t be covering installation of Homebrew in this article.

That being said…

Open up Terminal.app and run the following commands.

$ brew tap joshuairl/homebrew-cfenv 
$ brew update 
$ brew install cfenv

Using Git / GitHub

This will get you going with the latest version of cfenv and make it easy to fork and contribute any changes back upstream. Anyway, we start by installing Git if we don’t already have it. You can do this with homebrew via

brew install git or by downloading Xcode w/ Command Line Tools (recommended). But I’m not going to cover how to do that here.

  1. Check out cfenv into ~/.cfenv.
$ git clone https://github.com/joshuairl/cfenv.git ~/.cfenv
  1. Add ~/.cfenv/bin to your $PATH for access to the cfenv command-line utility.
$ echo 'export PATH="$HOME/.cfenv/bin:$PATH"' >> ~/.bash_profile
  1. Add cfenv init to your shell to enable shims and autocompletion.
$ echo 'eval "$(cfenv init -)"' >> ~/.bash_profile
  1. Restart your shell so that PATH changes take effect. (Opening a new terminal tab will usually do it.) Now check if cfenv was set up:
$ type cfenv // "cfenv is a function"

Upgrading CFENV

If you’ve installed cfenv manually using git, you can upgrade your installation to the cutting-edge version at any time.

$ cd ~/.cfenv
$ git pull

To use a specific release of cfenv, check out the corresponding tag:

$ cd ~/.cfenv
$ git fetch
$ git checkout v0.0.6

If you’ve installed via Homebrew, then upgrade via its brew command:

$ brew update
$ brew upgrade cfenv

That’s all there is to it!

For usage information and additional installation tips and steps visit

https://github.com/joshuairl/cfenv#groom-your-apps-cfml-dev-environment-with-cfenv

Dead Simple CFML Dev Environments with CFENV

Dead Simple CFML Dev Environments with CFENV

UPDATE!! 11/06/2013 Read First. 
I just updated this article to reflect some of the 
latest changes made to cfenv. 
Please refer to the README at 
<https://github.com/joshuairl/cfenv> for more complete information.
 If you have ever worked with Ruby on Rails, you know just now simple it is to spin up a new application and server to start developing. Well, due to CFML being Java based... it has loads more to do to startup and handle on the server-side. 

Some History

For awhile, I’ve been working with Railo as my development environment on my Mac. More specifically, Railo Express with Jetty and utilizing the “railo_runner” technique described on Mark Drew’s blog. If you are not familiar with that technique, it’s KIND OF similar to Rails in the sense that you can

mkdir ~/Projects/my_new_project in Terminal, then cd ~/Projects/my_new_project, and then railo_runner and it will place a WEB-INF directory and startup Jetty with Railo Express pointing to that directory. It’s creating a new WEB CONTEXT for this particular directory. It’s beautiful. You do not have to create manual entries in server.xml of Tomcat, or host your code within the webapps directory. It’s nice as is. But I wanted to make it a little better… That’s where railoenv comes in.

What is cfenv?

The railo_runner technique is awesome. But it does require some configuration initially which can get in the way of developing CFML if you’re on a new computer somewhere without Railo. I’ve decided to automate the download/install/configuration of Railo Express & railo_runner into one package and I’m calling it cfenv. The END goal is for this to be very similar in logic to rbenv and nodenv respectively.

Will it conflict with my Adobe ColdFusion and/or prior Railo installations and setups?

No, it won’t. cfenv is self contained and downloads it’s own copy of Railo Express with Jetty and maintains it for you.

How to use cfenv?

First, install cfenv. To do so, follow the instructions found at: https://github.com/joshuairl/cfenv#installation Once you’ve installed it, you will need to use cfenv to install a version of Railo.

$ cfenv install 4.1.1.009

  (which at this time is the latest version) Now we want to set this version to be used in all shells globally.

$ cfenv global 4.1.1.009

To test, create a new directory in your Sites / Projects directory… Mine are found in ~/Projects so that’s what I’ll use in my example.

$ mkdir -p ~/Projects/my_cfml_project 

And change into that directory…

$ cd ~/Projects/my_cfml_project

Now, we initialize a new railo context within the directory…

$ railo_init

You should now see output similar to the following…

mccme-rountrjf:my_cfml_project joshua$ railo_init
WARNING: System properties and/or JVM args set.  Consider using --dry-run or --exec
[ShutdownMonitor] STOP.PORT=8887
[ShutdownMonitor] STOP.KEY=railo
[ShutdownMonitor] ServerSocket[addr=/127.0.0.1,port=0,localport=8887]
Starting ShutdownMonitorThread
railo-server-root:/opt/railo/lib/ext/railo-server
Fri Nov 01 12:28:58 EDT 2013 Load Build in Core
===================================================================
SERVER CONTEXT
-------------------------------------------------------------------
- config:/opt/railo/lib/ext/railo-server/context
- loader-version:4.2
===================================================================

Fri Nov 01 12:28:58 EDT 2013-807 using JRE Date Library
Fri Nov 01 12:28:58 EDT 2013-831 write file:/opt/railo/lib/ext/railo-server/context/railo-server.xml
Fri Nov 01 12:28:59 EDT 2013-514 write file:/opt/railo/lib/ext/railo-server/context/library/tag/Dump.cfc
Fri Nov 01 12:28:59 EDT 2013-514 write file:/opt/railo/lib/ext/railo-server/context/library/tag/MediaPlayer.cfc

...

===================================================================

WEB CONTEXT (26e8ec2748b7d9a30de915bf6b5d1e3f)
-------------------------------------------------------------------
- config:/Users/joshua/Projects/my_cfml_project/WEB-INF/railo
- webroot:/Users/joshua/Projects/my_cfml_project
- hash:26e8ec2748b7d9a30de915bf6b5d1e3f
- label:26e8ec2748b7d9a30de915bf6b5d1e3f
===================================================================
Fri Nov 01 12:29:00 EDT 2013-5 write file:/Users/joshua/Projects/my_cfml_project/WEB-INF/railo/railo-web.xml.cfm
Fri Nov 01 12:29:00 EDT 2013-12 write file:/Users/joshua/Projects/my_cfml_project/WEB-INF/railo/locales/pt-PT-date.df
Fri Nov 01 12:29:00 EDT 2013-13 write file:/Users/joshua/Projects/my_cfml_project/WEB-INF/railo/video/video.xml

...

Your new web context is now running at http://localhost:8888/

Let’s create a test file for our context to load. Open up your favorite CFML Editor and add the

my_cfml_project directory to it as a new project.

Create a new file called index.cfm

Add something along these lines to the file for kicks…

<cfscript>
writeOutput('Hello, from your new cfenv context!!!'); 
writeDump(SERVER); 
</cfscript>   

Save it, and refresh http://localhost:8888/ and you should see something beautiful. 😀 Let me know if you guys try it. You can contribute bug reports, code, etc. at https://github.com/joshuairl/cfenv