Skip to content

Commit

Permalink
Merge branch '0.5' of git@github.com:sofadesign/limonade into 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrice Luraine committed Jan 19, 2010
2 parents 07336c6 + d51c58a commit 504a3c0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
3 changes: 0 additions & 3 deletions TODO
Expand Up @@ -24,16 +24,13 @@ autoload_controller(['function']);
- improving unregister_globals
- to avoid predefined variables (_SERVER, _REQUEST...) deletion
- to handle session globals by calling unregister_globals('_SESSION') after session start
- implements stop_and_exit() call with register_shutdown_function
- deleting deprecated ['HTTP_SERVER_VARS'], ['HTTP_GET_VARS']... (<http://www.php.net/manual/fr/reserved.variables.post.php>...)
- implement user agent detection option in routing
- params function should be singular like option ?
- adding a debug() helper
- new redirect_to (support for https)
- add header X-Limonade-PHP: (lim version name) or X-Powered-By: LimonadePHP… ; (cosmetic ;-)
- use array_walk_recursive for unregister_globals
- add a simple helper for benchmarking (execution time / memory)
- adding gzip option (http://fr.php.net/manual/en/zlib.configuration.php#ini.zlib.output-compression)
- simple form helper with XSS/CSRF protection
- remove examples/ and move it in an external depot
- public API documentation:
Expand Down
3 changes: 3 additions & 0 deletions examples/example02/index.php
Expand Up @@ -130,6 +130,9 @@ function html_my_layout($vars){ extract($vars);?>
</p>
</body>
</html>
<!--
<?php print_r(benchmark()); ?>
-->
<?}


Expand Down
34 changes: 31 additions & 3 deletions lib/limonade.php
Expand Up @@ -327,16 +327,27 @@ function run($env = null)
option('debug', true);
option('session', LIM_SESSION_NAME); // true, false or the name of your session
option('encoding', 'utf-8');
option('gzip', false);
option('x-sendfile', 0); // 0: disabled,
// X-SENDFILE: for Apache and Lighttpd v. >= 1.5,
// X-LIGHTTPD-SEND-FILE: for Apache and Lighttpd v. < 1.5

# 1. Set error handling
# 1. Set handlers
# 1.1 Set error handling
ini_set('display_errors', 1);
set_error_handler('error_handler_dispatcher', E_ALL ^ E_NOTICE);

# 1.2 Register shutdown function
register_shutdown_function('stop_and_exit');

# 2. Set user configuration
call_if_exists('configure');

# 2.1 Set gzip compression if defined
if(is_bool(option('gzip')) && option('gzip'))
{
ini_set('zlib.output_compression', '1');
}

# 3. Loading libs
require_once_dir(option('lib_dir'));
Expand Down Expand Up @@ -390,7 +401,6 @@ function route_missing($request_method, $request_uri)
{
echo after(error_notices_render() . $output);
}
stop_and_exit();
}
else halt(SERVER_ERROR, "Routing error: undefined function '{$route['function']}'", $route);
}
Expand Down Expand Up @@ -623,7 +633,6 @@ function error_handler_dispatcher($errno, $errstr, $errfile, $errline)
}
}
echo error_default_handler($errno, $errstr, $errfile, $errline);
stop_and_exit();
}
}

Expand Down Expand Up @@ -1689,6 +1698,25 @@ function end_content_for()
content_for();
}

/**
* Shows current memory and execution time of the application.
*
* @access public
* @return array
*/
function benchmark()
{
$current_mem_usage = memory_get_usage();
$execution_time = microtime() - LIM_START_MICROTIME;

return array(
'current_memory' => $current_mem_usage,
'start_memory' => LIM_START_MEMORY,
'average_memory' => (LIM_START_MEMORY + $current_mem_usage) / 2,
'execution_time' => $execution_time
);
}




Expand Down

0 comments on commit 504a3c0

Please sign in to comment.