Changing the default folder structure of concrete5

Permalink
Hi all,

I've searched for this in the forum but haven't found a good answer.

I would prefer a slightly different folder structure for concrete5. Instead of:

/blocks
/concrete
/config
/controllers
...
/packages

...I would rather have:

/app
-> /blocks
-> /controllers
-> ...other app-specific folders
/config
/concrete
/packages

Is this possible without core concrete5 changes?

Thanks for your response!

 
mesuva replied on at Permalink Reply
mesuva
Although I like this way of organising sites myself (it reminds me of CakePHP), from looking at how concrete5 works out the path to those folders, I think you might end up in a world of pain trying to reconfigure things that way.

Maybe you can do it with symlinks or something, but again I think that might end up being really messy.

Is there any particular reason you're wanting it this way?
jamonholmgren replied on at Permalink Reply
Thanks for the reply, Mesuva!

After looking into concrete's dispatcher extensively, I did get concrete5 working with that folder structure by adding in the following lines into index.php in the root folder:

define('DIR_BASE', dirname(__FILE__) . "/app");
        define('DIR_CONFIG_SITE', dirname(__FILE__) . "/config");
        require('concrete/dispatcher.php');


It also looks like I need to do something with DIR_FILES_UPLOADED. I'll play around with that and see what that does.
jamonholmgren replied on at Permalink Reply
Oh, I forgot to answer your question as to "why." Mainly because I think it is much cleaner. Right now you have "blocks" mixed with "concrete" when they're really two entirely different levels of importance. "app" and "concrete" make more sense.

Concrete is still uploading files to the /app/files folder instead of /files. Anyone know what constant to change to have concrete upload to the /files folder? Or is it due to my DIR_BASE constant being set to /app?
Mainio replied on at Permalink Reply
Mainio
At lease I found these from /concrete/config/base.php:
define('DIR_FILES_UPLOADED_STANDARD', DIR_BASE . '/files');
define('DIR_FILES_TRASH_STANDARD', DIR_BASE . '/files/trash');
define('REL_DIR_FILES_UPLOADED', DIR_REL . '/files');
if (!defined('DIR_FILES_BACKUPS')) {
   define('DIR_FILES_BACKUPS', DIR_BASE . '/files/backups');
}
define('REL_DIR_FILES_UPLOADED_THUMBNAILS', DIR_REL . '/files/thumbnails');
define('REL_DIR_FILES_UPLOADED_THUMBNAILS_LEVEL2', DIR_REL . '/files/thumbnails/level2');
define('REL_DIR_FILES_UPLOADED_THUMBNAILS_LEVEL3', DIR_REL . '/files/thumbnails/level3');
define('REL_DIR_FILES_CACHE', REL_DIR_FILES_UPLOADED . '/cache');
#Cache
if (!defined('DIR_FILES_CACHE')) {
   define('DIR_FILES_CACHE', DIR_BASE . '/files/cache');
}
# Sessions/TMP directories
jamonholmgren replied on at Permalink Reply
Okay, it's basically working (but needs to be tested quite a bit).

Just edit your index.php in your root folder. Modify as you wish.

One problem will come if you have strict error reporting on. Some of these constants get defined again later and you'll get a notice about that. The constants WILL NOT be overwritten, however, so you're good to go.

define('DIR_ROOT', dirname(__FILE__));
   define('DIR_BASE', DIR_ROOT . "/app");
   define('DIR_CONFIG_SITE', DIR_ROOT . "/config");
   define("DIR_FILES_UPLOADED", DIR_ROOT . "/files");
   define("DIR_FILES_UPLOADED_STANDARD", DIR_ROOT . "/files");
   define('DIR_FILES_TRASH_STANDARD', DIR_FILES_UPLOADED_STANDARD . '/trash');
   define("DIR_FILES_BACKUPS", DIR_FILES_UPLOADED . "/backups");
   define("DIR_FILES_CACHE", DIR_FILES_UPLOADED . "/cache");
   require('concrete/dispatcher.php');
jamonholmgren replied on at Permalink Reply
Note that relative paths don't need to be changed since concrete5 assumes files will be in the root folder already (and that's where they are).
mkly replied on at Permalink Reply
mkly
I think your best route for this kind of behavior is avoiding using a CMS or attempting to remedy this with a fork into a new project or pull request.

http://github.com/concrete5

Dogma following in the world of CMS's usually leads to massive headache's.
jamonholmgren replied on at Permalink Reply
If I figure out that we have to modify the core to make this happen, I'll do a pull request.

Thanks for the suggestion!
Mainio replied on at Permalink Reply
Mainio
+1 if you manage to do this, I'd be also really interested!

However, as @mkly pointed at, concrete5 already assumes a lot of the folders to be in the main root folder, so I'm sure you need to worry about a lot of things when testing this.

How I'd like things to be:
/app/ <-- App-specific folder & overrides
/assets/ <-- Static assets (could override the core folder's assets if found any)
/concrete/ <-- Core
/files/ <-- Files

And in that structure the /app/ folder would actually contain a lot of what the root folder now contains (the folders you don't see in the list above).

One main point also here is that I'd really like the static assets to be included in one single folder, as they now are separate folders:
/css/
/js/
/images/

So, I already prefer a bit different kind of structure that you do... :) Can we ever find a perfect solution that everyone would be pleased with? Probably not, but it would be great if these could be easily configurable, though.

I would also like the /config/ folder to be part of the app folder, so that it would be /app/config/ because config is usually app-specific.


Antti
jamonholmgren replied on at Permalink Reply
I'm fine with your structure. I just don't like concrete, helpers, packages, files, and blocks all mixed together like they're on the same level. Knowing what constants to edit should make any folder structure possible, provided that concrete5 utilizes the constants in all the right places.
Mnkras replied on at Permalink Reply
Mnkras
check out the files in /concrete/config, that is where 99% of all defines are,
jamonholmgren replied on at Permalink Reply
Yeah, that's where I found the constants I posted above. Thanks!