Skip to content
Browse files

Fixing dir structure

  • Loading branch information...
1 parent 3c325b6 commit e8e63a2d2540e1ca37b253b02e07768b5fd42e61 @jesalg committed May 4, 2012
Showing with 2 additions and 7,636 deletions.
  1. 0 {Slim/codeguy-Slim-aa7e919 → }/.htaccess
  2. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Environment.php
  3. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Exception/Pass.php
  4. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Exception/RequestSlash.php
  5. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Exception/Stop.php
  6. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Http/Headers.php
  7. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Http/Request.php
  8. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Http/Response.php
  9. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Http/Util.php
  10. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Log.php
  11. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/LogFileWriter.php
  12. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Middleware.php
  13. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Middleware/ContentTypes.php
  14. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Middleware/Flash.php
  15. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Middleware/MethodOverride.php
  16. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Middleware/PrettyExceptions.php
  17. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Middleware/SessionCookie.php
  18. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Route.php
  19. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Router.php
  20. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/Slim.php
  21. 0 Slim/{codeguy-Slim-aa7e919 → }/Slim/View.php
  22. +0 −19 Slim/codeguy-Slim-aa7e919/LICENSE
  23. +0 −163 Slim/codeguy-Slim-aa7e919/README.markdown
  24. +0 −21 Slim/codeguy-Slim-aa7e919/composer.json
  25. +0 −12 Slim/codeguy-Slim-aa7e919/docs/caching-etag.markdown
  26. +0 −11 Slim/codeguy-Slim-aa7e919/docs/caching-expires.markdown
  27. +0 −10 Slim/codeguy-Slim-aa7e919/docs/caching-last-modified.markdown
  28. +0 −9 Slim/codeguy-Slim-aa7e919/docs/caching.markdown
  29. +0 −56 Slim/codeguy-Slim-aa7e919/docs/environment.markdown
  30. +0 −19 Slim/codeguy-Slim-aa7e919/docs/errors-debug.markdown
  31. +0 −29 Slim/codeguy-Slim-aa7e919/docs/errors-error-handler.markdown
  32. +0 −35 Slim/codeguy-Slim-aa7e919/docs/errors-notfound-handler.markdown
  33. +0 −18 Slim/codeguy-Slim-aa7e919/docs/errors-output.markdown
  34. +0 −3 Slim/codeguy-Slim-aa7e919/docs/errors-reporting.markdown
  35. +0 −7 Slim/codeguy-Slim-aa7e919/docs/errors.markdown
  36. +0 −25 Slim/codeguy-Slim-aa7e919/docs/flash.markdown
  37. +0 −10 Slim/codeguy-Slim-aa7e919/docs/hooks-custom.markdown
  38. +0 −21 Slim/codeguy-Slim-aa7e919/docs/hooks-default.markdown
  39. +0 −33 Slim/codeguy-Slim-aa7e919/docs/hooks-usage.markdown
  40. +0 −7 Slim/codeguy-Slim-aa7e919/docs/hooks.markdown
  41. +0 −144 Slim/codeguy-Slim-aa7e919/docs/index.txt
  42. +0 −11 Slim/codeguy-Slim-aa7e919/docs/instantiation.markdown
  43. +0 −104 Slim/codeguy-Slim-aa7e919/docs/logging.markdown
  44. +0 −28 Slim/codeguy-Slim-aa7e919/docs/middleware-add.markdown
  45. +0 −36 Slim/codeguy-Slim-aa7e919/docs/middleware-architecture.markdown
  46. +0 −11 Slim/codeguy-Slim-aa7e919/docs/middleware-implementation.markdown
  47. +0 −3 Slim/codeguy-Slim-aa7e919/docs/middleware.markdown
  48. +0 −54 Slim/codeguy-Slim-aa7e919/docs/modes.markdown
  49. +0 −58 Slim/codeguy-Slim-aa7e919/docs/names-and-scopes.markdown
  50. +0 −24 Slim/codeguy-Slim-aa7e919/docs/request-cookies.markdown
  51. +0 −15 Slim/codeguy-Slim-aa7e919/docs/request-headers.markdown
  52. +0 −46 Slim/codeguy-Slim-aa7e919/docs/request-helpers.markdown
  53. +0 −27 Slim/codeguy-Slim-aa7e919/docs/request-method.markdown
  54. +0 −24 Slim/codeguy-Slim-aa7e919/docs/request-parameters.markdown
  55. +0 −19 Slim/codeguy-Slim-aa7e919/docs/request-paths.markdown
  56. +0 −8 Slim/codeguy-Slim-aa7e919/docs/request-xhr.markdown
  57. +0 −7 Slim/codeguy-Slim-aa7e919/docs/request.markdown
  58. +0 −16 Slim/codeguy-Slim-aa7e919/docs/response-body.markdown
  59. +0 −47 Slim/codeguy-Slim-aa7e919/docs/response-cookies.markdown
  60. +0 −15 Slim/codeguy-Slim-aa7e919/docs/response-header.markdown
  61. +0 −52 Slim/codeguy-Slim-aa7e919/docs/response-helpers.markdown
  62. +0 −9 Slim/codeguy-Slim-aa7e919/docs/response-status.markdown
  63. +0 −9 Slim/codeguy-Slim-aa7e919/docs/response.markdown
  64. +0 −30 Slim/codeguy-Slim-aa7e919/docs/routing-conditions.markdown
  65. +0 −29 Slim/codeguy-Slim-aa7e919/docs/routing-custom.markdown
  66. +0 −32 Slim/codeguy-Slim-aa7e919/docs/routing-delete.markdown
  67. +0 −11 Slim/codeguy-Slim-aa7e919/docs/routing-generic.markdown
  68. +0 −20 Slim/codeguy-Slim-aa7e919/docs/routing-get.markdown
  69. +0 −22 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-halt.markdown
  70. +0 −13 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-pass.markdown
  71. +0 −19 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-redirect.markdown
  72. +0 −11 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-stop.markdown
  73. +0 −15 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-urlfor.markdown
  74. +0 −3 Slim/codeguy-Slim-aa7e919/docs/routing-helpers.markdown
  75. +0 −17 Slim/codeguy-Slim-aa7e919/docs/routing-indepth-slashes.markdown
  76. +0 −30 Slim/codeguy-Slim-aa7e919/docs/routing-indepth-with-rewrite.markdown
  77. +0 −11 Slim/codeguy-Slim-aa7e919/docs/routing-indepth-without-rewrite.markdown
  78. +0 −13 Slim/codeguy-Slim-aa7e919/docs/routing-indepth.markdown
  79. +0 −49 Slim/codeguy-Slim-aa7e919/docs/routing-middleware.markdown
  80. +0 −15 Slim/codeguy-Slim-aa7e919/docs/routing-names.markdown
  81. +0 −30 Slim/codeguy-Slim-aa7e919/docs/routing-options.markdown
  82. +0 −40 Slim/codeguy-Slim-aa7e919/docs/routing-parameters.markdown
  83. +0 −20 Slim/codeguy-Slim-aa7e919/docs/routing-post.markdown
  84. +0 −32 Slim/codeguy-Slim-aa7e919/docs/routing-put.markdown
  85. +0 −7 Slim/codeguy-Slim-aa7e919/docs/routing.markdown
  86. +0 −38 Slim/codeguy-Slim-aa7e919/docs/sessions.markdown
  87. +0 −192 Slim/codeguy-Slim-aa7e919/docs/settings.markdown
  88. +0 −7 Slim/codeguy-Slim-aa7e919/docs/system-requirements.markdown
  89. +0 −47 Slim/codeguy-Slim-aa7e919/docs/views-custom.markdown
  90. +0 −31 Slim/codeguy-Slim-aa7e919/docs/views-data.markdown
  91. +0 −32 Slim/codeguy-Slim-aa7e919/docs/views-rendering.markdown
  92. +0 −15 Slim/codeguy-Slim-aa7e919/docs/views-settings.markdown
  93. +0 −43 Slim/codeguy-Slim-aa7e919/docs/views.markdown
  94. +0 −6 Slim/codeguy-Slim-aa7e919/docs/welcome.markdown
  95. +0 −163 Slim/codeguy-Slim-aa7e919/index.php
  96. +0 −340 Slim/codeguy-Slim-aa7e919/tests/EnvironmentTest.php
  97. +0 −7 Slim/codeguy-Slim-aa7e919/tests/Foo.php
  98. +0 −137 Slim/codeguy-Slim-aa7e919/tests/Http/HeadersTest.php
  99. +0 −875 Slim/codeguy-Slim-aa7e919/tests/Http/RequestTest.php
  100. +0 −534 Slim/codeguy-Slim-aa7e919/tests/Http/ResponseTest.php
  101. +0 −352 Slim/codeguy-Slim-aa7e919/tests/Http/UtilTest.php
  102. +0 −49 Slim/codeguy-Slim-aa7e919/tests/LogFileWriterTest.php
  103. +0 −138 Slim/codeguy-Slim-aa7e919/tests/LogTest.php
  104. +0 −157 Slim/codeguy-Slim-aa7e919/tests/Middleware/ContentTypesTest.php
  105. +0 −110 Slim/codeguy-Slim-aa7e919/tests/Middleware/FlashTest.php
  106. +0 −145 Slim/codeguy-Slim-aa7e919/tests/Middleware/MethodOverrideTest.php
  107. +0 −79 Slim/codeguy-Slim-aa7e919/tests/Middleware/PrettyExceptionsTest.php
  108. +0 −110 Slim/codeguy-Slim-aa7e919/tests/Middleware/SessionCookieTest.php
  109. +0 −82 Slim/codeguy-Slim-aa7e919/tests/MiddlewareTest.php
  110. +0 −18 Slim/codeguy-Slim-aa7e919/tests/README
  111. +0 −444 Slim/codeguy-Slim-aa7e919/tests/RouteTest.php
  112. +0 −329 Slim/codeguy-Slim-aa7e919/tests/RouterTest.php
  113. +0 −1,229 Slim/codeguy-Slim-aa7e919/tests/SlimTest.php
  114. +0 −180 Slim/codeguy-Slim-aa7e919/tests/ViewTest.php
  115. +0 −1 Slim/codeguy-Slim-aa7e919/tests/templates/test.php
  116. +2 −2 index.php
View
0 Slim/codeguy-Slim-aa7e919/.htaccess → .htaccess
File renamed without changes.
View
0 ...codeguy-Slim-aa7e919/Slim/Environment.php → Slim/Slim/Environment.php
File renamed without changes.
View
0 ...eguy-Slim-aa7e919/Slim/Exception/Pass.php → Slim/Slim/Exception/Pass.php
File renamed without changes.
View
0 ...m-aa7e919/Slim/Exception/RequestSlash.php → Slim/Slim/Exception/RequestSlash.php
File renamed without changes.
View
0 ...eguy-Slim-aa7e919/Slim/Exception/Stop.php → Slim/Slim/Exception/Stop.php
File renamed without changes.
View
0 ...odeguy-Slim-aa7e919/Slim/Http/Headers.php → Slim/Slim/Http/Headers.php
File renamed without changes.
View
0 ...odeguy-Slim-aa7e919/Slim/Http/Request.php → Slim/Slim/Http/Request.php
File renamed without changes.
View
0 ...deguy-Slim-aa7e919/Slim/Http/Response.php → Slim/Slim/Http/Response.php
File renamed without changes.
View
0 Slim/codeguy-Slim-aa7e919/Slim/Http/Util.php → Slim/Slim/Http/Util.php
File renamed without changes.
View
0 Slim/codeguy-Slim-aa7e919/Slim/Log.php → Slim/Slim/Log.php
File renamed without changes.
View
0 ...deguy-Slim-aa7e919/Slim/LogFileWriter.php → Slim/Slim/LogFileWriter.php
File renamed without changes.
View
0 .../codeguy-Slim-aa7e919/Slim/Middleware.php → Slim/Slim/Middleware.php
File renamed without changes.
View
0 ...-aa7e919/Slim/Middleware/ContentTypes.php → Slim/Slim/Middleware/ContentTypes.php
File renamed without changes.
View
0 ...uy-Slim-aa7e919/Slim/Middleware/Flash.php → Slim/Slim/Middleware/Flash.php
File renamed without changes.
View
0 ...a7e919/Slim/Middleware/MethodOverride.php → Slim/Slim/Middleware/MethodOverride.php
File renamed without changes.
View
0 ...e919/Slim/Middleware/PrettyExceptions.php → Slim/Slim/Middleware/PrettyExceptions.php
File renamed without changes.
View
0 ...aa7e919/Slim/Middleware/SessionCookie.php → Slim/Slim/Middleware/SessionCookie.php
File renamed without changes.
View
0 Slim/codeguy-Slim-aa7e919/Slim/Route.php → Slim/Slim/Route.php
File renamed without changes.
View
0 Slim/codeguy-Slim-aa7e919/Slim/Router.php → Slim/Slim/Router.php
File renamed without changes.
View
0 Slim/codeguy-Slim-aa7e919/Slim/Slim.php → Slim/Slim/Slim.php
File renamed without changes.
View
0 Slim/codeguy-Slim-aa7e919/Slim/View.php → Slim/Slim/View.php
File renamed without changes.
View
19 Slim/codeguy-Slim-aa7e919/LICENSE
@@ -1,19 +0,0 @@
-Copyright (c) 2011 Josh Lockhart
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is furnished
-to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
View
163 Slim/codeguy-Slim-aa7e919/README.markdown
@@ -1,163 +0,0 @@
-# Slim Framework for PHP 5
-
-Slim is a micro framework for PHP 5 that helps you quickly write simple yet powerful RESTful web applications and APIs. Slim is easy to use for both beginners and professionals. Slim favors cleanliness over terseness and common cases over edge cases. Its interface is simple, intuitive, and extensively documented — both online and in the code itself. Thank you for choosing Slim for your next project. I think you're going to love it.
-
-## Features
-
-* Clean and simple [DSL](http://en.wikipedia.org/wiki/Domain-specific_language) for writing powerful web applications
-* HTTP routing
- * Supports all standard and custom HTTP request methods
- * Route parameters and conditions
- * Route redirects
- * Route passing
- * Route halting
- * Route middleware
- * Named routes and `urlFor()` helper
-* Easy configuration
-* Easy templating with custom Views (e.g. Twig, Mustache, Smarty)
-* Flash messaging
-* Signed cookies with AES-256 encryption
-* HTTP caching (ETag and Last-Modified)
-* Logging
-* Error handling
- * Custom Not Found handler
- * Custom Error handler
- * Debugging
-* Built upon the Rack protocol
-* Extensible middleware and hook architecture
-* Supports PHP >= 5.2.0
-
-## "Hello World" application (PHP >= 5.3)
-
-The Slim Framework for PHP 5 supports anonymous functions. This is the preferred method to define Slim application routes. This example assumes you have setup URL rewriting with your web server (see below).
-
-```php
-<?php
-require 'Slim/Slim.php';
-$app = new Slim();
-$app->get('/hello/:name', function ($name) {
- echo "Hello, $name!";
-});
-$app->run();
-```
-
-## "Hello World" application (PHP < 5.3)
-
-If you are running PHP < 5.3, the second argument to the application's `get()` instance method is the name of a callable function instead of an anonymous function. This example assumes you have setup URL rewriting with your web server (see below).
-
-```php
-<?php
-require 'Slim/Slim.php';
-$app = new Slim();
-$app->get('/hello/:name', 'hello');
-function hello($name) {
- echo "Hello, $name!";
-}
-$app->run();
-```
-
-## Get Started
-
-### Install Slim
-
-Download the Slim Framework for PHP 5 and unzip the downloaded file into your virtual host's public directory. Slim will work in a sub-directory, too.
-
-### Setup your webserver
-
-#### Apache
-
-Ensure the `.htaccess` and `index.php` files are in the same public-accessible directory. The `.htaccess` file should contain this code:
-
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^ index.php [QSA,L]
-
-#### Nginx
-
-Your nginx configuration file should contain this code (along with other settings you may need) in your `location` block:
-
- if (!-f $request_filename) {
- rewrite ^ /index.php last;
- }
-
-This assumes that Slim's `index.php` is in the root folder of your project (www root).
-
-#### lighttpd ####
-
-Your lighttpd configuration file should contain this code (along with other settings you may need). This code requires lighttpd >= 1.4.24.
-
- url.rewrite-if-not-file = ("^" => "/index.php")
-
-This assumes that Slim's `index.php` is in the root folder of your project (www root).
-
-### Build Your Application
-
-Your Slim application will be defined in `index.php`. First, `require` the Slim Framework:
-
-```php
-require 'Slim/Slim.php';
-```
-
-Next, initialize the Slim application:
-
-```php
-$app = new Slim();
-```
-
-Next, define your application's routes:
-
-```php
-$app->get('/hello/:name', function ($name) {
- echo "Hello $name";
-});
-```
-
-Finally, run your Slim application:
-
-```php
- $app->run();
-```
-
-For more information about building an application with the Slim Framework, refer to the [official documentation](http://github.com/codeguy/Slim/wiki/Slim-Framework-Documentation).
-
-## Documentation
-
-* [Stable Branch Documentation](http://www.slimframework.com/documentation/stable)
-* [Development Branch Documentation](http://www.slimframework.com/documentation/develop)
-
-## Community
-
-### Forum and Knowledgebase
-
-Visit Slim's official forum and knowledge base at <http://help.slimframework.com> where you can find announcements, chat with fellow Slim users, ask questions, help others, or show off your cool Slim Framework apps.
-
-### Twitter
-
-Follow [@slimphp](http://www.twitter.com/slimphp) on Twitter to receive the very latest news and updates about the framework.
-
-### IRC
-
-You can find me, Josh Lockhart, hanging out in the ##slim chat room during the day. Feel free to say hi, ask questions, or just hang out. If you're on a Mac, check out Colloquy; if you're on a PC, check out mIRC; if you're on Linux, I'm sure you already know what you're doing.
-
-## Resources
-
-Additional resources (ie. custom Views and plugins) are available online in a separate repository.
-
-<https://github.com/codeguy/Slim-Extras>
-
-Here are more links that may also be useful.
-
-* Road Map: <http://github.com/codeguy/Slim/wiki/Road-Map>
-* Source Code: <http://github.com/codeguy/Slim/>
-
-## About the Author
-
-Slim is created and maintained by Josh Lockhart, a web developer by day at [New Media Campaigns](http://www.newmediacampaigns.com), and a [hacker by night](http://github.com/codeguy).
-
-Slim is in active development, and test coverage is continually improving.
-
-## Open Source License
-
-Slim is released under the MIT public license.
-
-<http://www.slimframework.com/license>
View
21 Slim/codeguy-Slim-aa7e919/composer.json
@@ -1,21 +0,0 @@
-{
- "name": "slim/slim",
- "type": "library",
- "description": "Slim Framework, a micro framework for PHP 5",
- "keywords": ["templating","extensions"],
- "homepage": "http://github.com/codeguy/Slim",
- "license": "MIT",
- "authors": [
- {
- "name": "Josh Lockhart",
- "email": "info@joshlockhart.com",
- "homepage": "http://www.joshlockhart.com/"
- }
- ],
- "require": {
- "php": ">=5.2.0"
- },
- "autoload": {
- "psr-0": { "Slim": "Slim/" }
- }
-}
View
12 Slim/codeguy-Slim-aa7e919/docs/caching-etag.markdown
@@ -1,12 +0,0 @@
-# Etag [caching-etag] #
-
-A Slim application provides built-in support for HTTP caching using ETags. An ETag is a unique identifier for a resource URI. When an ETag header is set with the `etag()` method, the HTTP client will send an **If-None-Match** header with each subsequent HTTP request of the same resource URI. If the ETag value for the resource URI matches the **If-None-Match** HTTP request header, the Slim application will return a **304 Not Modified** HTTP response that will prompt the HTTP client to continue using its cache; this also prevents the Slim application from serving the entire markup for the resource URI, saving bandwidth and response time.
-
-Setting an ETag with Slim is very simple. Invoke the `etag()` application method in your route callback, passing it a unique ID as the first and only argument.
-
- $app->get('/foo', function () use ($app) {
- $app->etag('unique-id');
- echo "This will be cached after the initial request!";
- });
-
-That’s it. Make sure the unique ETag ID *is unique for the given resource*. Also make sure the ETag unique ID changes as your resource changes; otherwise, the HTTP client will continue serving its outdated cache.
View
11 Slim/codeguy-Slim-aa7e919/docs/caching-expires.markdown
@@ -1,11 +0,0 @@
-# Expires [caching-expires] #
-
-Used in conjunction with the Slim application's `etag()` or `lastModified()` methods, the `expires()` method sets an `Expires:` header on the HTTP response informing the HTTP client when its client-side cache for the current resource should be considered stale. The HTTP client will continue serving from its client-side cache until the expiration date is reached, at which time the HTTP client will send a conditional GET request to the Slim application.
-
-The `expires()` method accepts one argument: an integer UNIX timestamp, or a string to be parsed with `strtotime()`.
-
- $app->get('/foo', function () use ($app) {
- $app->etag('unique-resource-id');
- $app->expires('+1 week');
- echo "This will be cached client-side for one week";
- });
View
10 Slim/codeguy-Slim-aa7e919/docs/caching-last-modified.markdown
@@ -1,10 +0,0 @@
-# Last-Modified [caching-last-modified] #
-
-A Slim application provides built-in support for HTTP caching using the resource’s last modified date. When you specify a last modified date, Slim tells the HTTP client the date and time the current resource was last modified. The HTTP client will then send a **If-Modified-Since** header with each subsequent HTTP request for the given resource URI. If the last modification date you specify matches the **If-Modified-Since** HTTP request header, the Slim application will return a **304 Not Modified** HTTP response that will prompt the HTTP client to use its cache; this also prevents the Slim application from serving the entire markup for the resource URI saving bandwidth and response time.
-
-Setting a last modified date with Slim is very simple. You only need to invoke the `lastModified()` application instance method in your route callback passing in a UNIX timestamp that represents the last modification date for the given resource. Be sure the `lastModified()` application instance method's timestamp updates along with the resource’s last modification date; otherwise, the browser client will continue serving its outdated cache.
-
- $app->get('/foo', function () use ($app) {
- $app->lastModified(1286139652);
- echo "This will be cached after the initial request!";
- });
View
9 Slim/codeguy-Slim-aa7e919/docs/caching.markdown
@@ -1,9 +0,0 @@
-# HTTP Caching [caching] #
-
-A Slim application provides built-in support for HTTP caching with its `etag()`, `lastModified()`, and `expires()` instance methods. It is best to use _one_ of `etag()` or `lastModified()` — in conjunction with `expires()` — per route; never use _both_ `etag()` and `lastModified()` together in the same route callback.
-
-The `etag()` and `lastModified()` methods should be invoked in a route callback *before* other code; this allows Slim to check conditional GET requests _before_ processing the route callback's remaining code.
-
-Both `etag()` and `lastModified()` instruct the HTTP client to store the resource response in a client-side cache. The `expires()` method indicates to the HTTP client when the client-side cache should be considered stale.
-
-More details for each method are below.
View
56 Slim/codeguy-Slim-aa7e919/docs/environment.markdown
@@ -1,56 +0,0 @@
-# The Environment [environment] #
-
-The Slim Framework implements a derivation of the [Rack protocol](http://rack.rubyforge.org/doc/files/SPEC.html). When you instantiate a Slim application, it immediately inspects the `$_SERVER` superglobal and derives a set of environment variables that dictate application behavior.
-
-## What is the Environment? ##
-
-A Slim application's "environment" is an associative array of settings that are parsed once and made accessible to the Slim application and its middleware. You are free to modify the environment variables during runtime; changes will propagate immediately throughout the application.
-
-When you instantiate a Slim application, the environment variables are derived from the `$_SERVER` superglobal; you do not need to set these yourself. However, you are free to modify or supplement these variables in [Slim middleware](#middleware).
-
-These variables are fundamental to determining how your Slim application runs: the resource URI, the HTTP method, the HTTP request body, the URL query parameters, error output, and more. Middleware, described later, gives you the power to — among other things — manipulate environment variables before and/or after the Slim application is run.
-
-## Environment Variables ##
-
-The following text respectfully borrows the same information originally available at <http://rack.rubyforge.org/doc/files/SPEC.html>. The environment array **must** include these variables:
-
-REQUEST_METHOD
-: The HTTP request method. This is required and may never be an empty string.
-
-SCRIPT_NAME
-: The initial portion of the request URI's "path" that corresponds to the physical directory in which the Slim application is installed --- so that the application knows its virtual "location". This may be an empty string if the application is installed in the top-level of the public document root directory. This will never have a trailing slash.
-
-PATH_INFO
-: The remaining portion of the request URI's "path" that determines the "virtual" location of the HTTP request's target resource within the Slim application context. This will always have a leading slash; it may or may not have a trailing slash.
-
-QUERY_STRING
-: The part of the HTTP request's URI after, but not including, the "?". This is required but may be an empty string.
-
-SERVER_NAME
-: When combined with **SCRIPT\_NAME** and **PATH\_INFO**, this can be used to create a fully qualified URL to an application resource. However, if **HTTP_HOST** is present, that should be used instead of this. This is required and may never be an empty string.
-
-SERVER_PORT
-: When combined with **SCRIPT\_NAME** and **PATH\_INFO**, this can be used to create a fully qualified URL to any application resource. This is required and may never be an empty string.
-
-HTTP_*
-: Variables matching the HTTP request headers sent by the client. The existence of these variables correspond with those sent in the current HTTP request.
-
-slim.url_scheme
-: Will be "http" or "https" depending on the HTTP request URL.
-
-slim.input
-: Will be a string representing the raw HTTP request body. If the HTTP request body is empty (e.g. with a GET request), this will be an empty string.
-
-slim.errors
-: Must always be a writable resource; by default, this is a write-only resource handle to **php://stderr**.
-
-The Slim application can store its own data in the environment, too. The environment array's keys must contain at least one dot, and should be prefixed uniquely (e.g. "prefix.foo"). The prefix **slim.** is reserved for use by Slim itself and must not be used otherwise. The environment must not contain the keys **HTTP\_CONTENT\_TYPE** or **HTTP\_CONTENT\_LENGTH** (use the versions without **HTTP\_**). The CGI keys (named without a period) must have String values. There are the following restrictions:
-
-* slim.url_scheme must either be "http" or "https".
-* slim.input must be a string.
-* There must be a valid, writable resource in "slim.errors".
-* The **REQUEST\_METHOD** must be a valid token.
-* The **SCRIPT\_NAME**, if non-empty, must start with /
-* The **PATH\_INFO**, if non-empty, must start with /
-* The **CONTENT_LENGTH**, if given, must consist of digits only.
-* One of **SCRIPT\_NAME** or **PATH\_INFO** must be set. **PATH\_INFO** should be / if **SCRIPT\_NAME** is empty. **SCRIPT\_NAME** never should be /, but instead be an empty string.
View
19 Slim/codeguy-Slim-aa7e919/docs/errors-debug.markdown
@@ -1,19 +0,0 @@
-# Debugging [errors-debug] #
-
-You can enable debugging during application instantiation with this setting:
-
- $app = new Slim(array(
- 'debug' => true
- ));
-
-You may also enable debugging during runtime with the Slim application's `config()` instance method.
-
- $app = new Slim();
-
- //Enable debugging (on by default)
- $app->config('debug', true);
-
- //Disable debugging
- $app->config('debug', false);
-
-If debugging is enabled and an exception or error occurs, a detailed error message will appear with the error description, the affected file, the file line number, and a stack trace. If debugging is disabled, your [custom Error handler](#error-handler) will be invoked instead.
View
29 Slim/codeguy-Slim-aa7e919/docs/errors-error-handler.markdown
@@ -1,29 +0,0 @@
-# Error Handler [error-handler] #
-
-You may use the Slim application's `error()` instance method to specify a custom error handler to be invoked when an error or exception occurs. Custom error handlers are only invoked if application debugging is disabled.
-
-A custom error handler should render a user-friendly message that mitigates user confusion. Similar to the Slim application's `notFound()` instance method, the `error()` instance method acts as both a getter and a setter.
-
-## Set a Custom Error Handler ##
-
-You may set a custom error handler by passing a callable into the `error()` instance method as the first and only argument.
-
- $app = new Slim();
-
- //PHP >= 5.3
- $app->error(function ( Exception $e ) use ($app) {
- $app->render('error.php');
- });
-
- //PHP < 5.3
- $app->error('custom_error_handler');
- function custom_error_handler( Exception $e ){
- $app = Slim::getInstance();
- $app->render('error.php');
- }
-
-In this example, notice how the custom error handler accepts the caught Exception as its argument. This allows you to respond appropriately to different exceptions.
-
-## Invoke a Custom Error Handler ##
-
-Usually, the Slim application will automatically invoke the error handler when an exception or error occurs. However, you may also manually invoke the error handler with the Slim application's `error()` method (without an argument).
View
35 Slim/codeguy-Slim-aa7e919/docs/errors-notfound-handler.markdown
@@ -1,35 +0,0 @@
-# Not Found Handler [not-found-handler] #
-
-It is an inevitability that someone will request a page that does not exist. The Slim application lets you easily define a custom **Not Found** handler with the Slim application's `notFound()` instance method. The Not Found handler will be invoked when a matching route is not found for the current HTTP request. This method may be invoked in two different contexts.
-
-## When defining the handler ##
-
-If you invoke the Slim application's `notFound()` instance method and specify a callable object as its first and only argument, this method will register the callable object as the Not Found handler. However, the registered handler will not be invoked.
-
- $app = new Slim();
-
- //For PHP >= 5.3
- $app->notFound(function () use ($app) {
- $app->render('404.html');
- });
-
- //For PHP < 5.3
- $app->notFound('custom_not_found_callback');
- function custom_not_found_callback() {
- $app = Slim::getInstance();
- $app->render('404.html');
- }
-
-## When invoking the Not Found handler ##
-
-If you invoke the Slim application's `notFound()` instance method without any arguments, this method will invoke the previously registered Not Found handler.
-
- $app = new Slim();
-
- $app->get('/hello/:name', function ($name) use ($app) {
- if ( $name === 'Waldo' ) {
- $app->notFound();
- } else {
- echo "Hello, $name";
- }
- });
View
18 Slim/codeguy-Slim-aa7e919/docs/errors-output.markdown
@@ -1,18 +0,0 @@
-# Error Output [errors-output] #
-
-The Slim environment will always contain a key **slim.errors** with a value that is a writable resource to which log and error messages may be written. The Slim application's [Slim_Log](#logging) object will write log messages to **slim.errors** whenever an Exception is caught or the `Slim_Log` object is manually invoked.
-
-If you want to redirect error output to a different location, you can define your own writable resource by modifying the Slim application's environment settings. I recommend you use [middleware](#middleware) to update the environment like this:
-
- class CustomErrorMiddleware extends Slim_Middleware {
- public function call() {
- // Set new error output
- $env = $this->app->environment();
- $env['slim.errors'] = fopen('/path/to/custom/output', 'w');
-
- // Call next middleware
- $this->next->call();
- }
- }
-
-Remember, **slim.errors** does not have to point to a file; it can point to any valid writable resource.
View
3 Slim/codeguy-Slim-aa7e919/docs/errors-reporting.markdown
@@ -1,3 +0,0 @@
-# Error Reporting [errors-reporting] #
-
-By default, Slim will report **E\_ALL** and **E\_STRICT** errors. You can change the error reporting by editing **Slim/Slim.php**; the error reporting definition is at the top of that file. Only reported errors will be handled by Slim. Unreported errors will be ignored or handled elsewhere.
View
7 Slim/codeguy-Slim-aa7e919/docs/errors.markdown
@@ -1,7 +0,0 @@
-# Error Handling [errors] #
-
-Let’s face it: sometimes things go wrong. It is important to intercept errors and respond to them appropriately. A Slim application provides helper methods to respond to errors and exceptions.
-
-Each Slim application handles its own errors and exceptions. If there are multiple Slim applications in the same PHP script, each application will catch and handle its own errors and exceptions. Errors or exceptions generated outside of a Slim application must be caught and handled elsewhere.
-
-To prevent recoverable errors from stopping the entire PHP script, Slim converts errors into `ErrorException` instances that are caught and handled by a default or custom Slim application error handler.
View
25 Slim/codeguy-Slim-aa7e919/docs/flash.markdown
@@ -1,25 +0,0 @@
-# Flash Messaging [flash] #
-
-Slim supports flash messaging much like Rails and other larger web frameworks. Flash messaging allows you to define messages that will persist until the next HTTP request but no further. This is helpful to display messages to the user after a given event or error occurs.
-
-As shown below, the Slim application's `flash()` and `flashNow()` instance methods accept two arguments: a key and a message. The key may be whatever you want and defines how the message will be accessed in the View templates. For example, if I invoke the Slim application's `flash('foo', 'The foo message')` instance method with those arguments, I can access that message in the next request’s templates with `flash['foo']`.
-
-Flash messages are persisted with sessions; sessions are required for flash messages to work. Flash messages are stored in `$\_SESSION['flash']`.
-
-## Flash
-
-The Slim application's `flash()` instance method sets a message that will be available in the next request’s view templates. The message in this example will be available in the variable `flash['error']` in the next request’s view templates.
-
- $app->flash('error', 'User email is required');
-
-## Flash Now
-
-The Slim application's `flashNow()` instance method sets a message that will be available in the current request’s view templates. Messages set with the `flashNow()` application instance method will not be available in the next request. The message in the example below will be available in the variable `flash['info']` in the current request’s view templates.
-
- $app->flashNow('info', 'Your credit card is expired');
-
-## Flash Keep
-
-This method tells the Slim application to keep existing flash messages set in the previous request so they will be available to the next request. This method is helpful for persisting flash messages across HTTP redirects.
-
- $app->flashKeep();
View
10 Slim/codeguy-Slim-aa7e919/docs/hooks-custom.markdown
@@ -1,10 +0,0 @@
-# Custom Hooks [hooks-custom] #
-
-Custom hooks may also be created and invoked in a Slim application. When a custom hook is invoked with `applyHook()`, it will invoke all callables assigned to that hook. This is exactly how the Slim application's [default hooks](#hooks-default) work. In this example, I apply a custom hook called "my.hook.name". All callables previously registered for this hook will be invoked.
-
- $app = new Slim();
- $app->applyHook('my.hook.name');
-
-When you run the above code, any callables previously assigned to the hook **my.hook.name** will be invoked in order of priority (ascending).
-
-You should register callables to a hook before the hook is applied. Think of it this way: when you invoke the Slim application's `applyHook()` instance method, you are asking Slim to invoke all callables already registered for that hook name.
View
21 Slim/codeguy-Slim-aa7e919/docs/hooks-default.markdown
@@ -1,21 +0,0 @@
-# Default Hooks [hooks-default] #
-
-These are the default hooks always invoked in a Slim application.
-
-slim.before
-: This hook is invoked before the Slim application is run and before output buffering is turned on. This hook is invoked once during the Slim application lifecycle.
-
-slim.before.router
-: This hook is invoked after output buffering is turned on and before the router is dispatched. This hook is invoked once during the Slim application lifecycle.
-
-slim.before.dispatch
-: This hook is invoked before the current matching route is dispatched. Usually this hook is invoked only once during the Slim application lifecycle; however, this hook may be invoked multiple times if a matching route chooses to pass to a subsequent matching route.
-
-slim.after.dispatch
-: This hook is invoked after the current matching route is dispatched. Usually this hook is invoked only once during the Slim application lifecycle; however, this hook may be invoked multiple times if a matching route chooses to pass to a subsequent matching route.
-
-slim.after.router
-: This hook is invoked after the router is dispatched, before the Response is sent to the client, and after output buffering is turned off. This hook is invoked once during the Slim application lifecycle.
-
-slim.after
-: This hook is invoked after output buffering is turned off and after the Response is sent to the client. This hook is invoked once during the Slim application lifecycle.
View
33 Slim/codeguy-Slim-aa7e919/docs/hooks-usage.markdown
@@ -1,33 +0,0 @@
-# How to use a hook #
-
-A callable is assigned to a hook using the Slim application's `hook()` instance method:
-
- $app = new Slim();
- $app->hook('the.hook.name', function () {
- //Do something
- });
-
-The first argument is the hook name, and the second argument is the callable. Each hook maintains a priority list of registered callables. By default, each callable assigned to a hook is given a priority of 10. You can give your callable a different priority by passing an integer as the third parameter of the `hook()` method like this:
-
- $app = new Slim();
- $app->hook('the.hook.name', function () {
- //Do something
- }, 5);
-
-The example above assigns a priority of 5 to the callable. When the hook is called, it will sort all callables assigned to it by priority (ascending). A callable with priority 1 will be invoked before a callable with priority 10.
-
-Hooks do not pass arguments to their callables. If a callable needs to access the Slim application, you can inject the application into the callback with the `use` keyword or with the static `getInstance()` method:
-
- $app = new Slim();
-
- //If using PHP >= 5.3
- $app->hook('the.hook.name', function () use ($app) {
- // Do something
- });
-
- //If using PHP < 5.3
- $app->hook('the.hook.name', 'nameOfMyHookFunction');
- function nameOfMyHookFunction() {
- $app = Slim::getInstance();
- //Do something
- }
View
7 Slim/codeguy-Slim-aa7e919/docs/hooks.markdown
@@ -1,7 +0,0 @@
-# Hooks [hooks] #
-
-A Slim application provides a set of hooks to which you can register your own callbacks.
-
-A “hook” is a moment in the Slim application lifecycle at which a priority list of callables assigned to the hook will be invoked. A hook is identified by a string name.
-
-A “callable” is anything that returns `true` for `is_callable()`. A callable is assigned to a hook and is invoked when the hook is called.
View
144 Slim/codeguy-Slim-aa7e919/docs/index.txt
@@ -1,144 +0,0 @@
-# Documentation
-#
-# This documentation is written in MultiMarkdown format and may be consolidated into HTML, PDF,
-# ODF, Latex, or other formats using the `mmd_merge` command line utility.
-#
-# Learn more about MultiMarkdown at <http://fletcherpenney.net/multimarkdown/>
-
-welcome.markdown
-
-system-requirements.markdown
-
-instantiation.markdown
-
- settings.markdown
-
- names-and-scopes.markdown
-
- modes.markdown
-
-routing.markdown
-
- routing-get.markdown
-
- routing-post.markdown
-
- routing-put.markdown
-
- routing-delete.markdown
-
- routing-options.markdown
-
- routing-generic.markdown
-
- routing-custom.markdown
-
- routing-parameters.markdown
-
- routing-names.markdown
-
- routing-conditions.markdown
-
- routing-middleware.markdown
-
- routing-helpers.markdown
-
- routing-helpers-halt.markdown
-
- routing-helpers-pass.markdown
-
- routing-helpers-redirect.markdown
-
- routing-helpers-stop.markdown
-
- routing-helpers-urlfor.markdown
-
- routing-indepth.markdown
-
- routing-indepth-slashes.markdown
-
- routing-indepth-with-rewrite.markdown
-
- routing-indepth-without-rewrite.markdown
-
-environment.markdown
-
-request.markdown
-
- request-method.markdown
-
- request-parameters.markdown
-
- request-headers.markdown
-
- request-cookies.markdown
-
- request-xhr.markdown
-
- request-paths.markdown
-
- request-helpers.markdown
-
-response.markdown
-
- response-status.markdown
-
- response-header.markdown
-
- response-body.markdown
-
- response-cookies.markdown
-
- response-helpers.markdown
-
-views.markdown
-
- views-rendering.markdown
-
- views-custom.markdown
-
- views-data.markdown
-
- views-settings.markdown
-
-caching.markdown
-
- caching-etag.markdown
-
- caching-last-modified.markdown
-
- caching-expires.markdown
-
-middleware.markdown
-
- middleware-architecture.markdown
-
- middleware-implementation.markdown
-
- middleware-add.markdown
-
-hooks.markdown
-
- hooks-usage.markdown
-
- hooks-custom.markdown
-
- hooks-default.markdown
-
-flash.markdown
-
-sessions.markdown
-
-logging.markdown
-
-errors.markdown
-
- errors-error-handler.markdown
-
- errors-notfound-handler.markdown
-
- errors-debug.markdown
-
- errors-reporting.markdown
-
- errors-output.markdown
View
11 Slim/codeguy-Slim-aa7e919/docs/instantiation.markdown
@@ -1,11 +0,0 @@
-# Instantiation
-
-First `require()` Slim into your application file. If you move the **Slim/** directory elsewhere on your filesystem, it is important that you keep Slim's dependencies in the same directory as Slim.php. Keeping the files together enables you to only require **Slim.php** and have the other files loaded automatically. Assuming the **Slim/** directory is on your include path, you only need to call:
-
- require 'Slim/Slim.php';
-
-After you require Slim, instantiate your Slim application like this:
-
- $app = new Slim();
-
-The Slim constructor accepts an optional associative array of settings to customize the Slim application during instantiation (see [settings]).
View
104 Slim/codeguy-Slim-aa7e919/docs/logging.markdown
@@ -1,104 +0,0 @@
-# Logging [logging] #
-
-A Slim application provides a `Slim_Log` object that logs data to a specific output via a log writer.
-
-## How to Log Messages ##
-
-To log messages from a Slim application, get a reference to the `Slim_Log` object like this:
-
- $log = $app->getLog();
-
-The `Slim_Log` object provides the following public interface:
-
- $log->debug( mixed $object );
- $log->info( mixed $object );
- $log->warn( mixed $object );
- $log->error( mixed $object );
- $log->fatal( mixed $object );
-
-Each `Slim_Log` method accepts one mixed argument. The argument is usually a string, but the argument can be anything. The argument will be passed to the log writer. It is the log writer's responsibility to log arbitrary input appropriately.
-
-## Log Writers ##
-
-The Slim application's `Slim_Log` instance has a log writer. The log writer is responsible for sending a logged message to the appropriate output (e.g. STDERR, a log file, a remote web service, Twitter, or a database). Out of the box, the Slim application's `Slim_Log` object has a log writer instance of class `Slim_LogFileWriter`; this log writer directs output to the resource handle referenced by the application environment's **slim.errors** key (by default, this is "php://stderr"). You may also define and use a custom log writer.
-
-### How to Use a Custom Log Writer ###
-
-A custom log writer must implement the following public interface:
-
- public function write( mixed $message );
-
-You must tell the Slim application's `Slim_Log` instance to use your writer. You can do so in your application's settings during instantiation like this:
-
- $app = new Slim(array(
- 'log.writer' => new MyLogWriter()
- ));
-
-You may also set a custom log writer with middleware like this:
-
- class CustomLogWriterMiddleware extends Slim_Middleware {
- public function call() {
- //Set the new log writer
- $log = $this->app->getLog()->setWriter( new MyLogWriter() );
-
- //Call next middleware
- $this->next->call();
- }
- }
-
-You can set the log writer similarly in an application [hook](#hooks) or [route](#routing-get) callback like this:
-
- $app->hook('slim.before', function () use ($app) {
- $app->getLog()->setWriter( new MyLogWriter() );
- });
-
-If you only need to redirect error output to a different resource, I recommend you [update the Environment's **slim.errors** element](#errors-output) instead of writing and entirely new LogWriter.
-
-## How to Enable or Disable Logging ##
-
-The Slim application's `Slim_Log` object provides the following public methods to enable or disable logging during runtime.
-
- //Enable logging
- $app->getLog()->setEnabled(true);
-
- //Disable logging
- $app->getLog()->setEnabled(false);
-
-You may enable or disable the `Slim_Log` object during application instantiation like this:
-
- $app = new Slim(array(
- 'log.enabled' => true
- ));
-
-If logging is disabled, the `Slim_Log` object will ignore all logged messages until it is enabled.
-
-## Log Levels ##
-
-The Slim application's `Slim_Log` object provides the following public methods to define the _level_ of messages it will log. When you invoke the `Slim_Log` objects's `debug()`, `info()`, `warn()`, `error()`, or `fatal()` methods, you are inherently assigning a level to the logged message:
-
-Debug
-: Level 4
-
-Info
-: Level 3
-
-Warn
-: Level 2
-
-Error
-: Level 1
-
-Fatal
-: Level 0
-
-Only messages that have a level _less than_ the current `Slim_Log` object's level will be logged. For example, if the `Slim_Log` object's level is "2", the `Slim_Log` object will ignore debug and info messages but will accept warn, error, and fatal messages.
-
-You can set the `Slim_Log` object's level like this:
-
- $app->getLog()->setLevel(2);
-
-You can set the `Slim_Log` object's level during application instantiation like this:
-
- $app = new Slim(array(
- 'log.level' => 2
- ));
View
28 Slim/codeguy-Slim-aa7e919/docs/middleware-add.markdown
@@ -1,28 +0,0 @@
-# Add Middleware [middleware-add] #
-
-Use the Slim application's `add()` instance method to add new middleware to a Slim application. New middleware will surround previously added middleware, or the Slim application itself if no middleware has yet been added.
-
-## Example Middleware ##
-
- class Secret_Middleware extends Slim_Middleware {
- public function call() {
- $app = $this->app;
- $req = $app->request();
- $res = $app->response();
- if ( $req->headers('X-Secret-Request') === 'The sun is shining' ) {
- $res->header('X-Secret-Response', 'But the ice is slippery');
- }
- $this->next->call();
- }
- }
-
-## Add Middleware ##
-
- $app = new Slim();
- $app->add(new Secret_Middleware());
- $app->get('/foo', function () use ($app) {
- //Do something
- });
- $app->run();
-
-The Slim application's `add()` method accepts one argument: a middleware instance. If the middleware instance requires special configuration, it may implement its own constructor so that it may be configured before it is added to the Slim application.
View
36 Slim/codeguy-Slim-aa7e919/docs/middleware-architecture.markdown
@@ -1,36 +0,0 @@
-# Middleware Architecture [middleware-architecture] #
-
-Think of a Slim application as the core of an onion. Each layer of the onion is middleware. When you invoke the Slim application's `run()` method, the outer-most middleware layer is invoked first. When ready, that middleware layer is responsible for optionally invoking the next middleware layer that it surrounds. This process steps deeper into the onion — through each middleware layer — until the core Slim application is invoked. This stepped process is possible because each middleware layer, and the Slim application itself, all implement a public `call()` instance method. When you add new middleware to a Slim application, the added middleware will become a new outer layer and surround the previous outer middleware layer (if available) or the Slim application itself.
-
-## Application Reference ##
-
-The purpose of middleware is to inspect, analyze, or modify the application environment, the application request, and the application response before and/or after the Slim application is invoked. It is easy for each middleware to obtain references to the primary Slim application, the Slim application's environment, the Slim application's request, and the Slim application's response:
-
- class My_Middleware extends Slim_Middleware {
- public function call() {
- //The Slim application
- $app = $this->app;
-
- //The Environment object
- $env = $app->environment();
-
- //The Request object
- $req = $app->request();
-
- //The Response object
- $res = $app->response();
- }
- }
-
-Changes made to the environment, request, and response objects will propagate immediately throughout the application and its other middleware layers. This is possible because every middleware layer is given a reference to the same Slim application object.
-
-## Next Middleware Reference ##
-
-Each middleware layer also has a reference to the _next_ inner middleware layer with `$this->next`. It is each middleware's responsibility to optionally call the next middleware. Doing so will allow the Slim application to complete its full lifecycle. If a middleware layer chooses _not_ to call the next inner middleware layer, further inner middleware and the Slim application itself will not be run, and the application response will be returned to the HTTP client as is.
-
- class My_Middleware extends Slim_Middleware {
- public function call() {
- //Optionally call the next middleware
- $this->next->call();
- }
- }
View
11 Slim/codeguy-Slim-aa7e919/docs/middleware-implementation.markdown
@@ -1,11 +0,0 @@
-# Middleware Implementation [middleware-implementation] #
-
-Middleware **must** extend the `Slim_Middleware` class and implement a public `call()` instance method. The `call()` method does not accept arguments. Otherwise, each middleware may implement its own constructor, properties, and methods. I encourage you to look at Slim's built-in middleware for working examples (e.g. `Slim/Middleware/ContentTypes.php` or `Slim/Middleware/SessionCookie.php`).
-
-This example is the most simple implementation of Slim application middleware. It extends `Slim_Middleware`, implements a public `call()` method, and calls the next inner middleware.
-
- class My_Middleware extends Slim_Middleware {
- public function call() {
- $this->next->call();
- }
- }
View
3 Slim/codeguy-Slim-aa7e919/docs/middleware.markdown
@@ -1,3 +0,0 @@
-# Middleware [middleware] #
-
-The Slim Framework implements a derivation of the Rack protocol. As a result, a Slim application can have middleware that may inspect, analyze, or modify the application environment variables, the application Request object, and the application Response object before and/or after the Slim application is invoked.
View
54 Slim/codeguy-Slim-aa7e919/docs/modes.markdown
@@ -1,54 +0,0 @@
-# Application Modes [application-modes]
-
-It is common practice to run web applications in a specific mode depending on the current state of the project. If you are developing the application, you will run the application in "development" mode; if you are testing the application, you will run the application in "test" mode; if you launch the application, you will run the application in "production" mode.
-
-Slim supports the concept of modes in that you may define your own modes and prompt Slim to prepare itself appropriately in the current mode. For example, you may want to enable debugging in "development" mode but not in "production" mode. The examples below demonstrate how to configure Slim differently for a given mode.
-
-## What is a mode? [what-is-a-mode]
-
-Technically, an application mode is merely a string of text — like "development" or "production" — that has an associated callback function used to prepare the Slim application appropriately. The application mode may be anything you like: “testing”, “production”, “development”, or even “foo”.
-
-## How do I set the Slim application mode? [how-to-set-mode]
-
-### Use an environment variable
-
-If Slim sees an environment variable named **SLIM_MODE**, it will set the current application mode to that variable’s value. This lets you define the Slim application mode programmatically if calling the application from the command line.
-
- $_ENV['SLIM_MODE'] = 'production';
-
-### Use an application setting
-
-If an environment variable is not found, Slim will next look for the mode in the application settings.
-
- $app = new Slim(array(
- 'mode' => 'production'
- ));
-
-### Default mode
-
-If the environment variable and application setting are not found, Slim will set the application mode to “development”.
-
-## Configure Slim for a specific mode [configure-for-mode]
-
-After you instantiate a Slim application, you may configure the Slim application for a specific mode with the `configureMode()` application instance method. This method accepts two arguments: the first is the name of the target mode, and the second is anything that returns `true` for `is_callable()` that will be immediately invoked if the first argument matches the current application mode.
-
-In this example, assume the current application mode is “production”. Only the callable associated with the “production” mode will be invoked. The callable associated with the “development” mode will be ignored until the application mode is changed to "development".
-
- $app = new Slim(array(
- 'mode' => 'production'
- ));
-
- $app->configureMode('production', function () use ($app) {
- $app->config(array(
- 'log.enable' => true,
- 'log.path' => '../logs',
- 'debug' => false
- ));
- });
-
- $app->configureMode('development', function () use ($app) {
- $app->config(array(
- 'log.enable' => false,
- 'debug' => true
- ));
- });
View
58 Slim/codeguy-Slim-aa7e919/docs/names-and-scopes.markdown
@@ -1,58 +0,0 @@
-# Application Names and Scopes [names-and-scopes]
-
-When you build a Slim application you will enter various scopes in your code (e.g. global scope and function scope). You will likely need a reference to your Slim application in each scope. You can use application names, or `use` with PHP >= 5.3, to obtain a reference to your Slim application.
-
-## Application Names [application-names]
-
-Every Slim application may be given a name. **This is optional**. Names help you get a reference to a Slim application instance in any scope throughout your code. Here is how you set and get an application's name:
-
- $app = new Slim();
- $app->setName('foo');
- $theName = $app->getName(); //returns "foo"
-
-## Scope Resolution [scope-resolution]
-
-So how do you get a reference to your Slim application? The example below demonstrates how to obtain a reference to a Slim application within a route callback function. The Slim `$app` variable is accessed in the global scope to define the GET route. We also need to access the Slim `$app` variable within the route’s callback scope to render a template.
-
- $app = new Slim();
- $app->get('/foo', function () {
- $app->render('foo.php'); //<--ERROR
- });
-
-This fails because we cannot access the Slim `$app` variable inside of the route callback function. In PHP >= 5.3 we can inject the Slim `$app` variable into the anonymous function scope with the `use` keyword:
-
- $app = new Slim();
- $app->get('/foo', function () use ($app) {
- $app->render('foo.php'); //<--SUCCESS
- });
-
-Now it works correctly. In PHP < 5.3, you can use `Slim::getInstance()` instead.
-
- $app = new Slim();
- $app->get('/foo', 'foo');
- function foo() {
- $app = Slim::getInstance();
- $app->render('foo.php');
- }
-
-The first instantiated Slim application is automatically assigned the name "default". If you invoke `Slim::getInstance()` without an argument, it will return the Slim application that is named "default".
-
-If you instantiate multiple Slim applications with PHP < 5.3, it is important that you assign each Slim application a name.
-
- $app1 = new Slim();
- $app1->setName('myApp1');
-
- $app2 = new Slim();
- $app2->setName('myApp2');
-
- $app1->get('/foo', 'appOneCallback');
- function appOneCallback() {
- $app = Slim::getInstance('myApp1');
- }
-
- $app2->get('/foo', 'appTwoCallback');
- function appTwoCallback() {
- $app = Slim::getInstance('myApp2');
- }
-
-Invoking `Slim::getInstance()` without an argument will return a reference to `$app1` because that is the first Slim application instantiated.
View
24 Slim/codeguy-Slim-aa7e919/docs/request-cookies.markdown
@@ -1,24 +0,0 @@
-# Request Cookies [request-cookies] #
-
-## Get Cookies [request-cookies-basic] ##
-
-A Slim application will automatically parse cookies sent with the current HTTP request. You can fetch cookie values with the Slim application's `getCookie()` instance method like this:
-
- $foo = $app->getCookie('foo');
-
-Only Cookies **sent** with the current HTTP request are accessible with this method. If you set a cookie during the current request, it will not be accessible with this method until the subsequent request. If you want to fetch an array of all cookies sent with the current request, you must use the Request object's `cookies()` instance method like this:
-
- //Get all cookies as associative array
- $cookies = $app->request()->cookies();
-
-## Get Encrypted Cookies [request-cookies-encrypted] ##
-
-If you previously set an encrypted cookie, you can fetch its decrypted value with the Slim application's `getEncryptedCookie()` instance method like this:
-
- $cookieValue = $app->getEncryptedCookie('foo');
-
-If the cookie was modified while with the HTTP client, Slim will automatically destroy the cookie's value and invalidate the cookie in the next HTTP response. You can disable this behavior by passing `false` as the second argument:
-
- $cookieValue = $app->getEncryptedCookie('foo', false);
-
-Whether you destroy invalid cookies or not, `NULL` is returned if the cookie does not exist or is invalid.
View
15 Slim/codeguy-Slim-aa7e919/docs/request-headers.markdown
@@ -1,15 +0,0 @@
-# Request Headers [request-headers] #
-
-A Slim application will automatically parse all HTTP request headers. You can access the Request headers using the Request `headers()` instance method.
-
- $app = new Slim();
-
- //Fetch all request headers as associative array
- $headers = $app->request()->headers();
-
- //Fetch only the ACCEPT_CHARSET header
- $charset = $app->request()->headers('ACCEPT_CHARSET'); //returns string or NULL
-
-In the second example, the `headers()` method will either return a string value or `NULL` if the header with the given name does not exist.
-
-The HTTP specification states that HTTP header names may be uppercase, lowercase, or mixed-case. Slim is smart enough to parse and return header values whether you request a header value using upper, lower, or mixed case header name, with either underscores or dashes. So use the naming convention with which you are most comfortable.
View
46 Slim/codeguy-Slim-aa7e919/docs/request-helpers.markdown
@@ -1,46 +0,0 @@
-# Request Helpers [request-helpers] #
-
-Slim provides several helper methods that help you fetch common HTTP request information.
-
- //Fetch HTTP request content type (e.g. "application/json;charset=utf-8"
- $contentType = $app->request()->getContentType();
-
- //Fetch HTTP request media type (e.g "application/json")
- $mediaType = $app->request()->getMediaType();
-
- //Fetch HTTP request media type params (e.g [charset => "utf-8"])
- $mediaTypeParams = $app->request()->getMediaTypeParams();
-
- //Fetch HTTP request content type charset (e.g. "utf-8")
- $charset = $app->request()->getContentCharset();
-
- //Fetch HTTP request content length
- $contentLength = $app->request()->getContentLength();
-
- //Fetch HTTP request host (e.g. "slimframework.com")
- $host = $app->request()->getHost();
-
- //Fetch HTTP request host with port (e.g. "slimframework.com:80")
- $hostAndPort = $app->request()->getHostWithPort();
-
- //Fetch HTTP request port (e.g. 80)
- $port = $app->request()->getPort();
-
- //Fetch HTTP request scheme (e.g. "http" or "https")
- $scheme = $app->request()->getScheme();
-
- //Fetch HTTP request URI path (root URI + resource URI)
- $path = $app->request()->getPath();
-
- //Fetch HTTP request URL (scheme + host [ + port if non-standard ])
- $url = $app->request()->getUrl();
-
- //Fetch HTTP request IP address
- $ip = $app->request()->getIp();
-
- //Fetch HTTP request referer
- $ref = $app->request()->getReferer();
- $ref = $app->request()->getReferrer();
-
- //Fetch HTTP request user agent string
- $ua = $app->request()->getUserAgent();
View
27 Slim/codeguy-Slim-aa7e919/docs/request-method.markdown
@@ -1,27 +0,0 @@
-# Request Method [request-method] #
-
-Every HTTP request has a method (e.g. GET or POST). You can obtain the current HTTP request method via the Slim application's Request object:
-
- //What is the request method?
- $method = $app->request()->getMethod(); //returns "GET", "POST", etc.
-
- //Is this a GET request?
- $app->request()->isGet(); //true or false
-
- //Is this a POST request?
- $app->request()->isPost(); //true or false
-
- //Is this a PUT request?
- $app->request()->isPut(); //true or false
-
- //Is this a DELETE request?
- $app->request()->isDelete(); //true or false
-
- //Is this a HEAD request?
- $app->request()->isHead(); //true or false
-
- //Is this a OPTIONS request?
- $app->request()->isOptions(); //true or false
-
- //Is this a request made with Ajax/XHR?
- $app->request()->isAjax(); //true or false
View
24 Slim/codeguy-Slim-aa7e919/docs/request-parameters.markdown
@@ -1,24 +0,0 @@
-# Request Parameters [request-parameters] #
-
-An HTTP request may have associated parameters (not to be confused with [Route parameters](#routing-paramters)). The GET, POST, or PUT parameters sent with the current HTTP request are exposed via the Slim application's Request object.
-
-If you want to quickly fetch a request parameter value without considering its type, use the `params()` Request method:
-
- $paramValue = $app->request()->params('paramName');
-
-The `params()` Request instance method will first search **PUT** parameters, then **POST** parameters, then **GET** parameters. If no parameter is found, `NULL` is returned. If you only want to search for a specific type of parameter, you can use these Request instance methods instead:
-
- //GET parameter
- $paramValue = $app->request()->get('paramName');
-
- //POST parameter
- $paramValue = $app->request()->post('paramName');
-
- //PUT parameter
- $paramValue = $app->request()->put('paramName');
-
-If a parameter does not exist, each method above will return `NULL`. You can also invoke any of these functions without an argument to obtain an array of all parameters of the given type:
-
- $allGetParams = $app->request()->get();
- $allPostParams = $app->request()->post();
- $allPutParams = $app->request()->put();
View
19 Slim/codeguy-Slim-aa7e919/docs/request-paths.markdown
@@ -1,19 +0,0 @@
-# Request Paths [request-paths] #
-
-Every HTTP request received by a Slim application will have a root URI and a resource URI.
-
-The **root URI** is the physical URL path of the directory in which the Slim application is instantiated and run. If a Slim application is instantiated in **index.php** within the top-most directory of the virtual host's document root, the root URI will be an empty string. If a Slim application is instantiated and run in **index.php** within a physical subdirectory of the virtual host's document root, the root URI will be the path to that subdirectory *with* a leading slash and *without* a trailing slash.
-
-The **resource URI** is the virtual URI path of an application resource. The resource URI will be matched to the Slim application's routes.
-
-Here's an example. Assume the Slim application is installed in a physical subdirectory **/foo** beneath your virtual host's document root. Also assume the full HTTP request URL (what you'd see in the browser location bar) is **/foo/books/1**. The root URI is **/foo** (the path to the physical directory in which the Slim application is instantiated) and the resource URI is **/books/1** (the path to the application resource).
-
-You can get the Request’s root URI and resource URI like this:
-
- $app = new Slim();
-
- //Get the Request root URI
- $rootUri = $app->request()->getRootUri();
-
- //Get the Request resource URI
- $resourceUri = $app->request()->getResourceUri();
View
8 Slim/codeguy-Slim-aa7e919/docs/request-xhr.markdown
@@ -1,8 +0,0 @@
-# XMLHttpRequest [request-xhr] #
-
-When using a Javascript framework like MooTools or jQuery to execute an XMLHttpRequest, the XMLHttpRequest will usually be sent with a 'X-Requested-With' HTTP header. The Slim application will detect the HTTP request's ‘X-Requested-With’ header and flag the request as such. If for some reason an XMLHttpRequest cannot be sent with the 'X-Requested-With' HTTP header, you can force the Slim application to assume an HTTP request is an XMLHttpRequest by setting a GET, POST, or PUT parameter in the HTTP request named “isajax” with a truthy value.
-
-Here's how you tell if the current request is an XHR/Ajax request:
-
- $isXHR = $app->request()->isAjax(); //true or false
- $isXHR = $app->request()->isXhr(); //true or false; alias of `isAjax()`
View
7 Slim/codeguy-Slim-aa7e919/docs/request.markdown
@@ -1,7 +0,0 @@
-# The Request Object [request] #
-
-Each Slim application instance has one Request object. The Request object is an abstraction of the current HTTP request and allows you to easily interact with the [Environment](#environment) variables. Although each Slim application includes a default Request object, the `Slim_Http_Request` class is idempotent; you may instantiate the class at will (in [Middleware](#middleware) or elsewhere in your Slim application) without affecting the application as a whole.
-
-You can obtain a reference to the Slim application's Request object like this:
-
- $app->request();
View
16 Slim/codeguy-Slim-aa7e919/docs/response-body.markdown
@@ -1,16 +0,0 @@
-# Response Body [response-body] #
-
-The HTTP response returned to the client will have a body. The HTTP body is the actual content of the HTTP response delivered to the client. You can use the Slim application's Response object to set the HTTP response's body like this:
-
- $response = $app->response();
- $response->body('Foo'); //The body is now "Foo" (overwrites)
- $response->write('Bar'); //The body is now "FooBar" (appends)
-
-When you overwrite or append the Response's body, the Response object will automatically set the `Content-Length` header based on the byte size of the new response body.
-
-You can fetch the Response object's body using the same Response `body()` instance method without an argument like this:
-
- $response = $app->response();
- $body = $response->body();
-
-Usually, you will never need to manually set the Response body with the Response `body()` or `write()` methods; instead, the Slim application will do this for you. Whenever you `echo()` content from within a route callback, the `echo()`'d content is captured in an output buffer and later appended to the Response body before the HTTP response is returned to the client.
View
47 Slim/codeguy-Slim-aa7e919/docs/response-cookies.markdown
@@ -1,47 +0,0 @@
-# Response Cookies [response-cookies] #
-
-The Slim application instance provides several helper methods to send cookies with the HTTP response.
-
-## Set Cookie ##
-
-This example demonstrates how to use the Slim application's `setCookie()` instance method to create a Cookie that will be sent with the HTTP response:
-
- $app->setCookie('foo', 'bar', '2 days');
-
-This creates a cookie with name **foo** and value **bar** that expires two days from now. You may also provide additional cookie properties, including path, domain, secure, and httponly. The Slim application's `setCookie()` method uses the same signature as PHP's native `setCookie()` function.
-
- $app->setCookie($name, $value, $expiresAt, $path, $domain, $secure, $httponly);
-
-The last argument, `$httpOnly`, was added in PHP 5.2. However, because Slim's underlying cookie implementation does not rely on PHP's native `setCookie()` function, you may use the `$httpOnly` cookie property even with PHP 5.1.
-
-## Set Encrypted Cookie [response-cookies-encrypted] ##
-
-You may also create encrypted cookies using the Slim application's `setEncryptedCookie()` instance method. This method acts the same as the Slim application's `setCookie()` instance method demonstrated above, but it will encrypt the cookie value using the AES-256 cipher and your own secret key. To use encryption, you **must** define your encryption key when you instantiate your Slim application like this:
-
- $app = new Slim(array(
- 'cookies.secret_key' => 'my_secret_key'
- ));
-
-If you prefer, you may also change the default cipher and cipher mode, too:
-
- $app = new Slim(array(
- 'cookies.secret_key' => 'my_secret_key',
- 'cookies.cipher' => MCRYPT_RIJNDAEL_256,
- 'cookies.cipher_mode' => MCRYPT_MODE_CBC
- ));
-
-The encrypted cookie value is hashed and later verified to ensure data integrity so that its value is not changed while on the HTTP client.
-
-## Delete Cookie [response-cookies-delete] ##
-
-You can delete a cookie using the Slim application's `deleteCookie()` instance method. This will remove the cookie from the HTTP client before the next HTTP request. This method accepts the same signature as the Slim application's `setCookie()` instance method, just without the `$expires` argument. Only the first argument is required.
-
- $app->deleteCookie('foo');
-
-Or if you need to also specify the **path** and **domain**:
-
- $app->deleteCookie('foo', '/', 'foo.com');
-
-You may also further specify the **secure** and **httponly** properties, too:
-
- $app->deleteCookie('foo', '/', 'foo.com', true, true);
View
15 Slim/codeguy-Slim-aa7e919/docs/response-header.markdown
@@ -1,15 +0,0 @@
-# Response Header [response-header] #
-
-The HTTP response returned to the HTTP client will have a header. The HTTP header is a list of keys and values that provide metadata about the HTTP response. You can use the Slim application's Response object to set the HTTP response's header. The Response object is special because it acts like an array. Here's an example.
-
- $response = $app->response();
- $response['Content-Type'] = 'application/json';
- $response['X-Powered-By'] = 'Slim';
-
-Just the same, you can also fetch headers from the Response object like this:
-
- $response = $app->response();
- $contentType = $response['Content-Type'];
- $poweredBy = $response['X-Powered-By'];
-
-If a header with the given name does not exist, `NULL` is returned instead. You may specify header names with upper, lower, or mixed case with dashes or underscores. Use the naming convention with which you are most comfortable.
View
52 Slim/codeguy-Slim-aa7e919/docs/response-helpers.markdown
@@ -1,52 +0,0 @@
-# Response Helpers [response-helpers] #
-
-The Response object provides several instance methods to help you inspect and interact with the underlying HTTP response.
-
-## Finalize [response-helpers-finalize] ##
-
-The Response object's `finalize()` method returns a numeric array of status, header, and body. The status is an integer; the header is an iterable data structure; and the body is a string. Were you to create a new Response object in the Slim application or in middleware, you would call this method to produce the status, header, and body for the underlying response.
-
- $res = new Slim_Http_Response();
- $res->status(400);
- $res->write('You made a bad request');
- $res['Content-Type'] = 'text/plain';
- $array = $res->finalize(); //returns [200, ['Content-type' => 'text/plain'], 'You made a bad request']
-
-## Redirect [response-helpers-redirect] ##
-
-The Response object's `redirect()` method will help you quickly set the status and **Location:** header needed to return a **3xx Redirect** response.
-
- $app->response()->redirect('/foo', 303);
-
-In this example, the Response will now have a **Location:** header with value "/foo" and a 303 status code.
-
-## Status Inspection [response-helpers-inspection] ##
-
-The Response object provides several methods to help you quickly inspect the type of Response based on its status. All return a boolean value. They are:
-
- //Is this an informational response?
- $app->response()->isInformational();
-
- //Is this a 200 OK response?
- $app->response()->isOk();
-
- //Is this a 2xx successful response?
- $app->response()->isSuccessful();
-
- //Is this a 3xx redirection response?
- $app->response()->isRedirection();
-
- //Is this a specific redirect response? (301, 302, 303, 307)
- $app->response()->isRedirect();
-
- //Is this a forbidden response?
- $app->response()->isForbidden();
-
- //Is this a not found response?
- $app->response()->isNotFound();
-
- //Is this a client error response?
- $app->response()->isClientError();
-
- //Is this a server error response?
- $app->response()->isServerError();
View
9 Slim/codeguy-Slim-aa7e919/docs/response-status.markdown
@@ -1,9 +0,0 @@
-# Response Status [response-status] #
-
-The HTTP response returned to the client will have a status code indicating the response's type (e.g. 200 OK, 400 Bad Request, or 500 Server Error). You can use the Slim application's Response object to set the HTTP response's status like this:
-
- $app->response()->status(400);
-
-You only need to set the Response object's status if you intend to return an HTTP response that does not have a **200 OK** status. You can just as easily fetch the Response object's current HTTP status by invoking the same method without an argument, like this:
-
- $status = $app->response()->status(); //returns int
View
9 Slim/codeguy-Slim-aa7e919/docs/response.markdown
@@ -1,9 +0,0 @@
-# The Response Object [response] #
-
-Each Slim application instance has one Response object. The Response object is a high-level interface that allows you to easily interact with the HTTP response that is returned to the HTTP client. Although each Slim application includes a default Response object, the `Slim_Http_Response` class is idempotent; you may instantiate the class at will (in [Middleware](#middleware) or elsewhere in your Slim application) without affecting the application as a whole.
-
-You can obtain a reference to the Slim application's Response object like this:
-
- $app->response();
-
-An HTTP response has three primary properties: the status code, the header, and the body. The Response object provides several helper methods, described next, that help you interact with these HTTP response properties in your Slim application. The default Response object in each Slim application will return a **200 OK** HTTP response with the **text/html** content type.
View
30 Slim/codeguy-Slim-aa7e919/docs/routing-conditions.markdown
@@ -1,30 +0,0 @@
-# Route Conditions [routing-conditions] #
-
-Slim lets you assign conditions to route parameters. If the specified conditions are not met, the route is not run. For example, if you need a route with a second segment that must be a valid 4-digit year, you could enforce this condition like this:
-
- $app = new Slim();
- $app->get('/archive/:year', function ($year) {
- echo "You are viewing archives from $year";
- })->conditions(array('year' => '(19|20)\d\d'));
-
-Invoke the `conditions()` Route method. The first and only argument is an associative array with keys that match any of the route’s parameters and values that are regular expressions.
-
-## Application-wide Route Conditions
-
-If many of your Slim application Routes accept the same parameters and use the same conditions, you can define default application-wide Route conditions like this:
-
- Slim_Route::setDefaultConditions(array(
- 'firstName' => '[a-zA-Z]{3,}'
- ));
-
-Define application-wide route conditions before you define application routes. When you define a route, the route will automatically be assigned any application-wide Route conditions defined with `Slim\_Route::setDefaultConditions()`. If for whatever reason you need to get the application-wide default route conditions, you can fetch them with `Slim_Route::getDefaultConditions()`; this static method returns an array exactly as the default route conditions were defined.
-
-You may override a default route condition by redefining the route’s condition when you define the route, like this:
-
- $app = new Slim();
- $app->get('/hello/:firstName', $callable)->conditions(array('firstName' => '[a-z]{10,}'));
-
-You may append new conditions to a given route like this:
-
- $app = new Slim();
- $app->get('/hello/:firstName/:lastName', $callable)->conditions(array('lastName' => '[a-z]{10,}'));
View
29 Slim/codeguy-Slim-aa7e919/docs/routing-custom.markdown
@@ -1,29 +0,0 @@
-# Custom Routes [routing-custom] #
-
-## One Route, Multiple HTTP Methods ##
-
-Sometimes you may need a route to respond to multiple HTTP methods; sometimes you may need a route to respond to a custom HTTP method. You can accomplish both with the `via()` Route method. This example demonstrates how to map a resource URI to a callback that responds to multiple HTTP methods.
-
- $app = new Slim();
- $app->map('/foo/bar', function() {
- echo "I respond to multiple HTTP methods!";
- })->via('GET', 'POST');
- $app->run();
-
-The route defined in this example will respond to both GET and POST requests for the resource identified by "/foo/bar". Specify each appropriate HTTP method as a separate string argument to the `via()` Route method. Like other Route methods (e.g. `name()` and `conditions()`), the `via()` Route method is chainable:
-
- $app = new Slim();
- $app->map('/foo/bar', function() {
- echo "Fancy, huh?";
- })->via('GET', 'POST')->name('foo');
- $app->run();
-
-## One Route, Custom HTTP Methods ##
-
-The `via()` Route method is not limited to just GET, POST, PUT, DELETE, and OPTIONS methods. You may also specify your own custom HTTP methods (e.g. if you were responding to WebDAV HTTP requests). You can define a route that responds to a custom "FOO" HTTP method like this:
-
- $app = new Slim();
- $app->map('/hello', function() {
- echo "Hello";
- })->via('FOO');
- $app->run();
View
32 Slim/codeguy-Slim-aa7e919/docs/routing-delete.markdown
@@ -1,32 +0,0 @@
-# DELETE Routes [routing-delete] #
-
-Use the `delete()` application instance method to map a callback function to a resource URI that is requested with the HTTP DELETE method.
-
- $app = new Slim();
-
- //For PHP >= 5.3
- $app->delete('/books/:id', function ($id) {
- //Delete book identified by $id
- });
-
- //For PHP < 5.3
- $app->delete('/books/:id', 'delete_book');
- function delete_book($id) {
- //Delete book identified by $id
- }
-
-In this example, an HTTP DELETE request for “/books/1” will invoke the associated callback function.
-
-The first argument of the `delete()` application instance method is the resource URI. The last argument is anything that returns `true` for `is_callable()`. I encourage you to use PHP >= 5.3 so you may take advantage of anonymous functions.
-
-## Method Override ##
-
-Unfortunately, modern browsers do not provide native support for HTTP DELETE requests. To work around this limitation, ensure your HTML form’s **method** attribute is “post”, then add a method override parameter to your HTML form like this:
-
- <form action="/books/1" method="post">
- ... other form fields here...
- <input type="hidden" name="_METHOD" value="DELETE"/>
- <input type="submit" value="Delete Book"/>
- </form>
-
-If you are using [Backbone.js](http://documentcloud.github.com/backbone/) or a command-line HTTP client, you may also override the HTTP method by using the `X-HTTP-Method-Override` header.
View
11 Slim/codeguy-Slim-aa7e919/docs/routing-generic.markdown
@@ -1,11 +0,0 @@
-# Generic Routes [routing-generic] #
-
-Slim provides the `map()` application instance method to define generic routes that are not immediately associated with an HTTP method.
-
- $app = new Slim();
- $app->map('/generic/route', function () {
- echo "I'm a generic route!";
- });
- $app->run();
-
-This example always returns a **404 Not Found** response because the "/generic/route" route does not respond to any HTTP methods. Use the [via()](#routing-custom) method (available on Route objects), to assign one or many HTTP methods to a generic route.
View
20 Slim/codeguy-Slim-aa7e919/docs/routing-get.markdown
@@ -1,20 +0,0 @@
-# GET Routes [routing-get] #
-
-Use the `get()` application instance method to map a callback function to a resource URI that is requested with the HTTP GET method.
-
- $app = new Slim();
-
- //For PHP >= 5.3
- $app->get('/books/:id', function ($id) {
- //Show book identified by $id
- });
-
- //For PHP < 5.3
- $app->get('/books/:id', 'show_book');
- function show_book($id) {
- //Show book identified by $id
- }
-
-In this example, an HTTP GET request for “/books/1” will invoke the associated callback function, passing “1” as the callback function argument.
-
-The first argument of the `get()` application instance method is the resource URI. The last argument is anything that returns `true` for `is_callable()`. I encourage you to use PHP >= 5.3 so you may take advantage of anonymous functions.
View
22 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-halt.markdown
@@ -1,22 +0,0 @@
-# Halt [routing-helpers-halt] #
-
-The `halt()` application instance method will immediately return an HTTP response with a given status code and body. This method accepts two arguments: the HTTP status code and an optional message. Slim will immediately halt the current application and send an HTTP response to the client with the specified status and optional message (as the response body). This will override the existing Response object.
-
- $app = new Slim();
-
- //Send a default 500 error response
- $app->halt(500);
-
- //Or if you encounter a Balrog...
- $app->halt(403, 'You shall not pass!');
-
-If you would like to render a template with a list of error messages, you should use the `render()` application instance method instead.
-
- $app = new Slim();
- $app->get('/foo', function () use ($app) {
- $errorData = array('error' => 'Permission Denied');
- $app->render('errorTemplate.php', $errorData, 403);
- });
- $app->run();
-
-The `halt()` application instance method may send any type of HTTP response to the client: informational, success, redirect, not found, client error, or server error.
View
13 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-pass.markdown
@@ -1,13 +0,0 @@
-# Pass [routing-helpers-pass] #
-
-A route can tell the Slim application to continue to the next matching route with the `pass()` application instance method. When this method is invoked, the Slim application will immediately stop processing the current matching route and invoke the next matching route. If no subsequent matching route is found, a **404 Not Found** response is sent to the client. Here is an example. Assume an HTTP request for "GET /hello/Frank".
-
- $app = new Slim();
- $app->get('/hello/Frank', function () use ($app) {
- echo "You won't see this...";
- $app->pass();
- });
- $app->get('/hello/:name', function ($name) use ($app) {
- echo "But you will see this!";
- });
- $app->run();
View
19 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-redirect.markdown
@@ -1,19 +0,0 @@
-# Redirect [routing-helpers-redirect] #
-
-It is easy to redirect the client to another URL with the `redirect()` application instance method. This method accepts two arguments: the first argument is the URL to which the client will redirect; the second optional argument is the HTTP status code. By default the `redirect()` application instance method will send an **HTTP 302 Temporary Redirect** response.
-
- $app = new Slim();
- $app->get('/foo', function () use ($app) {
- $app->redirect('/bar');
- });
- $app->run();
-
-Or if you wish to use a permanent redirect, you must specify the destination URL as the first parameter and the HTTP status code as the second parameter.
-
- $app = new Slim();
- $app->get('/old', function () use ($app) {
- $app->redirect('/new', 301);
- });
- $app->run();
-
-This method will automatically set the **Location:** header. The HTTP redirect response will be sent to the HTTP client immediately.
View
11 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-stop.markdown
@@ -1,11 +0,0 @@
-# Stop [routing-helpers-stop] #
-
-The `stop()` application instance method will stop the Slim application and send the current HTTP response to the client as is. No *ifs*, *ands*, or *buts*.
-
- $app = new Slim();
- $app->get('/foo', function () use ($app) {
- echo "You will see this...";
- $app->stop();
- echo "But not this";
- });
- $app->run();
View
15 Slim/codeguy-Slim-aa7e919/docs/routing-helpers-urlfor.markdown
@@ -1,15 +0,0 @@
-# URL For [routing-helpers-urlfor] #
-
-The `urlFor()` application instance method lets you dynamically create URLs *for a named route* so that, were a route pattern to change, your URLs would update automatically without breaking your application. This example demonstrates how to generate URLs for a named route.
-
- $app = new Slim();
-
- //Create a named route
- $app->get('/hello/:name', function ($name) use ($app) {
- echo "Hello $name";
- })->name('hello');
-
- //Generate a URL for the named route
- $url = $app->urlFor('hello', array('name' => 'Josh'));
-
-In this example, `$url` is "/hello/Josh". To use the `urlFor()` application instance method, you must first assign a name to a route. Next, invoke the `urlFor()` application instance method. The first argument is the name of the route, and the second argument is an associative array used to replace the route’s URL parameters with actual values; the array's keys must match parameters in the route's URI and the values will be used as substitutions.
View
3 Slim/codeguy-Slim-aa7e919/docs/routing-helpers.markdown
@@ -1,3 +0,0 @@
-# Route Helpers [routing-helpers] #
-
-Slim provides several helper methods (exposed via the `Slim` application instance) that will help you control the flow of your application.
View
17 Slim/codeguy-Slim-aa7e919/docs/routing-indepth-slashes.markdown
@@ -1,17 +0,0 @@
-# Trailing Slashes [routing-indepth-slashes] #
-
-Slim routes automatically provide pretty URLs and intelligent redirection — behavior very similar to the Apache web server. Here are two example routes:
-
- $app = new Slim();
-
- //This has a trailing slash
- $app->get('/services/', function () {});
-
- //This does not have a trailing slash
- $app->get('/contact', function () {});
-
-At first glance, both routes appear similar. However, in the first route example, the canonical URL for the services route has a trailing slash. It acts the same as a folder; accessing it without a trailing slash will prompt Slim to redirect to the canonical URL with the trailing slash.
-
-In the second example, the URL is defined without a trailing slash. Therefore, it behaves similar to a file. Accessing it with a trailing slash will result with a **404 Not Found** response.
-
-This behavior allows URLs to continue working if users access the page and forget the trailing slash. This is consistent with the Apache web server’s behavior. Because Slim automatically redirects URLs, search engines will always index the canonical URLs rather than index both the correct and incorrect URLs.
View
30 Slim/codeguy-Slim-aa7e919/docs/routing-indepth-with-rewrite.markdown
@@ -1,30 +0,0 @@
-# URL Rewriting [routing-indepth-with-rewrite] #
-
-I strongly encourage you to use a web server that supports URL rewriting; this will let you enjoy clean, human-friendly URLs with your Slim application. To enable URL rewriting, you should use the appropriate tools provided by your web server to forward all HTTP requests to the PHP file in which you instantiate and run your Slim application.
-
-I am most familiar with the Apache web server, so my examples below demonstrate how to setup a Slim application with Apache and mod_rewrite.
-
-Here is an example directory structure:
-
- www.mysite.com/
- public_html/ <-- Document root!
- .htaccess
- index.php <-- I instantiate Slim here!
- lib/
- Slim/ <-- I store Slim lib files here!
-
-The **.htaccess** file in the directory structure above contains:
-
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^(.*)$ index.php [QSA,L]
-
-As a result, Apache will send all requests for non-existent files to my **index.php** script in which I instantiate and run my Slim application. With URL rewriting enabled and assuming the following Slim application is defined in **index.php**, you can access the application route below at "/foo" rather than "/index.php/foo".
-
- $app = new Slim();
- $app->get('/foo', function () {
- echo "Foo!";
- });
- $app->run();
-
-This process will act very much the same for nginx, except that you will define the URL rewriting in your nginx configuration file rather than in a **.htaccess** file. I will defer to those more intelligent than me to demonstrate nginx configuration.
View
11 Slim/codeguy-Slim-aa7e919/docs/routing-indepth-without-rewrite.markdown
@@ -1,11 +0,0 @@
-# Without URL Rewriting [routing-indepth-without-rewrite] #
-
-Slim will work without URL rewriting. In this scenario, you must include the name of the PHP file in which you instantiate and run the Slim application in the resource URI. For example, assume the following Slim application is defined in **index.php** at the top level of your virtual host's document root:
-
- $app = new Slim();
- $app->get('/foo', function () {
- echo "Foo!";
- });
- $app->run();
-
-You can access the defined route at "/index.php/foo". If the same application is instead defined in **index.php** inside of the physical subdirectory **blog/**, you can access the defined route at **/blog/index.php/foo**.
View
13 Slim/codeguy-Slim-aa7e919/docs/routing-indepth.markdown
@@ -1,13 +0,0 @@
-# Routing In-Depth [routing-indepth] #
-
-Slim's routing methods, described earlier, help you map a resource URI to a callback function for a given HTTP method (or for multiple HTTP methods). This is the simplest explanation of Slim's router. However, there is more than meets the eye.
-
-When you invoke a routing method (e.g `get()`, `post()`, `put()`, etc.) to define a route, you are actually telling Slim to create a Route object that responds to the respective HTTP request method. The Route object will know its resource URI, its callback, and the HTTP methods to which it responds. You may further assign [names](#routing-names) and [conditions](#routing-conditions) to a Route object.
-
-When you invoke your app's `run()` method, Slim will determine the current HTTP request's method and URI. Slim next iterates over each route in your application in the order they were defined. If a route's URI matches the HTTP request's URI, Slim asks the matching route if it answers to the current HTTP request's method. If yes, the route's callback is invoked; if no, the Route is ignored but Slim remembers the HTTP methods to which that Route *does* respond (more on this in a bit).
-
-If a route matches both the current HTTP request's URI and method, Slim will invoke that Route's callback and send the eventual HTTP response to the client. Subsequent route objects will not be iterated.
-
-If Slim finds routes that match the HTTP request URI but not the HTTP request method, Slim will return a **405 Method Not Allowed** response with an **Allow:** header that lists the HTTP methods to which the found routes do respond (as I alluded to above).
-
-If Slim does not find routes that match the HTTP request URI, Slim will return a **404 Not Found** response.
View
49 Slim/codeguy-Slim-aa7e919/docs/routing-middleware.markdown
@@ -1,49 +0,0 @@
-# Route Middleware [routing-middleware] #
-
-Slim enables you to associate middleware with a specific application route. When the given route matches the current HTTP request and is invoked, Slim will first invoke the associated middleware in the order they are defined.
-
-## What is Route Middleware?
-
-Route middleware is anything that returns true for is_callable.
-
-## How do I Add Route Middleware?
-
-When you define a new application route with the Slim application's `get()`, `post()`, `put()`, or `delete()` methods you must define a route pattern and a callable to be invoked when the route matches an HTTP request.
-
- $app = new Slim();
- $app->get('/foo', function () {
- //Do something
- });
-
-In the example above, the first argument is the route pattern. The last argument is the callable to be invoked when the route matches the current HTTP request. The route pattern must always be the first argument. The route callable must always be the last argument.
-
-You can assign middleware to this route by passing each middleware as a separate interior or... (ahem) middle... argument like this:
-
- function myMiddleware1() {
- echo "This is middleware!";
- }
- function myMiddleware2() {
- echo "This is middleware!";
- }
- $app = new Slim();
- $app->get('/foo', 'myMiddleware', 'myMiddleware2', function () {
- //Do something
- });
-
-When the **/foo** route matches the current HTTP request, the `myMiddleware1` and `myMiddleware2` functions will be invoked in sequence before the route’s callable.
-
-If you are running PHP >= 5.3, you can get a bit more creative. Suppose you wanted to authenticate the current user against a given role for a specific route. You could use some closure magic like this:
-
- $authenticateForRole = function ( $role = 'member' ) {
- return function () use ( $role ) {
- $user = User::fetchFromDatabaseSomehow();
- if ( $user->belongsToRole($role) === false ) {
- Slim::flash('error', 'Login required');
- Slim::redirect('/login');
- }
- }
- }
- $app = new Slim();
- $app->get('/foo', $authenticateForRole('admin'), function () {
- //Display admin control panel
- });
View
15 Slim/codeguy-Slim-aa7e919/docs/routing-names.markdown
@@ -1,15 +0,0 @@
-# Named Routes [routing-names] #
-
-Slim lets you assign a name to a route. Naming a route enables you to dynamically generate URLs using the [urlFor](#routing-helpers-urlfor) helper method. When you use the `urlFor()` application instance method to create application URLs, you can freely change route patterns without breaking your application. Here is an example of a named route:
-
- $app = new Slim();
- $app->get('/hello/:name', function ($name) {
- echo "Hello, $name!";
- })->name('hello');
-
-You may now generate URLs for this route using the `urlFor()` application instance method, described later in this documentation. The route `name()` method is also chainable:
-
- $app = new Slim();
- $app->get('/hello/:name', function ($name) {
- echo "Hello, $name!";
- })->name('hello')->conditions(array('name' => '\w+'));
View
30 Slim/codeguy-Slim-aa7e919/docs/routing-options.markdown
@@ -1,30 +0,0 @@
-# OPTIONS Routes [routing-options] #
-
-Use the `options()` application instance method to map a callback function to a resource URI that is requested with the HTTP OPTIONS method.
-
- $app = new Slim();
-
- //For PHP 5 >= 5.3
- $app->options('/books/:id', function ($id) {
- //Provide options for this resource to the client
- });
-
- //For PHP 5 < 5.3
- $app->options('/books/:id', 'options_book');
- function options_book($id) {
- //Provide options for this resource to the client
- }
-
-In this example, an HTTP OPTIONS request for “/books/1” will invoke the associated callback function.
-
-The first argument of the `options()` application instance method is the resource URI. The last argument is anything that returns `true` for `is_callable()`. I encourage you to use PHP >= 5.3 so you may take advantage of anonymous functions.
-
-## Method Override ##
-
-Unfortunately, modern browsers do not provide native support for HTTP OPTIONS requests. To work around this limitation, ensure your HTML form’s **method** attribute is “post”, then add a method override parameter to your HTML form like this:
-
- <form action="/books/1" method="post">
- ... other form fields here...
- <input type="hidden" name="_METHOD" value="OPTIONS"/>
- <input type="submit" value="Get Options For Book"/>
- </form>
View
40 Slim/codeguy-Slim-aa7e919/docs/routing-parameters.markdown
@@ -1,40 +0,0 @@
-# Route Parameters [routing-parameters] #
-
-You can embed parameters into route resource URIs. In this example, I have two parameters in my route URI, “:one” and “:two”.
-
- $app = new Slim();
-
- //For PHP >= 5.3
- $app->get('/books/:one/:two', function ($one, $two) {
- echo "The first paramter is " . $one;
- echo "The second parameter is " . $two;
- });
-
- //For PHP < 5.3
- $app->get('/books/:one/:two', 'callback_name');
- function callback_name($one, $two) {
- echo "The first paramter is " . $one;
- echo "The second parameter is " . $two;
- }
-
-T