Created
December 27, 2011 20:13
-
-
Save mattkatz/1525004 to your computer and use it in GitHub Desktop.
Slim not logging or routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#RewriteEngine On | |
# Some hosts may require you to use the `RewriteBase` directive. | |
# If you need to use the `RewriteBase` directive, it should be the | |
# absolute physical path to the directory that contains this htaccess file. | |
# | |
#RewriteBase / | |
#RewriteCond %{REQUEST_FILENAME} !-f | |
#RewriteRule ^(.*)$ index.php [QSA,L] | |
## good hosts have all this on already | |
#DirectoryIndex index.php index.html | |
#Options +FollowSymLinks | |
#Options -Indexes | |
## for clean urls, uncomment all below lines | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} -f [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^(.+) - [PT,L] | |
RewriteRule ^(.*) index.php | |
#RewriteCond %{HTTP:Authorization} !^$ | |
#RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}] | |
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Step 1: Require the Slim PHP 5 Framework | |
*/ | |
require 'Slim/Slim.php'; | |
/** | |
* Step 2: Instantiate the Slim application | |
*/ | |
$app = new Slim( array( | |
'log.enable' => true, | |
'log.path' => './logs', | |
'log.level' => 4, | |
'debug' =>true | |
) | |
); | |
$app->get('/hi', function(){ | |
echo 'This gets a 404!'; | |
}); | |
//GET route | |
$app->get('/', function () { | |
$template = <<<EOT | |
this works! | |
EOT; | |
echo $template; | |
}); | |
//GET route doesn't work | |
$app->get('/hello/:name',function($name){ | |
echo "Hello, $name"; | |
}); | |
//doesn't work 404 | |
$app->get('/hello',function($name){ | |
echo "hello there!"; | |
}); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment