Setting up a NATIVE centralized concrete5 environment
Permalink
I'm running multiple instances of concrete5 in my dev environment for different projects or purposes so I thought it's not time to centralize things up in my development environment. After searching for a while, I bumped into this article:
http://www.concrete5.org/documentation/how-tos/developers/setting-u...
That article basically shows how to do a centralized environment in a "real hosting environment" and with symlinks. However, I'm running my dev env in windows so I'm not that comfortable with symlinks although it's on some level possible with "mklink" command (still, there are e.g. permission issues etc. with running that command).
My development environment with different concrete5 installs looks basically like this:
And my development web server is serving /dev/php/. So basically e.g. the static assets (together with the main core) are already available in the main concrete5 folders and there's no reason I'd copy e.g. the latest github version over and over again for different projects because it changes fequently. As said, I wanted to do this locally from c5 instead of windows symlinking what I've never done with windows.
So here's what I did:
a) I copied the empty project folder structure (concrete5 overriding structure) to a blank project (without /concrete/ folder)
b) I created an empty /concrete/ folder into that project for adding a custom dispatcher.php file in there
c) wrote a project-specific /concrete/dispatcher.php that will check for project-specific startup script named /config/startup.php
d) when the custom /concrete/dispatcher.php file is done, it loads the REAL dispatcher file from /DIR_BASE_CORE/concrete/dispatcher.php
And I also see no reason why this KIND OF stuff could not be included natively in index.php other than keeping index.php clean. For the keeping it clean point, check up e.g. a native Zend Framework project's index.php file, it's not completely clean and there is this kind of configuration in that file.
The custom dispatcher.php file is attached in this message (concrete.zip). Please note that in the custom project, that is really the only file you need to have in the /concrete/ folder, it is otherwise empty!
After this, I could do the centralization configuration in each project's /config/startup.php file:
HOWEVER, because of how concrete5 core currently defines ASSETS_URL_WEB, you will end up with a PHP error if you keep that code in your /config/startup.php script. So there's still ONE CENTRALIZED CORE HACK you need to do, you cannot bypass this in any ways and if you don't set up that constant properly, you won't be loading your core css/js/images properly.
<< EDIT 1: The hack provided below is not necessary, see EDIT 1 at the bottom of this message >>
The hack you need to do in the core is for file /concrete/config/base.php. Search for the problematic constant ASSETS_URL_WEB and you find these rows (please note that these rows are NOT together in the same place consequently):
Change BOTH OF THOSE ROWS to this:
And after that you're ready to go using your centralized c5 environments. Please note that if you e.g. want to test out with different versions of c5, you'll need to do the hack mentioned above for each of those cores.
Tested this out with latest c5 github version for installation and running the site.
Hopefully it will help also someone other than me. At least I'm now happily developing under WAMP. :)
Antti / Mainio
EDIT1:
I realized a way you can also do that WITHOUT ANY HACKS to the real core, so here's what you need to add to the config/startup.php before that issue gets fixed in the core:
This does not affect any other errors because concrete5 error displaying is set AFTER the problematic /concrete/config/base.php is loaded.
http://www.concrete5.org/documentation/how-tos/developers/setting-u...
That article basically shows how to do a centralized environment in a "real hosting environment" and with symlinks. However, I'm running my dev env in windows so I'm not that comfortable with symlinks although it's on some level possible with "mklink" command (still, there are e.g. permission issues etc. with running that command).
My development environment with different concrete5 installs looks basically like this:
/dev/php/concrete5/ <-- Latest github version /dev/php/concrete5.x.x.x/ <-- Official releases /dev/php/concrete5_packages/ <-- Package development /dev/php/concrete5_some_random_project/ <-- E.g. some add-on project I'm contributing to
And my development web server is serving /dev/php/. So basically e.g. the static assets (together with the main core) are already available in the main concrete5 folders and there's no reason I'd copy e.g. the latest github version over and over again for different projects because it changes fequently. As said, I wanted to do this locally from c5 instead of windows symlinking what I've never done with windows.
So here's what I did:
a) I copied the empty project folder structure (concrete5 overriding structure) to a blank project (without /concrete/ folder)
b) I created an empty /concrete/ folder into that project for adding a custom dispatcher.php file in there
c) wrote a project-specific /concrete/dispatcher.php that will check for project-specific startup script named /config/startup.php
d) when the custom /concrete/dispatcher.php file is done, it loads the REAL dispatcher file from /DIR_BASE_CORE/concrete/dispatcher.php
And I also see no reason why this KIND OF stuff could not be included natively in index.php other than keeping index.php clean. For the keeping it clean point, check up e.g. a native Zend Framework project's index.php file, it's not completely clean and there is this kind of configuration in that file.
The custom dispatcher.php file is attached in this message (concrete.zip). Please note that in the custom project, that is really the only file you need to have in the /concrete/ folder, it is otherwise empty!
After this, I could do the centralization configuration in each project's /config/startup.php file:
// Hide "constant already defined" errors when /concrete/config/base.php gets included ini_set('display_errors', 0); // I'm using the latest github version core for this project define('DIR_BASE_CORE', '/dev/php/concrete5/web/concrete'); // From which project I'm serving the static assets define('ASSETS_URL_WEB', '/concrete5/web');
HOWEVER, because of how concrete5 core currently defines ASSETS_URL_WEB, you will end up with a PHP error if you keep that code in your /config/startup.php script. So there's still ONE CENTRALIZED CORE HACK you need to do, you cannot bypass this in any ways and if you don't set up that constant properly, you won't be loading your core css/js/images properly.
<< EDIT 1: The hack provided below is not necessary, see EDIT 1 at the bottom of this message >>
The hack you need to do in the core is for file /concrete/config/base.php. Search for the problematic constant ASSETS_URL_WEB and you find these rows (please note that these rows are NOT together in the same place consequently):
Change BOTH OF THOSE ROWS to this:
And after that you're ready to go using your centralized c5 environments. Please note that if you e.g. want to test out with different versions of c5, you'll need to do the hack mentioned above for each of those cores.
Tested this out with latest c5 github version for installation and running the site.
Hopefully it will help also someone other than me. At least I'm now happily developing under WAMP. :)
Antti / Mainio
EDIT1:
I realized a way you can also do that WITHOUT ANY HACKS to the real core, so here's what you need to add to the config/startup.php before that issue gets fixed in the core:
// Do not display "constant already defined" errors ini_set('display_errors', 0);
This does not affect any other errors because concrete5 error displaying is set AFTER the problematic /concrete/config/base.php is loaded.
for developing on windows I just downloaded an app that made symlinks easy to make and keep track of, cant remember the name of it though.
Well, for now I prefer this one because it's just copying one file to each concrete5 project that already points to the correct location (or I can change it to some different if I want to use different version).
No installing new programs on Windows, no core hacks. Nothing, except copy the one file (and also the startup.php).
-Antti
No installing new programs on Windows, no core hacks. Nothing, except copy the one file (and also the startup.php).
-Antti