2

This week I just try to recall Fw1 framework. But, I faced fw1 core file error. Below screen has my folder structure,

enter image description here

Inside the lib folder, I have one more folder called a framework. The framework folder also has one.cfc & ioc.cfc files. Now, I'm trying to run my application in the browser. It's throwing below error.

Could not find the ColdFusion component or interface C:\ColdFusion2016\cfusion\wwwroot\try\Fw1Demo\framework\ioc.cfc

But, In my Application.cfc I have extended fw1 one.cfc core file.

component extends="lib.framework.one" output="false" {
}

But, I'm not sure why this is throwing an error.

jawahar N
  • 462
  • 2
  • 13
  • 1) Just do test Dump & abort in your setupApplication() and check whether the setApplication called or not. 2) If it's called properly then again do a test dump in your setupRequest(). If it's called properly then there is no is issue in Framework one.cfc . Make sure you have to you setupApplication() , setupRequest() methods instead of OnApplicationStart() and OnRequestStart(). Let me know the result. – Kannan.P May 12 '19 at 07:53
  • 2
    rather than putting the files into `lib/framework`, just put them in `framework` – James A Mohler May 12 '19 at 15:01
  • 1
    @JamesAMohler Yeah. You are right. I have analyzed the `framework core files ( one.cfc & ioc.cfc )`. In these files, they are mentioned `static path like framework.ioc`. I found the exact reason why it's throwing an error when we use a different folder structure. – jawahar N May 12 '19 at 17:05
  • 1
    You should write up confirmed that and how you fixed the issue. OT: FW/1 does all kinds of good things. Once you start following its patterns, all kinds of functionality starts happening. – James A Mohler May 12 '19 at 20:40
  • @JamesAMohler I have added my fix. :) – jawahar N May 14 '19 at 02:39

3 Answers3

2

Now, We can able to put fw1 framework core files in a different folder. We don't need to follow the fw1 mentioned folder structure. I mean, framework/one.cfc & framework/ioc.cfc.

But, for using different folder structure need to change the path in framework/one.cfc. In this file, they are used as a static path to point out the ioc.cfc file. We need to change that path.

In my above questions, I used lib/framework/one.cfc & lib/framework/ioc.cfc. So, In one.cfc file, need to change the below code,

var diComponent = 'lib.framework.ioc';

variables.framework.applicationKey = 'lib.framework.one';

By default, the above mentioned variables have the below values,

var diComponent = 'framework.ioc';

variables.framework.applicationKey = 'framework.one';

So, In this variables need to update our path.

Thanks,

jawahar N
  • 462
  • 2
  • 13
  • 1
    But @jawahar. You can't change the core functionality directly. That's not good. right ?. Imagine in future they may added some improvements / enhancement on your diComponent means that time also you have change that values. So better try to follow what FW1 suggested folder directory. That's what we called as framework. Again I advice don't change that file directly. – Kannan.P May 14 '19 at 11:30
  • @Kannan.P Some exceptional cases, we need to touch core files. For example, the client asking us to put all those kind of files in the inside of the lib folder. At that situation, we can able to explain what is fw1 framework and what is fw1 folder structure. But, the client said, if you put all files inside of lib that would you great for me. So, Again we can't able to argue with our client. Because fw1 has a feature to change its own folder structure. – jawahar N May 16 '19 at 02:49
  • So, As a developer, we need to satisfy our client. That's the main key point. If we don't have options to change the means, then we can able to explain our points. But, fw1 also gives the opportunity to change its folder structure. My question is, then why they are giving these features? If it's mandatory means, why they are giving these features to change the path? – jawahar N May 16 '19 at 02:51
  • because it's convention over configuration framework. But, Instead of changing a core file can able to use like @sathish chelladurai mentioned. And you said, if we change the core directly means, in future, they added some improvements in dicomponent means, that time also we need to change the path. But, they just added improvements. Definitely, they have not changed their path (framework/ioc.cfc). – jawahar N May 16 '19 at 02:53
  • Core which mean the owner and contribution devs only have rights changes the core functionality. If you want to satisfy your client you have to write your own changes in variables.framework as Sathis chelladurai mentioned. If you change your application.cfc that will affect in that particular application only. But if you change in core you need to change more every time the fw1 get upgrade if that upgrade it related with your changes. Hope you understood. – Kannan.P May 16 '19 at 03:50
  • Hope, You didn't read my all points. So, You can able to get what I try to convey. In my point, I already explained what you said in your above point. Hope, you understood. – jawahar N May 16 '19 at 08:58
2

Fw1 is a light weight framework and have that is called convention over configuration. We can configure it in the Application.cfc

As per my knowledge, If you want to configure that you don't touch the core files. Just add it into the Application.cfc

Its like the default Section, Item and the reloadApplicationOnEveryRequest setup like

variables.framework = {
        defaultSection = 'dashboard',
        defaultItem = 'default',
        reloadApplicationOnEveryRequest = false
    };

For your scenario you should add in Application.cfc like,

variables.framework = { applicationKey = 'lib.framework.one'; }

For its only the application specific configuration. I didn't try the configure like that but we can do the configuration like this.

Sathish Chelladurai
  • 670
  • 1
  • 8
  • 23
0

Instead of changing the core files, please, try the following.

  1. Create a mapping for framework folder using CF admin interface named 'framework'
  2. Add/Update this in your Application.cfc file variables.framework = {diComponent = "framework.ioc"}

This way, you will not change the core files and still have what you want.

akashb
  • 111
  • 6