Skip to content

Instantly share code, notes, and snippets.

@mattkatz
Created December 27, 2011 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattkatz/1525004 to your computer and use it in GitHub Desktop.
Save mattkatz/1525004 to your computer and use it in GitHub Desktop.
Slim not logging or routing
#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>
<?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