Page 1 of 1

Propel: problem with loading configuration variables

Posted: Tue Nov 14, 2006 10:58 am
by raghavan20
The Propel.php has a public static method to load configuration files into the static variable: $configuration

it uses a include line which will actually load an array from a configuration file which is actually returned.
but this line does not work as expected here in php.net example

Code: Select all

return.php
<?php

$var = 'PHP';

return $var;

?>

noreturn.php
<?php

$var = 'PHP';

?>

testreturns.php
<?php

$foo = include 'return.php';

echo $foo; // prints 'PHP'

$bar = include 'noreturn.php';

echo $bar; // prints 1

?>
the config file

Code: Select all

<?php

// This file generated by Propel convert-props target on Tue Nov 14 16:33:05 2006
// from XML runtime conf file /var/www/test/bookstore/runtime-conf.xml [EDITED]
return array (
  'log' => 
  array (
    'ident' => 'propel-bookstore',
    'level' => '7',
  ));

?>
the line that calls the following code

Code: Select all

Propel::init( '/var/www/test/bookstore/build/conf/bookstore-conf.php' );
the actual code in Propel.php file

Code: Select all

public static function configure($configFile)
	{
		self::$configuration = include($configFile);
		
		if (self::$configuration === false) {
			throw new PropelException("Unable to open configuration file: " . var_export($configFile, true));
		}
	}
so in the above function, configFile is the path to the configuration file.
when it executes the include line, it does not move to the next line in the function and no error is reported as well.

i do see that line can be

Code: Select all

include $configFile instead of include($configFile) and I have tried the other format but it does not work.
Any ideas why return is not working...

Re: Propel: problem with loading configuration variables

Posted: Tue Nov 14, 2006 11:09 am
by volka
raghavan20 wrote:$foo = include 'return.php';

echo $foo; // prints 'PHP'
And that's what you want. The version with the return statement is the one you want to use.
But you don't
raghavan20 wrote:the config file

Code: Select all

<?php

// This file generated by Propel convert-props target on Tue Nov 14 16:33:05 2006
// from XML runtime conf file /var/www/test/bookstore/runtime-conf.xml
$configArray = array (
  'log' => 
  array (
    'ident' => 'propel-bookstore',
    'level' => '7',
  ));

?>
there's no return $configArray. Why?

Posted: Tue Nov 14, 2006 11:12 am
by raghavan20
sorry, i was doing a workaround earlier and now i have put the original configuration file in...thanks volka