Skip to content

Instantly share code, notes, and snippets.

@designermonkey
Created July 1, 2012 20:39
Show Gist options
  • Save designermonkey/3029532 to your computer and use it in GitHub Desktop.
Save designermonkey/3029532 to your computer and use it in GitHub Desktop.
Proposed Symphony CMS config XML
<?xml version="1.0" encoding="UTF-8"?>
<config:core xmlns:config="http://symphony-cms.com/schemas/config/1.0">
<!--
Environment
Specify the environment of your setup
Environments can be any value, which will be passed through to
a front-end parameter $environment
-->
<environment>production</environment>
<!--
General
Config options that affect the admin and front-end equally
(Grouped some old config options more meaningfully)
-->
<general>
<sitename>Symphony CMS</sitename>
<max-upload-size>5242880</max-upload-size>
</general>
<!--
Symphony
Admin specific config options
-->
<symphony>
<pagination-maximum-rows>20</pagination-maximum-rows>
<lang>en</lang>
<pages-table-nest-children>no</pages-table-nest-children>
<version>2.3</version>
<cookie-prefix>sym-</cookie-prefix>
<session-gc-divider>10</session-gc-divider>
</symphony>
<!--
Public
Front-end specific config options
-->
<public>
<display-event-xml-in-source>no</display-event-xml-in-source>
</public>
<!--
Log
System log parameters
-->
<log>
<archive>1</archive>
<maxsize>102400</maxsize>
</log>
<!--
Database
Connection parameters for the database
-->
<database>
<host>localhost</host>
<port>3306</port>
<user>root</user>
<password>password</password>
<db>symphony</db>
<tbl-prefix>sym_</tbl-prefix>
</database>
<!--
Write Mode
Unix permissions to apply/expect on files and folders
(Grouped old config options more meaningfully)
-->
<write-mode>
<file>0644</file>
<directory>0755</directory>
</write-mode>
<!--
Region
Specify the PHP Date and Time format
-->
<region>
<time-format>H:i:s</time-format>
<date-format>Y/m/d</date-format>
<datetime-separator> </datetime-separator>
<timezone>Europe/London</timezone>
</region>
<!--
Image
Image handling parameters
-->
<image>
<settings env="default">
<cache>1</cache>
<quality>90</quality>
</settings>
</image>
<!--
Email
Symphony email handling parameters
(Grouped old config options more meaningfully)
-->
<email>
<default-gateway>sendmail</default-gateway>
<from-name>Symphony</from-name>
<from-address>noreply@website.com</from-address>
<!-- Should extensions that provide gateways write them here? -->
<smtp>
<host>127.0.0.1</host>
<port>25</port>
<secure>no</secure>
<auth>0</auth>
<username>admin</username>
<password>admin</password>
</smtp>
</email>
</config:core>
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://symphony-cms.com/schemas/configuration/1.0">
<!--
Environment
Specify the environment of your setup
Environments can be any value, which will be passed through to
a front-end parameter $environment
-->
<environment>production</environment>
<!--
General
Config options that affect the admin and front-end equally
(Grouped some old config options more meaningfully)
-->
<general>
<sitename>Symphony CMS</sitename>
<max-upload-size>5242880</max-upload-size>
</general>
<!--
Symphony
Admin specific config options
-->
<symphony>
<pagination-maximum-rows>20</pagination-maximum-rows>
<lang>en</lang>
<pages-table-nest-children>no</pages-table-nest-children>
<version>2.3</version>
<cookie-prefix>sym-</cookie-prefix>
<session-gc-divider>10</session-gc-divider>
</symphony>
<!--
Public
Front-end specific config options
-->
<public>
<display-event-xml-in-source>no</display-event-xml-in-source>
</public>
<!--
Log
System log parameters
-->
<log>
<archive>1</archive>
<maxsize>102400</maxsize>
</log>
<!--
Database
Connection parameters for the database
Example provided for two databases. Note that only some nodes devaite from the default @env
-->
<database>
<host>localhost</host>
<port>3306</port>
<user>root</user>
<password>password</password>
<db>symphony</db>
<tbl-prefix>sym_</tbl-prefix>
</database>
<!--
Write Mode
Unix permissions to apply/expect on files and folders
(Grouped old config options more meaningfully)
-->
<write-mode>
<file>0644</file>
<directory>0755</directory>
</write-mode>
<!--
Region
Specify the PHP Date and Time format
-->
<region>
<time-format>H:i:s</time-format>
<date-format>Y/m/d</date-format>
<datetime-separator> </datetime-separator>
<timezone>Europe/London</timezone>
</region>
<!--
Image
Image handling parameters
-->
<image>
<settings env="default">
<cache>1</cache>
<quality>90</quality>
</settings>
</image>
<!--
Email
Symphony email handling parameters
(Grouped old config options more meaningfully)
-->
<email>
<default-gateway>sendmail</default-gateway>
<from-name>Symphony</from-name>
<from-address>noreply@website.com</from-address>
<!-- Should extensions that provide gateways write them here? -->
<smtp>
<host>127.0.0.1</host>
<port>25</port>
<secure>no</secure>
<auth>0</auth>
<username>admin</username>
<password>admin</password>
</smtp>
</email>
<!--
Extensions
Configuration options for extensions are written here to maintain a tidy config file
Extensions are identified by the @id that they are required to use in the meta xml file
(This section could well be a separate file if decided)
-->
<extensions>
<!-- Even Maintenance Mode is stored here -->
<extension id="maintenance_mode">
<settings env="default">
<enabled>no</enabled>
</settings>
</extension>
<extension id="sitemap">
<settings env="default">
<index-type>index</index-type>
<primary-type>primary</primary-type>
<utilities-type>global</utilities-type>
<exclude-types>hidden, XML, 403, 404</exclude-types>
</settings>
</extension>
<extension id="content_type_mappings">
<settings env="default">
<xml>text/xml; charset=utf-8</xml>
<text>text/plain; charset=utf-8</text>
<css>text/css; charset=utf-8</css>
<json>application/json; charset=utf-8</json>
<csv>'text/csv; charset=utf-8</csv>
</settings>
</extension>
<extension id="client_logo">
<settings env="default">
<path>null</path>
</settings>
</extension>
</extensions>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<config:ext xmlns:config="http://symphony-cms.com/schemas/config/1.0">
<!--
Extensions
Configuration options for extensions are written here to maintain a tidy config file
Extensions are identified by the @id that they are required to use in the meta xml file
(This section could well be a separate file if we want)
-->
<!-- Even Maintenance Mode is stored here -->
<extension id="maintenance_mode">
<enabled>no</enabled>
</extension>
<extension id="sitemap">
<index-type>index</index-type>
<primary-type>primary</primary-type>
<utilities-type>global</utilities-type>
<exclude-types>hidden, XML, 403, 404</exclude-types>
</extension>
<extension id="content_type_mappings">
<xml>text/xml; charset=utf-8</xml>
<text>text/plain; charset=utf-8</text>
<css>text/css; charset=utf-8</css>
<json>application/json; charset=utf-8</json>
<csv>'text/csv; charset=utf-8</csv>
</extension>
<extension id="client_logo">
<path>null</path>
</extension>
</config:ext>
<?xml version="1.0" encoding="UTF-8"?>
<config:local xmlns:config="http://symphony-cms.com/schemas/config/1.0">
<!--
Environment
Specify the environment of your setup locally
Environments can be any value, which will be passed through to
a front-end parameter $environment
-->
<environment>production</environment>
<!--
Database
Connection parameters for the database
Example provided for two databases. Note that only some nodes devaite from the default @env
-->
<database>
<host>localhost</host>
<port>3306</port>
<user>root</user>
<password>password</password>
<db>symphony</db>
<tbl-prefix>sym_</tbl-prefix>
</database>
<!--
Email
Symphony email handling parameters
(Grouped old config options more meaningfully)
-->
<email>
<default-gateway>sendmail</default-gateway>
<from-name>Symphony</from-name>
<from-address>noreply@website.com</from-address>
<!-- Should extensions that provide gateways write them here? -->
<smtp>
<host>127.0.0.1</host>
<port>25</port>
<secure>no</secure>
<auth>0</auth>
<username>admin</username>
<password>admin</password>
</smtp>
</email>
</config:local>
<?xml version="1.0" encoding="UTF-8"?>
<config:routes xmlns="http://symphony-cms.com/schemas/config/1.0">
<!--
Routes
Specify any URL rewriting routes here
The URL Router extension is to be used as an interface for this file
-->
<route>
<from></from>
<to></to>
<force>true</force>
</route>
<redirect>
<from></from>
<to></to>
<http>301</http>
</redirect>
</config:routes>
@nickdunn
Copy link

nickdunn commented Jul 2, 2012

An interesting idea. Questions:

  • are you suggesting always having one single file which contains details for all environments?
  • where would the environment switch go, that says "use default or use live"?
  • when saving values back to the config file, how should Symphony decide which block to persist to (e.g. I edit client_logo on live, does it create a <settings env="live">...` block?

Some of these are addressed in symphonycms/symphonycms#669 where we talk about a separate environment file per config, which allows the defaults to be overridden.

@designermonkey
Copy link
Author

I'm writing up an explanation on the issue relating to config shizzle. A slightly different approach, but one that I think caters for all ideas expressed (in some way).

@designermonkey
Copy link
Author

Thankyou. Answers:

  • Yes. It is cleaner, easier to parse in one file, and easily readable to see the environment differences.
  • There is no real switch. If you have something specified for live then you have provided a URL. The system will check that URL and load any config options it can match against. If you don't want to override the default options, don't specify any environment ones.
  • My idea is to have all environments present on the prefs page, so whatever environment you're in, you could reasonably change any set.

The point is I'm trying to avoid a separate file per environment. I currently do that and it is turning into a nightmare to manage. Change one extensions config in one environment, and you have to remember to duplicate the change. Pain. In. The. Arse. In one file, all blocked together, t becomes really easy to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment