Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

setting paths to folers - mappings?

Explorer ,
May 22, 2009 May 22, 2009

Hi,

I already use mappings to set the location of my CFC's. In my Application file I tend to set file folders like this

<cfset application.galleryPath = '/mysite/gallery/galleryImages/'>

and use #application.galleryPath# when outputing my images.

Now on my remote server I can setup a the mappings on a site by site basis

/galleryImages   /httpdocs/backend/galleryImages

but locally because I am creating and testing multiple sites I have to do it by name of the site

/site1galleryImages   /httpdocs/site1/backend/galleryImages

/site2galleryImages   /httpdocs/site2/backend/galleryImage

which means eventually I will have hundreds of mappings. Is there a workaround?

Alternatively is what I am doing with the apllication variables ok or does anyone have an alternative?

Thanks.

622
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , May 24, 2009 May 24, 2009

Hulfy,

On your local development box, you can create Virtual Hosts for each site on which you're working to keep things clean and separate while developing.

I'm on Mac 10.5.7 with Apache 2.2.9 and ColdFusion 8.0.1. This is what I do when I start a new project or site:

1. In my hosts file (/private/etc/hosts), I add a new host entry for my site as I start a new project:

     127.0.0.1     dev.mynewsite.local

     On Windows, this same file (hosts) is typically here: c:\windows\system32\drivers\etc\ho

...
Translate
Advocate ,
May 24, 2009 May 24, 2009

Hulfy,

On your local development box, you can create Virtual Hosts for each site on which you're working to keep things clean and separate while developing.

I'm on Mac 10.5.7 with Apache 2.2.9 and ColdFusion 8.0.1. This is what I do when I start a new project or site:

1. In my hosts file (/private/etc/hosts), I add a new host entry for my site as I start a new project:

     127.0.0.1     dev.mynewsite.local

     On Windows, this same file (hosts) is typically here: c:\windows\system32\drivers\etc\hosts

2. In my Apache httpd-vhosts.conf, I add a VirtualHost entry for this new site:

<VirtualHost *:80>

      ServerName dev.mynewsite.local

      ServerAlias dev.mynewsite.local

      ServerAdmin me@email.com

      DirectoryIndex index.cfm index.html index.htm

      DocumentRoot /Users/path/to/Sites/mynewsite

</VirtualHost>  

I think in IIS, you would just create a new site in the IIS Administrator and tell that site to 'listen' for requests for the domain/host created in step 1, above.

3. I restart Apache (I don't think IIS needs to restart for this) & I'm ready to go.

If I point my browser to http://dev.mynewsite.local, I see my newly setup site. Now, I can set my mappings just like I do on the production server and without worrying about duplicated mappings, assuming your new application has its own Application file (cfm or cfc). I find that with this setup and approach, I can better mirror or mimic my production environment when I develop, plus it keeps all my local sites/projects neat and orderly!.

As for the use of the application scope, I think that's a bit of a larger 'debate'. Personally, I like this scope for globally used objects, common elements like DSNs, mappings, and the like. I just try not to go overboard and shove too much in it .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 25, 2009 May 25, 2009

Thanks for your great answer. The only bit that is confusing me is this

If I point my browser to http://dev.mynewsite.local, I see my newly setup site. Now, I can set my mappings just like I do on the production server and without worrying about duplicated mappings, assuming your new application has its own Application file (cfm or cfc).

My undertanderstanding is that mapings are a physical path, if I setup 2 sites abc and def

galleyPath        /Applications/ColdFusion8/wwwroot/abc/backend/imageGallery

galleyPath        /Applications/ColdFusion8/wwwroot/def/backend/imageGallery

How will the server determine which one to use? Each one has it's own Appilcation.cfc what should be in there?

Many thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 25, 2009 May 25, 2009
LATEST

Hi, Hulfy,

Sorry I wasn't more specific! Let's use your example from below and say we have 2 sites, Site abc & Site def. Site abc is in /Applications/ColdFusion8/wwwroot/abc and Site def is in /Applications/ColdFusion8/wwwroot/def.

Site abc has 2 files and 1 folder (marked by leading dash) in it:

Application.cfc

index.cfm

-backend

The backend folder in abc contains another folder:

-imageGallery

Site def has the same structure -- 2 files and 1 folder (marked by leading dash) in it:

Application.cfc

index.cfm

-backend

The backend folder in def contains another folder:

-imageGallery

The goal, as I understand it, is to use a common path (common in that it has the same variable name, galleryPath) to get to the imageGallery directory in both sites.

In Site abc's Application.cfc, we set a galleryPath variable in onApplicationStart():

application.galleryPath = " /Applications/ColdFusion8/wwwroot/abc/backend/imageGallery";

In Site def's Application.cfc, we set a galleryPath variable in onApplicationStart():

application.galleryPath = " /Applications/ColdFusion8/wwwroot/def/backend/imageGallery";

Even though both sites have the same path name (galleryPath), there will be no conflict b/c they are declared/set in separate applications and are able to be used by both applications without any conflicts. The 'key' is to set the paths in your respective Application.cfc files, rather than in the CF Administrator.

When you setup your dev environment this way, each application, in essence, lives in its own little bubble, unaware of what other CF applications are doing, except for the 'shared' settings made in your CF Administrator (DSNs, etc., can be accessed from any CF app on your server).

One important note: in each Application.cfc, be sure to give each app a unique name (this.name = site_abc and this.name = site_def, for example)!

Please let me know if this doesn't help or answer your question!

Best,

Craig

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources