class.config.php - example...?

329 views
Skip to first unread message

Kristian Tørning

unread,
Nov 23, 2011, 1:50:35 PM11/23/11
to Simple PHP Framework
Hi,

I am having problems understanding the class.config.php (https://
github.com/tylerhall/simple-php-framework/blob/master/includes/
class.config.php).

I want to work using my laptop as a staging/development environment
(running XAMPP). I would like to develop locally and then "publish" to
a standard hosted www.one.com domain - how do you do that?

In the config we have:

private $productionServers = array('/^your-domain\.com$/');
private $stagingServers = array();
private $localServers = array();
etc. etc.

So, how do you do it? Can someone running a similar setup share a
class.config.php with dummy/fake data...? What software do you use to
move the files from staging to production? Just ftp - or is there a
smarter option?

Can someone explain how to do this, as if I was 5 years old...?

Kind regards

Kristian


Max Fierke

unread,
Nov 23, 2011, 5:47:00 PM11/23/11
to simple-php...@googlegroups.com
The arrays contain regular expressions to detect specific domains that the site is running on. If a regular expression matches the host name of the requested page, it uses the settings for that.

Example:

private $productionServers = array('/^maxfierke\.com$/'); // maxfierke.com is my live site that I upload everything to.
private $localServers = array('/^maxfierke\.dev$/'); // maxfierke.dev is a record in my local /etc/hosts file that points to localhost. If you don't know what a hosts file is, just use localhost

If I am accessing my site from http://www.maxfierke.com/about.php, SPF will use the production database settings, web root settings, etc.

If I am accessing my site from http://www.maxfierke.dev/about.php, SPF will use the local settings.

This method helps alleviate the inconveniences of having to change all your settings any time you want to run your code elsewhere. With this, you merely have to add the settings once for each domain/host name, and you can upload the same config file to all servers and SPF will decide which settings to use, and it should work. It will not deploy your code anywhere or anything like that.

Kristian Tørning

unread,
Nov 24, 2011, 4:13:07 PM11/24/11
to Simple PHP Framework
Hi,

Thank you very much. This was exactly what I needed! :-)

Kind regards

Kristian

Juan Pablo Herrera

unread,
Nov 29, 2011, 5:58:17 AM11/29/11
to simple-php...@googlegroups.com
Hi!
Thanks for your explain.

For this example:

private $productionServers = array('/^domain\.com$/');

If I am accessing my site form http://www.domain.com the result is:

Where am I?
You need to setup your server names in class.config.php
$_SERVER['HTTP_HOST'] reported www.domain.com

Well, if i am accessing for http://domain.com the result is OK.

How I can fix this?

Regards,
JP

Tyler Hall

unread,
Nov 29, 2011, 9:06:05 AM11/29/11
to simple-php...@googlegroups.com
Remove the caret from the beginning of the regular expression so it doesn't match the beginning. i.e.

private $productionServers = array('/domain\.com$/');

Or, if you want to be more specific, you could do

private $productionServers = array('/^(www\.)?domain\.com$/');

(Haven't tested that last one.)

Tyler

> --
> You received this message because you are subscribed to the Google Groups "Simple PHP Framework" group.
> To post to this group, send email to simple-php...@googlegroups.com.
> To unsubscribe from this group, send email to simple-php-frame...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-php-framework?hl=en.
>

Juan Pablo Herrera

unread,
Nov 29, 2011, 9:11:25 AM11/29/11
to simple-php...@googlegroups.com
Thanks Tyler.
I used:

private $productionServers = array('/domain\.com$/');

Regards,
JP

Reply all
Reply to author
Forward
0 new messages