Development

/branches/1.0/lib/symfony.php

You must first sign up to be able to contribute.

root/branches/1.0/lib/symfony.php

Revision 7791, 4.5 kB (checked in by fabien, 4 years ago)

updated Sean Kerr email address

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  * (c) 2004-2006 Sean Kerr <sean@code-box.org>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 /**
13  * Pre-initialization script.
14  *
15  * @package    symfony
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @author     Sean Kerr <sean@code-box.org>
18  * @version    SVN: $Id$
19  */
20
21 $sf_symfony_lib_dir = sfConfig::get('sf_symfony_lib_dir');
22 if (!sfConfig::get('sf_in_bootstrap'))
23 {
24   // YAML support
25   require_once($sf_symfony_lib_dir.'/util/sfYaml.class.php');
26
27   // cache support
28   require_once($sf_symfony_lib_dir.'/cache/sfCache.class.php');
29   require_once($sf_symfony_lib_dir.'/cache/sfFileCache.class.php');
30
31   // config support
32   require_once($sf_symfony_lib_dir.'/config/sfConfigCache.class.php');
33   require_once($sf_symfony_lib_dir.'/config/sfConfigHandler.class.php');
34   require_once($sf_symfony_lib_dir.'/config/sfYamlConfigHandler.class.php');
35   require_once($sf_symfony_lib_dir.'/config/sfAutoloadConfigHandler.class.php');
36   require_once($sf_symfony_lib_dir.'/config/sfRootConfigHandler.class.php');
37   require_once($sf_symfony_lib_dir.'/config/sfLoader.class.php');
38
39   // basic exception classes
40   require_once($sf_symfony_lib_dir.'/exception/sfException.class.php');
41   require_once($sf_symfony_lib_dir.'/exception/sfAutoloadException.class.php');
42   require_once($sf_symfony_lib_dir.'/exception/sfCacheException.class.php');
43   require_once($sf_symfony_lib_dir.'/exception/sfConfigurationException.class.php');
44   require_once($sf_symfony_lib_dir.'/exception/sfParseException.class.php');
45
46   // utils
47   require_once($sf_symfony_lib_dir.'/util/sfParameterHolder.class.php');
48 }
49 else
50 {
51   require_once($sf_symfony_lib_dir.'/config/sfConfigCache.class.php');
52 }
53
54 // autoloading
55 sfCore::initAutoload();
56
57 try
58 {
59   $configCache = sfConfigCache::getInstance();
60
61   // force setting default timezone if not set
62   if (function_exists('date_default_timezone_get'))
63   {
64     if ($default_timezone = sfConfig::get('sf_default_timezone'))
65     {
66       date_default_timezone_set($default_timezone);
67     }
68     else if (sfConfig::get('sf_force_default_timezone', true))
69     {
70       date_default_timezone_set(@date_default_timezone_get());
71     }
72   }
73
74   // get config instance
75   $sf_app_config_dir_name = sfConfig::get('sf_app_config_dir_name');
76
77   $sf_debug = sfConfig::get('sf_debug');
78
79   // load timer classes if in debug mode
80   if ($sf_debug)
81   {
82     require_once($sf_symfony_lib_dir.'/debug/sfTimerManager.class.php');
83     require_once($sf_symfony_lib_dir.'/debug/sfTimer.class.php');
84   }
85
86   // load base settings
87   include($configCache->checkConfig($sf_app_config_dir_name.'/settings.yml'));
88   if (sfConfig::get('sf_logging_enabled', true))
89   {
90     include($configCache->checkConfig($sf_app_config_dir_name.'/logging.yml'));
91   }
92   if ($file = $configCache->checkConfig($sf_app_config_dir_name.'/app.yml', true))
93   {
94     include($file);
95   }
96   if (sfConfig::get('sf_i18n'))
97   {
98     include($configCache->checkConfig($sf_app_config_dir_name.'/i18n.yml'));
99   }
100
101   // add autoloading callables
102   foreach ((array) sfConfig::get('sf_autoloading_functions', array()) as $callable)
103   {
104     sfCore::addAutoloadCallable($callable);
105   }
106
107   // error settings
108   ini_set('display_errors', $sf_debug ? 'on' : 'off');
109   error_reporting(sfConfig::get('sf_error_reporting'));
110
111   // create bootstrap file for next time
112   if (!sfConfig::get('sf_in_bootstrap') && !$sf_debug && !sfConfig::get('sf_test'))
113   {
114     $configCache->checkConfig($sf_app_config_dir_name.'/bootstrap_compile.yml');
115   }
116
117   // required core classes for the framework
118   // create a temp var to avoid substitution during compilation
119   if (!$sf_debug && !sfConfig::get('sf_test'))
120   {
121     $core_classes = $sf_app_config_dir_name.'/core_compile.yml';
122     $configCache->import($core_classes, false);
123   }
124
125   $configCache->import($sf_app_config_dir_name.'/php.yml', false);
126   $configCache->import($sf_app_config_dir_name.'/routing.yml', false);
127
128   // include all config.php from plugins
129   sfLoader::loadPluginConfig();
130
131   // compress output
132   ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
133 }
134 catch (sfException $e)
135 {
136   $e->printStackTrace();
137 }
138 catch (Exception $e)
139 {
140   if (sfConfig::get('sf_test'))
141   {
142     throw $e;
143   }
144
145   try
146   {
147     // wrap non symfony exceptions
148     $sfException = new sfException();
149     $sfException->printStackTrace($e);
150   }
151   catch (Exception $e)
152   {
153     header('HTTP/1.0 500 Internal Server Error');
154   }
155 }
156
Note: See TracBrowser for help on using the browser.