Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Oct 8, 2013
2 parents a9abd36 + 1817ff9 commit bc5f5a8
Show file tree
Hide file tree
Showing 41 changed files with 143 additions and 77 deletions.
22 changes: 22 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ The nginx configuration file should contain this code (along with other settings

This assumes that Slim's `index.php` is in the root folder of your project (www root).

#### HipHop Virtual Machine for PHP

Your HipHop Virtual Machine configuration file should contain this code (along with other settings you may need).
Be sure you change the `ServerRoot` setting to point to your Slim app's document root directory.

Server {
SourceRoot = /path/to/public/directory
}

VirtualHost {
* {
Pattern = .*
RewriteRules {
* {
pattern = ^(.*)$
to = index.php/$1
qsa = true
}
}
}
}

#### lighttpd ####

Your lighttpd configuration file should contain this code (along with other settings you may need). This code requires
Expand Down
40 changes: 13 additions & 27 deletions Slim/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down Expand Up @@ -126,35 +126,21 @@ private function __construct($settings = null)
//The IP
$env['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];

/**
* Application paths
*
* This derives two paths: SCRIPT_NAME and PATH_INFO. The SCRIPT_NAME
* is the real, physical path to the application, be it in the root
* directory or a subdirectory of the public document root. The PATH_INFO is the
* virtual path to the requested resource within the application context.
*
* With htaccess, the SCRIPT_NAME will be an absolute path (without file name);
* if not using htaccess, it will also include the file name. If it is "/",
* it is set to an empty string (since it cannot have a trailing slash).
*
* The PATH_INFO will be an absolute path with a leading slash; this will be
* used for application routing.
*/
if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0) {
$env['SCRIPT_NAME'] = $_SERVER['SCRIPT_NAME']; //Without URL rewrite
// Root URI (physical path) and resource URI (virtual path)
$scriptName = str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']); // <-- "/physical/index.php"
$requestUri = $_SERVER['REQUEST_URI']; // <-- "/physical/index.php/virtual?abc=123" or "/physical/virtual?abc=123"
$queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; // <-- "abc=123"
if (strpos($requestUri, $scriptName) === false) {
// With rewriting
$env['SCRIPT_NAME'] = str_replace('/' . basename($scriptName), '', $scriptName);
} else {
$env['SCRIPT_NAME'] = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); //With URL rewrite
// Without rewriting
$env['SCRIPT_NAME'] = $scriptName;
}
$env['PATH_INFO'] = substr_replace($_SERVER['REQUEST_URI'], '', 0, strlen($env['SCRIPT_NAME']));
if (strpos($env['PATH_INFO'], '?') !== false) {
$env['PATH_INFO'] = substr_replace($env['PATH_INFO'], '', strpos($env['PATH_INFO'], '?')); //query string is not removed automatically
}
$env['SCRIPT_NAME'] = rtrim($env['SCRIPT_NAME'], '/');
$env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/');
$env['PATH_INFO'] = '/' . ltrim(str_replace(array($env['SCRIPT_NAME'], '?' . $queryString), '', $requestUri), '/');

//The portion of the request URI following the '?'
$env['QUERY_STRING'] = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
// Query string (without leading "?")
$env['QUERY_STRING'] = $queryString;

//Name of server host that is running the script
$env['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
Expand Down
2 changes: 1 addition & 1 deletion Slim/Exception/Pass.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Exception/Stop.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Helper/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Http/Cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Http/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Http/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/LogWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Middleware/ContentTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
15 changes: 13 additions & 2 deletions Slim/Middleware/Flash.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.2.0
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down Expand Up @@ -45,7 +45,7 @@
* @author Josh Lockhart
* @since 1.6.0
*/
class Flash extends \Slim\Middleware implements \ArrayAccess, \IteratorAggregate
class Flash extends \Slim\Middleware implements \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* @var array
Expand Down Expand Up @@ -198,4 +198,15 @@ public function getIterator()

return new \ArrayIterator($messages);
}

/**
* Countable: Count
*/
public function count()
{
return count($this->getMessages());
}



}
2 changes: 1 addition & 1 deletion Slim/Middleware/MethodOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
3 changes: 2 additions & 1 deletion Slim/Middleware/PrettyExceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down Expand Up @@ -68,6 +68,7 @@ public function call()
} catch (\Exception $e) {
$log = $this->app->getLog(); // Force Slim to append log to env if not already
$env = $this->app->environment();
$env['slim.log'] = $log;
$env['slim.log']->error($e);
$this->app->contentType('text/html');
$this->app->response()->status(500);
Expand Down
4 changes: 2 additions & 2 deletions Slim/Middleware/SessionCookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down Expand Up @@ -153,7 +153,7 @@ protected function saveSession()
$this->settings['httponly']
);
}
session_destroy();
// session_destroy();
}

/********************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion Slim/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.0.0
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
2 changes: 1 addition & 1 deletion Slim/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
10 changes: 6 additions & 4 deletions Slim/Slim.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down Expand Up @@ -49,7 +49,7 @@ class Slim
/**
* @const string
*/
const VERSION = '2.3.2';
const VERSION = '2.3.3';

/**
* @var \Slim\Helper\Set
Expand Down Expand Up @@ -1277,8 +1277,10 @@ public function run()
}
}

//Send body
echo $body;
//Send body, but only if it isn't a HEAD request
if (!$this->request->isHead()) {
echo $body;
}

restore_error_handler();
}
Expand Down
2 changes: 1 addition & 1 deletion Slim/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
* @package Slim
*
* MIT LICENSE
Expand Down
9 changes: 8 additions & 1 deletion tests/EnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
*
* MIT LICENSE
*
Expand Down Expand Up @@ -43,6 +43,8 @@ class EnvironmentTest extends PHPUnit_Framework_TestCase
*/
public function setUp()
{
$_SERVER['DOCUMENT_ROOT'] = '/var/www';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/foo/index.php';
$_SERVER['SERVER_NAME'] = 'slim';
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['SCRIPT_NAME'] = '/foo/index.php';
Expand Down Expand Up @@ -106,6 +108,7 @@ public function testParsesPathsWithoutUrlRewriteInSubdirectory()
*/
public function testParsesPathsWithoutUrlRewriteInRootDirectory()
{
$_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
$_SERVER['REQUEST_URI'] = '/index.php/bar/xyz';
$_SERVER['SCRIPT_NAME'] = '/index.php';
$env = \Slim\Environment::getInstance(true);
Expand All @@ -123,6 +126,7 @@ public function testParsesPathsWithoutUrlRewriteInRootDirectory()
*/
public function testParsesPathsWithoutUrlRewriteInRootDirectoryForAppRootUri()
{
$_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
$_SERVER['REQUEST_URI'] = '/index.php';
$_SERVER['SCRIPT_NAME'] = '/index.php';
unset($_SERVER['PATH_INFO']);
Expand Down Expand Up @@ -157,6 +161,7 @@ public function testParsesPathsWithUrlRewriteInSubdirectory()
*/
public function testParsesPathsWithUrlRewriteInRootDirectory()
{
$_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
$_SERVER['SCRIPT_NAME'] = '/index.php';
$_SERVER['REQUEST_URI'] = '/bar/xyz';
unset($_SERVER['PATH_INFO']);
Expand All @@ -175,6 +180,7 @@ public function testParsesPathsWithUrlRewriteInRootDirectory()
*/
public function testParsesPathsWithUrlRewriteInRootDirectoryForAppRootUri()
{
$_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
$_SERVER['REQUEST_URI'] = '/';
$_SERVER['SCRIPT_NAME'] = '/index.php';
unset($_SERVER['PATH_INFO']);
Expand Down Expand Up @@ -224,6 +230,7 @@ public function testRemovesQueryStringFromPathInfo()
*/
public function testPathInfoRetainsUrlEncodedCharacters()
{
$_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
$_SERVER['SCRIPT_NAME'] = '/index.php';
$_SERVER['REQUEST_URI'] = '/foo/%23bar'; //<-- URL-encoded "#bar"
$env = \Slim\Environment::getInstance(true);
Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/SetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.3.2
* @version 2.3.3
*
* MIT LICENSE
*
Expand Down
Loading

0 comments on commit bc5f5a8

Please sign in to comment.