Development

/tags/RELEASE_0_6_1/lib/symfony.php

You must first sign up to be able to contribute.

root/tags/RELEASE_0_6_1/lib/symfony.php

Revision 843, 5.3 kB (checked in by fabien, 3 years ago)

removed the cache cleaning process in debug mode
better config cache system (sith inheritance)
debug mode is now a lot faster
removed param parameter from config cache handler (not needed anymore)
configuration files can now be optionals
config handlers must now have config/ prefix for main configuration files
removed uneeded default configuration files

  • 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.
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 <skerr@mojavi.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   if (!function_exists('syck_load'))
26   {
27     require_once($sf_symfony_lib_dir.'/util/Spyc.class.php');
28   }
29   require_once($sf_symfony_lib_dir.'/util/sfYaml.class.php');
30
31   // cache support
32   require_once($sf_symfony_lib_dir.'/cache/sfCache.class.php');
33   require_once($sf_symfony_lib_dir.'/cache/sfFileCache.class.php');
34
35   // config support
36   require_once($sf_symfony_lib_dir.'/config/sfConfigCache.class.php');
37   require_once($sf_symfony_lib_dir.'/config/sfConfigHandler.class.php');
38   require_once($sf_symfony_lib_dir.'/config/sfYamlConfigHandler.class.php');
39   require_once($sf_symfony_lib_dir.'/config/sfAutoloadConfigHandler.class.php');
40   require_once($sf_symfony_lib_dir.'/config/sfRootConfigHandler.class.php');
41
42   // basic exception classes
43   require_once($sf_symfony_lib_dir.'/exception/sfException.class.php');
44   require_once($sf_symfony_lib_dir.'/exception/sfAutoloadException.class.php');
45   require_once($sf_symfony_lib_dir.'/exception/sfCacheException.class.php');
46   require_once($sf_symfony_lib_dir.'/exception/sfConfigurationException.class.php');
47   require_once($sf_symfony_lib_dir.'/exception/sfParseException.class.php');
48
49   // utils
50   require_once($sf_symfony_lib_dir.'/util/sfParameterHolder.class.php');
51 }
52 else
53 {
54   require_once($sf_symfony_lib_dir.'/config/sfConfigCache.class.php');
55 }
56
57 /**
58  * Handles autoloading of classes that have been specified in autoload.yml.
59  *
60  * @param string A class name.
61  *
62  * @return void
63  */
64 if (!function_exists('__autoload'))
65 {
66   function __autoload($class)
67   {
68     static $loaded;
69
70     if (!$loaded)
71     {
72       // load the list of autoload classes
73       include_once(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/autoload.yml'));
74
75       $loaded = true;
76     }
77
78     $classes = sfConfig::get('sf_class_autoload', array());
79     if (!isset($classes[$class]))
80     {
81       if (sfContext::hasInstance())
82       {
83         // see if the file exists in the current module lib directory
84         // must be in a module context
85         $current_module = sfContext::getInstance()->getModuleName();
86         if ($current_module)
87         {
88           $module_lib = sfConfig::get('sf_app_module_dir').'/'.$current_module.'/'.sfConfig::get('sf_app_module_lib_dir_name').'/'.$class.'.class.php';
89           if (is_readable($module_lib))
90           {
91             require_once($module_lib);
92
93             return;
94           }
95         }
96       }
97
98       // unspecified class
99       $error = sprintf('Autoloading of class "%s" failed. Try to clear the symfony cache and refresh. [err0003]', $class);
100       $e = new sfAutoloadException($error);
101
102       $e->printStackTrace();
103     }
104     else
105     {
106       // class exists, let's include it
107       require_once($classes[$class]);
108     }
109   }
110 }
111
112 try
113 {
114   $configCache = sfConfigCache::getInstance();
115
116   ini_set('unserialize_callback_func', '__autoload');
117
118   // force setting default timezone if not set
119   if (function_exists('date_default_timezone_get'))
120   {
121     if ($default_timezone = sfConfig::get('sf_default_timezone'))
122     {
123       date_default_timezone_set($default_timezone);
124     }
125     else if (sfConfig::get('sf_force_default_timezone', true))
126     {
127       date_default_timezone_set(@date_default_timezone_get());
128     }
129   }
130
131   // get config instance
132   $sf_app_config_dir_name = sfConfig::get('sf_app_config_dir_name');
133
134   $sf_debug = sfConfig::get('sf_debug');
135
136   // load base settings
137   include($configCache->checkConfig($sf_app_config_dir_name.'/logging.yml'));
138   $configCache->import($sf_app_config_dir_name.'/php.yml');
139   include($configCache->checkConfig($sf_app_config_dir_name.'/settings.yml'));
140   include($configCache->checkConfig($sf_app_config_dir_name.'/app.yml'));
141
142   // create bootstrap file for next time
143   if (!sfConfig::get('sf_in_bootstrap') && !$sf_debug && !sfConfig::get('sf_test'))
144   {
145     $configCache->checkConfig($sf_app_config_dir_name.'/bootstrap_compile.yml');
146   }
147
148   // set exception format
149   sfException::setFormat(isset($_SERVER['HTTP_HOST']) ? 'html' : 'plain');
150
151   // error settings
152   ini_set('display_errors', $sf_debug ? 'on' : 'off');
153   error_reporting(sfConfig::get('sf_error_reporting'));
154
155   // compress output
156   ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
157
158 /*
159   if (sfConfig::get('sf_logging_active'))
160   {
161     set_error_handler(array('sfLogger', 'errorHandler'));
162   }
163 */
164
165   // required core classes for the framework
166   // create a temp var to avoid substitution during compilation
167   if (!$sf_debug && !sfConfig::get('sf_test'))
168   {
169     $core_classes = $sf_app_config_dir_name.'/core_compile.yml';
170     $configCache->import($core_classes);
171   }
172
173   $configCache->import($sf_app_config_dir_name.'/routing.yml');
174 }
175 catch (sfException $e)
176 {
177   $e->printStackTrace();
178 }
179 catch (Exception $e)
180 {
181   // unknown exception
182   $e = new sfException($e->getMessage());
183
184   $e->printStackTrace();
185 }
186
187 ?>
Note: See TracBrowser for help on using the browser.