├── CNAME ├── _layouts ├── blank.html └── default.html ├── assets ├── images │ ├── favicon.png │ ├── logo-256.png │ ├── logo-small.png │ ├── modx-logo.png │ ├── swag-shirt.png │ ├── slim-elephant.png │ ├── 200x200-Typo-Grey.png │ ├── 200x200-Typo-White.png │ └── swag-sticker-text.png ├── fonts │ ├── FontAwesome.otf │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ ├── fontawesome-webfont.woff2 │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── discourse │ ├── slim-avatar.png │ └── slim-discourse-logo.png ├── less │ ├── variables.less │ ├── fontawesome │ │ ├── fixed-width.less │ │ ├── bordered-pulled.less │ │ ├── larger.less │ │ ├── list.less │ │ ├── font-awesome.less │ │ ├── core.less │ │ ├── stacked.less │ │ ├── rotated-flipped.less │ │ ├── path.less │ │ ├── animated.less │ │ └── mixins.less │ ├── components │ │ ├── footer.less │ │ ├── all.less │ │ ├── share.less │ │ ├── anchors.less │ │ ├── header.less │ │ ├── notes.less │ │ ├── buttons.less │ │ └── swag.less │ ├── all.less │ └── typography.less ├── bootstrap │ └── less │ │ ├── mixins │ │ ├── center-block.less │ │ ├── text-emphasis.less │ │ ├── size.less │ │ ├── background-variant.less │ │ ├── opacity.less │ │ ├── text-overflow.less │ │ ├── tab-focus.less │ │ ├── labels.less │ │ ├── resize.less │ │ ├── progress-bar.less │ │ ├── nav-divider.less │ │ ├── reset-filter.less │ │ ├── alerts.less │ │ ├── nav-vertical-align.less │ │ ├── responsive-visibility.less │ │ ├── pagination.less │ │ ├── border-radius.less │ │ ├── panels.less │ │ ├── list-group.less │ │ ├── hide-text.less │ │ ├── clearfix.less │ │ ├── table-row.less │ │ ├── image.less │ │ └── buttons.less │ │ ├── .csslintrc │ │ ├── wells.less │ │ ├── breadcrumbs.less │ │ ├── responsive-embed.less │ │ ├── component-animations.less │ │ ├── close.less │ │ ├── thumbnails.less │ │ ├── utilities.less │ │ ├── media.less │ │ ├── pager.less │ │ ├── jumbotron.less │ │ ├── mixins.less │ │ ├── bootstrap.less │ │ ├── labels.less │ │ ├── badges.less │ │ ├── code.less │ │ ├── grid.less │ │ └── alerts.less └── scripts │ └── src │ └── setup.js ├── .gitignore ├── docs ├── v3 │ ├── images │ │ └── middleware.png │ ├── contributors │ │ ├── strategy.md │ │ └── guidelines.md │ ├── start │ │ └── installation.md │ ├── cookbook │ │ ├── ip-address.md │ │ ├── retrieving-current-route.md │ │ └── route-patterns.md │ ├── features │ │ └── flash.md │ └── handlers │ │ └── not-allowed.md ├── v4 │ ├── images │ │ └── middleware.png │ ├── concepts │ │ └── index.md │ ├── objects │ │ └── index.md │ ├── start │ │ └── index.md │ ├── cookbook │ │ ├── index.md │ │ ├── route-patterns.md │ │ └── retrieving-current-route.md │ ├── middleware │ │ ├── index.md │ │ ├── content-length.md │ │ ├── method-overriding.md │ │ ├── routing.md │ │ ├── output-buffering.md │ │ └── body-parsing.md │ ├── contributors │ │ ├── index.md │ │ ├── strategy.md │ │ └── guidelines.md │ └── features │ │ ├── templates.md │ │ └── php-view.md └── v2 │ ├── flash │ ├── keep.md │ ├── next.md │ ├── now.md │ └── overview.md │ ├── request │ ├── body.md │ ├── content-types.md │ ├── overview.md │ ├── xhr.md │ ├── headers.md │ ├── method.md │ ├── variables.md │ ├── cookies.md │ └── paths.md │ ├── view │ ├── overview.md │ ├── rendering.md │ └── data.md │ ├── routing │ ├── overview.md │ ├── post.md │ ├── get.md │ ├── patch.md │ ├── names.md │ ├── groups.md │ ├── put.md │ ├── delete.md │ ├── options.md │ └── custom.md │ ├── sessions │ ├── native.md │ └── cookies.md │ ├── hooks │ ├── overview.md │ ├── custom.md │ ├── how-to-use.md │ └── defaults.md │ ├── logging │ ├── activate.md │ ├── overview.md │ ├── levels.md │ └── writers.md │ ├── errors │ ├── overview.md │ ├── debug.md │ ├── output.md │ ├── 500.md │ └── 404.md │ ├── response │ ├── status.md │ ├── overview.md │ ├── headers.md │ └── body.md │ ├── cache │ ├── overview.md │ ├── expires.md │ ├── etag.md │ └── lastmodified.md │ ├── middleware │ ├── how-to-write.md │ └── how-to-use.md │ ├── start │ └── get-started.md │ ├── index.md │ ├── configuration │ └── overview.md │ └── di │ └── overview.md ├── 404.html ├── _posts ├── 2015-06-09-slim3-primer.md ├── 2019-04-16-slim-3.12.1.md ├── 2019-08-20-slim-3.12.2.md ├── 2017-03-19-slim-3.8.1.md ├── 2012-04-22-version-162.md ├── 2017-01-07-slim-2.6.3.md ├── 2016-03-05-slim-3.2.2.md ├── 2012-08-28-version-167.md ├── 2016-05-25-slim-3.4.2.md ├── 2019-11-28-slim-3.12.3-release.md ├── 2025-08-24-slim-4.15.0-release.md ├── 2012-02-08-net-magazine-and-slim.md ├── 2016-07-26-slim-3.5.0.md ├── 2016-12-20-slim-3.7.0.md ├── 2015-03-01-version-260.md ├── 2015-05-21-slim-treehouse.md ├── 2013-08-22-zend-software.md ├── 2025-11-21-slim-4.15.1-release.md ├── 2012-04-22-composer-and-packagist.md ├── 2019-01-15-slim-3.12.0.md ├── 2012-07-31-version-165.md ├── 2016-11-20-slim-3.6.0.md ├── 2012-07-25-pagodabox-quickstart.md ├── 2012-06-24-version-164.md ├── 2017-03-18-slim-3.8.0.md ├── 2016-03-14-tutorial-for-slim-3.md ├── 2018-04-19-slim-3.10.0.md ├── 2016-03-10-slim-3.3.0.md ├── 2016-03-01-slim-3.2.1.md ├── 2016-05-16-slim-3.4.1.md ├── 2020-11-30-slim-4.7.0-release.md ├── 2018-09-16-slim-3.11.0.md ├── 2011-11-16-slim-framework-and-phpfog.md ├── 2017-11-04-slim-3.9.0.md ├── 2012-06-17-version-163.md ├── 2019-08-06-slim-4.1.0-release.md ├── 2012-02-18-slim-framework-moves-to-pagodabox.md ├── 2011-12-26-multimarkdown-community-documentation.md ├── 2011-12-29-version-numbers.md ├── 2015-02-23-modx-cms-and-slim.md ├── 2012-04-21-version-161.md ├── 2015-02-25-slim-github-organization.md ├── 2020-04-14-slim-4.5.0-release.md ├── 2012-08-27-version-166.md ├── 2016-11-27-starting-slim-framework-v4.md ├── 2012-08-29-moving-forward.md ├── 2011-12-27-support-forum-now-uses-tender.md ├── 2013-03-24-cookie-handling-updates.md ├── 2017-11-26-slim-3.9.1.md ├── 2012-07-04-skeleton-application.md ├── 2016-01-08-slim-3.1.0.md ├── 2021-10-04-slim-4.9.0-release.md ├── 2016-02-25-slim-3.2.0.md ├── 2024-06-13-slim-4.14.0-release.md ├── 2023-04-17-slim-psr7-advisory-CVE-2023-30536.md ├── 2019-10-05-slim-4.3.0-release.md └── 2011-09-15-hello-world.md ├── .github └── dependabot.yml ├── package.json ├── Gemfile ├── _includes ├── nav.html ├── version-selector.html ├── maintainers.html ├── footer.html └── search-box.html ├── blog ├── index.html └── feed.rss └── README.md /CNAME: -------------------------------------------------------------------------------- 1 | www.slimframework.com 2 | -------------------------------------------------------------------------------- /_layouts/blank.html: -------------------------------------------------------------------------------- 1 | {{ content }} 2 | -------------------------------------------------------------------------------- /assets/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/favicon.png -------------------------------------------------------------------------------- /assets/images/logo-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/logo-256.png -------------------------------------------------------------------------------- /assets/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /assets/images/logo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/logo-small.png -------------------------------------------------------------------------------- /assets/images/modx-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/modx-logo.png -------------------------------------------------------------------------------- /assets/images/swag-shirt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/swag-shirt.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | package-lock.json 4 | _site 5 | .DS_Store 6 | /.idea/ 7 | /.vscode/ 8 | -------------------------------------------------------------------------------- /assets/images/slim-elephant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/slim-elephant.png -------------------------------------------------------------------------------- /docs/v3/images/middleware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/docs/v3/images/middleware.png -------------------------------------------------------------------------------- /docs/v4/images/middleware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/docs/v4/images/middleware.png -------------------------------------------------------------------------------- /assets/discourse/slim-avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/discourse/slim-avatar.png -------------------------------------------------------------------------------- /assets/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /assets/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /assets/images/200x200-Typo-Grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/200x200-Typo-Grey.png -------------------------------------------------------------------------------- /assets/images/200x200-Typo-White.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/200x200-Typo-White.png -------------------------------------------------------------------------------- /assets/images/swag-sticker-text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/images/swag-sticker-text.png -------------------------------------------------------------------------------- /assets/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /assets/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /assets/less/variables.less: -------------------------------------------------------------------------------- 1 | @baseline: 24px; 2 | 3 | @green: #719E40; 4 | @primary-grey: #282A36; 5 | @primary-light-grey: #333540; -------------------------------------------------------------------------------- /assets/discourse/slim-discourse-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/discourse/slim-discourse-logo.png -------------------------------------------------------------------------------- /docs/v4/concepts/index.md: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /docs/v4/objects/index.md: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /docs/v4/start/index.md: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /assets/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /assets/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /assets/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /docs/v4/cookbook/index.md: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /docs/v4/middleware/index.md: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | --- 2 | # example 404.md 3 | 4 | layout: default 5 | permalink: /404.html 6 | --- 7 | 8 | # 404 9 | 10 | Page not found! :( 11 | -------------------------------------------------------------------------------- /assets/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slimphp/Slim-Website/HEAD/assets/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /docs/v4/contributors/index.md: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /assets/less/fontawesome/fixed-width.less: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .@{fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /assets/less/components/footer.less: -------------------------------------------------------------------------------- 1 | .site-footer{ 2 | border-top: 1px solid #CCC; 3 | margin-top: @baseline * 2; 4 | padding: @baseline 0; 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/center-block.less: -------------------------------------------------------------------------------- 1 | // Center-align a block level element 2 | 3 | .center-block() { 4 | display: block; 5 | margin-left: auto; 6 | margin-right: auto; 7 | } 8 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/text-emphasis.less: -------------------------------------------------------------------------------- 1 | // Typography 2 | 3 | .text-emphasis-variant(@color) { 4 | color: @color; 5 | a&:hover { 6 | color: darken(@color, 10%); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /assets/less/components/all.less: -------------------------------------------------------------------------------- 1 | @import "header"; 2 | @import "buttons"; 3 | @import "notes"; 4 | @import "share"; 5 | @import "footer"; 6 | @import "swag"; 7 | @import "docs"; 8 | @import "anchors"; 9 | -------------------------------------------------------------------------------- /assets/less/components/share.less: -------------------------------------------------------------------------------- 1 | .share{ 2 | a{ 3 | display: inline-block; 4 | margin: 0 @baseline/2; 5 | font-size: 36px; 6 | line-height: @baseline*2; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/size.less: -------------------------------------------------------------------------------- 1 | // Sizing shortcuts 2 | 3 | .size(@width; @height) { 4 | width: @width; 5 | height: @height; 6 | } 7 | 8 | .square(@size) { 9 | .size(@size; @size); 10 | } 11 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/background-variant.less: -------------------------------------------------------------------------------- 1 | // Contextual backgrounds 2 | 3 | .bg-variant(@color) { 4 | background-color: @color; 5 | a&:hover { 6 | background-color: darken(@color, 10%); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/opacity.less: -------------------------------------------------------------------------------- 1 | // Opacity 2 | 3 | .opacity(@opacity) { 4 | opacity: @opacity; 5 | // IE8 filter 6 | @opacity-ie: (@opacity * 100); 7 | filter: ~"alpha(opacity=@{opacity-ie})"; 8 | } 9 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/text-overflow.less: -------------------------------------------------------------------------------- 1 | // Text overflow 2 | // Requires inline-block or block for proper styling 3 | 4 | .text-overflow() { 5 | overflow: hidden; 6 | text-overflow: ellipsis; 7 | white-space: nowrap; 8 | } 9 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/tab-focus.less: -------------------------------------------------------------------------------- 1 | // WebKit-style focus 2 | 3 | .tab-focus() { 4 | // Default 5 | outline: thin dotted; 6 | // WebKit 7 | outline: 5px auto -webkit-focus-ring-color; 8 | outline-offset: -2px; 9 | } 10 | -------------------------------------------------------------------------------- /_layouts/default.html: -------------------------------------------------------------------------------- 1 | {% include header.html %} 2 | 3 |
4 |
5 | {{ content }} 6 | {% include maintainers.html %} 7 |
8 |
9 | 10 | {% include footer.html %} 11 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/labels.less: -------------------------------------------------------------------------------- 1 | // Labels 2 | 3 | .label-variant(@color) { 4 | background-color: @color; 5 | 6 | &[href] { 7 | &:hover, 8 | &:focus { 9 | background-color: darken(@color, 10%); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/resize.less: -------------------------------------------------------------------------------- 1 | // Resize anything 2 | 3 | .resizable(@direction) { 4 | resize: @direction; // Options: horizontal, vertical, both 5 | overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible` 6 | } 7 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/progress-bar.less: -------------------------------------------------------------------------------- 1 | // Progress bars 2 | 3 | .progress-bar-variant(@color) { 4 | background-color: @color; 5 | 6 | // Deprecated parent class requirement as of v3.2.0 7 | .progress-striped & { 8 | #gradient > .striped(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /_posts/2015-06-09-slim3-primer.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3 Primer by Rob Allen 3 | description: Learn what's new in Slim 3.0 4 | layout: post 5 | --- 6 | 7 | [Rob Allen](http://akrabat.com/) presents a primer on Slim 3.0 at a recent PHPSW meetup. Watch the video at . 8 | -------------------------------------------------------------------------------- /docs/v3/contributors/strategy.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Branching Strategy 3 | --- 4 | 5 | The Slim Framework uses a simple branching strategy. There is a `3.x` branch, and the `3.x` branch `HEAD` reference points to the latest unstable code. Each stable release is denoted with a numeric tag (e.g., `3.0.0`). 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: bundler 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | open-pull-requests-limit: 10 8 | versioning-strategy: increase 9 | ignore: 10 | - dependency-name: github-pages 11 | versions: 12 | - "210" 13 | -------------------------------------------------------------------------------- /_posts/2019-04-16-slim-3.12.1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.12.1 released 3 | description: Slim 3.12.1 released 4 | layout: post 5 | --- 6 | 7 | Minor bug fixes and RFC compliance updates. 8 | 9 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.12.1+is%3Aclosed) 10 | -------------------------------------------------------------------------------- /docs/v4/contributors/strategy.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Branching Strategy 3 | --- 4 | 5 | The Slim Framework uses a simple branching strategy. 6 | There is a `4.x` branch, and the `4.x` branch `HEAD` reference points to the latest unstable code. 7 | Each stable release is denoted with a numeric tag (e.g., `4.0.0`). 8 | -------------------------------------------------------------------------------- /_posts/2019-08-20-slim-3.12.2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.12.2 released 3 | description: Slim 3.12.2 released 4 | layout: post 5 | --- 6 | 7 | This is the last release for Slim 3. Minor bug fixes and improvements. 8 | 9 | The full list of changes is [here](https://github.com/slimphp/Slim/releases/tag/3.12.2) 10 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/nav-divider.less: -------------------------------------------------------------------------------- 1 | // Horizontal dividers 2 | // 3 | // Dividers (basically an hr) within dropdowns and nav lists 4 | 5 | .nav-divider(@color: #e5e5e5) { 6 | height: 1px; 7 | margin: ((@line-height-computed / 2) - 1) 0; 8 | overflow: hidden; 9 | background-color: @color; 10 | } 11 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/reset-filter.less: -------------------------------------------------------------------------------- 1 | // Reset filters for IE 2 | // 3 | // When you need to remove a gradient background, do not forget to use this to reset 4 | // the IE filter for IE9 and below. 5 | 6 | .reset-filter() { 7 | filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)")); 8 | } 9 | -------------------------------------------------------------------------------- /docs/v2/flash/keep.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Keep 3 | --- 4 | This method tells the Slim application to keep existing flash messages set in the previous request so they will be 5 | available to the next request. This method is helpful for persisting flash messages across HTTP redirects. 6 | 7 | flashKeep(); 9 | -------------------------------------------------------------------------------- /docs/v2/flash/next.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Next 3 | --- 4 | The Slim application’s `flash()` method sets a message that will be available in the next request’s view templates. 5 | The message in this example will be available in the template variable `flash['error']`. 6 | 7 | flash('error', 'User email is required'); 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "slim-website", 3 | "version": "0.1.0", 4 | "devDependencies": { 5 | "grunt": "^1.4.0", 6 | "grunt-contrib-concat": "^1.0.1", 7 | "grunt-contrib-less": "^3.0.0", 8 | "grunt-contrib-uglify": "^5.0.1", 9 | "grunt-contrib-watch": "^1.1.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /docs/v2/request/body.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Body 3 | --- 4 | Use the request object's `getBody()` method to fetch the raw HTTP request body sent by the HTTP client. This is 5 | particularly useful for Slim application's that consume JSON or XML requests. 6 | 7 | request->getBody(); 10 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/alerts.less: -------------------------------------------------------------------------------- 1 | // Alerts 2 | 3 | .alert-variant(@background; @border; @text-color) { 4 | background-color: @background; 5 | border-color: @border; 6 | color: @text-color; 7 | 8 | hr { 9 | border-top-color: darken(@border, 5%); 10 | } 11 | .alert-link { 12 | color: darken(@text-color, 10%); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /assets/less/components/anchors.less: -------------------------------------------------------------------------------- 1 | .docs-content { 2 | h2, h3 { 3 | display: table; 4 | border-bottom: dotted 1px transparent; 5 | 6 | &:hover { 7 | cursor: pointer; 8 | border-color: #333;; 9 | } 10 | } 11 | } 12 | html, body { 13 | scroll-padding-top: @navbar-height; 14 | } 15 | -------------------------------------------------------------------------------- /_posts/2017-03-19-slim-3.8.1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.8.1 released 3 | description: Slim 3.8.1 released 4 | layout: post 5 | --- 6 | 7 | A [BC break](https://github.com/slimphp/Slim/issues/2176) was found in 3.8.0. Version 3.8.1 fixes it. 8 | 9 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.8.1+is%3Aclosed) 10 | -------------------------------------------------------------------------------- /assets/less/components/header.less: -------------------------------------------------------------------------------- 1 | .site-header { 2 | padding: 0 0 @baseline 0; 3 | } 4 | .site-title { 5 | .brandonLight; 6 | color: @green; 7 | font-size: @baseline * 5; 8 | letter-spacing: -3px; 9 | line-height: @baseline * 5; 10 | text-align: center; 11 | } 12 | .site-slogan { 13 | color: #AAA; 14 | font-size: 18px; 15 | text-align: center; 16 | } 17 | -------------------------------------------------------------------------------- /docs/v2/view/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | A Slim application delegates rendering of templates to its view object. A Slim application view is a subclass 5 | of `\Slim\View` that implements this interface: 6 | 7 | flashNow('info', 'Your credit card is expired'); 10 | -------------------------------------------------------------------------------- /_posts/2017-01-07-slim-2.6.3.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 2.6.3 released 3 | description: Slim 2.6.3 released 4 | layout: post 5 | --- 6 | 7 | We have released a new version of Slim 2! 8 | 9 | Slim 2.6.3 handles the deprecation of mcrypt in PHP 7.1. It also add support for 10 | IPv6 addresses in HTTP_HOST and escapes HTML when displaying exceptions. 11 | 12 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A2.6.3+is%3Aclosed) 13 | 14 | -------------------------------------------------------------------------------- /docs/v2/routing/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | The Slim Framework helps you map resource URIs to callback functions for specific HTTP request methods (e.g. GET, POST, PUT, DELETE, OPTIONS or HEAD). A Slim application will invoke the first route that matches the current HTTP request’s URI and method. 5 | 6 | If the Slim application does not find routes with URIs that match the HTTP request URI and method, it will automatically return a 404 Not Found response. 7 | -------------------------------------------------------------------------------- /assets/less/all.less: -------------------------------------------------------------------------------- 1 | @import "variables"; 2 | @import "typography"; 3 | @import "layout"; 4 | @import "prism"; 5 | @import "fontawesome/font-awesome"; 6 | @import "components/all"; 7 | 8 | html { 9 | margin: 0; 10 | padding: 0; 11 | } 12 | 13 | body { 14 | margin: 0; 15 | padding: 96px 0; 16 | } 17 | 18 | a code { 19 | color: @green; 20 | } 21 | 22 | .highlighter-rouge { 23 | background: #EEE; 24 | font-size: 12px; 25 | font-weight: 400; 26 | } 27 | -------------------------------------------------------------------------------- /assets/less/components/notes.less: -------------------------------------------------------------------------------- 1 | .note{ 2 | margin: 0 0 @baseline 0; 3 | 4 | .note-title{ 5 | margin: 0 0 @baseline/2 0; 6 | .latoLight; 7 | } 8 | .note-publish-datetime{ 9 | .latoLight; 10 | color: #777; 11 | font-size: 16px; 12 | } 13 | .note-footer{ 14 | margin-top: @baseline; 15 | text-align: center; 16 | 17 | .share-title{ 18 | margin-top: 0; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /_posts/2016-03-05-slim-3.2.2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.2.2 released 3 | description: Slim 3.2.2 released 4 | layout: post 5 | --- 6 | 7 | Another BC break has been found in the 3.2 series, so version [3.2.2](https://github.com/slimphp/Slim/releases/tag/3.2.2) resolves issue [(#1798)](https://github.com/slimphp/Slim/issues/1798). 8 | 9 | The only change is: 10 | 11 | ## Fixed 12 | 13 | * [#1799](https://github.com/slimphp/Slim/pull/1799) - Make $file public in UploadedFile. 14 | 15 | 16 | -------------------------------------------------------------------------------- /assets/less/fontawesome/list.less: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: @fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: (-@fa-li-width + (4em / 14)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /_posts/2012-08-28-version-167.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework Version 1.6.7 3 | description: Slim Framework 1.6.7 is a minor update recommended for all users 4 | layout: post 5 | --- 6 | 7 | I’ve just released Slim Framework 1.6.7. This minor release is recommended for everyone and includes the following changes: 8 | 9 | * Re-add mcrypt constant definitions if mcrypt extension not loaded 10 | * Bump inline code documentation version numbers 11 | * Remove obsolete application default setting 12 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'github-pages' 3 | gem 'activesupport', '~> 8.1' 4 | 5 | # Jekyll Plugins 6 | group :jekyll_plugins do 7 | gem 'jekyll-algolia' 8 | end 9 | 10 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 11 | gem 'wdm', '>= 0.1.0' 12 | gem 'tzinfo', '~> 2.0' 13 | gem 'tzinfo-data', '~> 1.2', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 14 | 15 | # Since Ruby 3.0 webrick isn't included in Ruby anymore. 16 | gem "webrick", "~> 1.9" 17 | -------------------------------------------------------------------------------- /_posts/2016-05-25-slim-3.4.2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.4.2 released 3 | description: Slim 3.4.2 released 4 | layout: post 5 | --- 6 | 7 | 3.4.1 had a BC break when handling errors where the acceptable media type listed in the Accept header wasn't the first one. This is now fixed. 8 | 9 | Also, with this release, we set the `App::VERSION` constant to the correct number. 10 | 11 | Total issues resolved: **1** 12 | - [1893: Ensure determineContentType() returns a valid result](https://github.com/slimphp/Slim/pull/1893) 13 | 14 | -------------------------------------------------------------------------------- /_posts/2019-11-28-slim-3.12.3-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.12.3 released 3 | description: Slim 3.12.3 released 4 | layout: post 5 | --- 6 | 7 | We are excited to announce the Slim 3.12.3 release. 8 | 9 | # Changelog 10 | 11 | ## 3.12.3 - 2019-11-28 12 | 13 | ### Fixed 14 | - [2885](https://github.com/slimphp/Slim/pull/2885) Replace abandoned `container-interop/container-interop` package with `psr/container` 15 | 16 | ### Removed 17 | - [2880](https://github.com/slimphp/Slim/pull/2880) Remove phpdoc inheritdoc override 18 | -------------------------------------------------------------------------------- /_posts/2025-08-24-slim-4.15.0-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 4.15.0 released 3 | description: Slim 4.15.0 released 4 | layout: post 5 | --- 6 | 7 | Slim 4.15.0 has been released. 8 | 9 | The most important thing to note with this release is that we have deprecated `RouteInterface::setArgument()` and `RouteInterface::setArguments()`. You should use middleware to set custom route arguments. 10 | 11 | Various other minor improvements and bug fixes have also been made, with the full changelog [here](https://github.com/slimphp/Slim/releases/tag/4.15.0). 12 | 13 | -------------------------------------------------------------------------------- /assets/less/components/buttons.less: -------------------------------------------------------------------------------- 1 | .slim-button { 2 | background-color: @green; 3 | border-radius: 4px; 4 | display: block; 5 | padding: @baseline/2 0; 6 | width: 100%; 7 | text-align: center; 8 | 9 | i { 10 | color: #FFF; 11 | font-size: 32px; 12 | line-height: @baseline * 2; 13 | } 14 | 15 | span { 16 | color: #FFF; 17 | display: block; 18 | .latoLight; 19 | font-size: 18px; 20 | } 21 | 22 | &:hover { 23 | text-decoration: none; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /_posts/2012-02-08-net-magazine-and-slim.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Mentioned in .NET Magazine 3 | description: The Slim Framework for PHP 5 was mentioned by Lorna Jane in her opinion piece for .NET magazine 4 | layout: post 5 | --- 6 | 7 | Today Slim was mentioned by [Lorna Mitchell](http://www.twitter.com/lornajane) in her latest opinion piece for [.NET Magazine](http://www.netmagazine.com/) that analyzes the current landscape of PHP frameworks. Head on over to read her article, [Land of a Thousand Frameworks](http://www.netmagazine.com/opinions/php-land-thousand-frameworks). 8 | -------------------------------------------------------------------------------- /docs/v2/sessions/native.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Native 3 | --- 4 | A Slim application does not presume anything about sessions. If you prefer to use a PHP session, you must configure 5 | and start a native PHP session with `session_start()` before you instantiate the Slim application. 6 | 7 | You should also disable PHP’s session cache limiter so that PHP does not send conflicting cache expiration headers 8 | with the HTTP response. You can disable PHP’s session cache limiter with: 9 | 10 | li { 5 | > a, 6 | > span { 7 | padding: @padding-vertical @padding-horizontal; 8 | font-size: @font-size; 9 | } 10 | &:first-child { 11 | > a, 12 | > span { 13 | .border-left-radius(@border-radius); 14 | } 15 | } 16 | &:last-child { 17 | > a, 18 | > span { 19 | .border-right-radius(@border-radius); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /_posts/2016-07-26-slim-3.5.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.5.0 released 3 | description: Slim 3.5.0 released 4 | layout: post 5 | --- 6 | 7 | A few useful bug fixes in this release including the ability to read the 'Authorization' header without tweaking .htaccess files or manually looking in `getallheaders`()! 8 | 9 | We have also added `getCookieParam()` to the `Request` class. Also this release continues our efforts to improve the unit test coverage of the framework. 10 | 11 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.5.0+is%3Aclosed) 12 | -------------------------------------------------------------------------------- /_posts/2016-12-20-slim-3.7.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.7.0 released 3 | description: Slim 3.7.0 released 4 | layout: post 5 | --- 6 | 7 | Slim 3.7.0 is a small release containing a one bug fixes and a new feature: we now pass the Exception into the NotFoundHandler so that custom handlers have access to this additional information. If you work with cookies, then you'll be glad to know that we have fixed a bug in our cookie parser so that commas are handled properly! 8 | 9 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.7.0+is%3Aclosed) 10 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/border-radius.less: -------------------------------------------------------------------------------- 1 | // Single side border-radius 2 | 3 | .border-top-radius(@radius) { 4 | border-top-right-radius: @radius; 5 | border-top-left-radius: @radius; 6 | } 7 | .border-right-radius(@radius) { 8 | border-bottom-right-radius: @radius; 9 | border-top-right-radius: @radius; 10 | } 11 | .border-bottom-radius(@radius) { 12 | border-bottom-right-radius: @radius; 13 | border-bottom-left-radius: @radius; 14 | } 15 | .border-left-radius(@radius) { 16 | border-bottom-left-radius: @radius; 17 | border-top-left-radius: @radius; 18 | } 19 | -------------------------------------------------------------------------------- /assets/less/fontawesome/core.less: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | -------------------------------------------------------------------------------- /assets/less/fontawesome/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /_posts/2015-03-01-version-260.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Version 2.6.0 3 | description: We just released version 2.6.0 with a fix for a potential object injection vulnerability. 4 | layout: post 5 | --- 6 | 7 | We've just released version 2.6.0. This update includes a small but important fix for a potential object injection vulnerability in the `SessionCookie` class. We encourage you to update your applications as soon as possible. This update also includes several other improvements. You can read more on the GitHub release page. 8 | 9 | [More Details](https://github.com/slimphp/Slim/releases/tag/2.6.0) 10 | -------------------------------------------------------------------------------- /assets/less/components/swag.less: -------------------------------------------------------------------------------- 1 | .swag-product-image{ 2 | img{ 3 | max-width: 100%; 4 | } 5 | } 6 | 7 | .swag-product-price{ 8 | margin-bottom: 10px; 9 | color: @green; 10 | font-weight: bold; 11 | font-size: 24px; 12 | line-height: 30px; 13 | 14 | sup{ 15 | font-weight: normal; 16 | font-size: 12px; 17 | position: relative; 18 | top: -1em; 19 | } 20 | 21 | small{ 22 | font-size: 12px; 23 | font-weight: normal; 24 | } 25 | } 26 | 27 | .swag-product-description{ 28 | margin-bottom: 20px; 29 | } 30 | -------------------------------------------------------------------------------- /_posts/2015-05-21-slim-treehouse.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Treehouse Slim Framework Tutorials 3 | description: Treehouse has published a new tutorial series on the Slim Framework. 4 | layout: post 5 | --- 6 | 7 | [Treehouse](http://teamtreehouse.com/) and [Hampton Paulk](http://teamtreehouse.com/hamptonpaulk) have published a new tutorial series that demonstrates how to create a website with the Slim Framework. It's aimed at PHP beginners, and it teaches you how to use Composer, Slim, SwiftMailer, and Monolog while building a simple website. 8 | 9 | 10 | -------------------------------------------------------------------------------- /_posts/2013-08-22-zend-software.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework and Zend Server Enterprise Edition 3 | description: Top 50 Slim Framework contributors eligible for Zend Server Enterprise Edition and Zend Studio 4 | layout: post 5 | --- 6 | 7 | The top 50 Slim Framework contributors are eligible for a free copy of 8 | [Zend Server Enterprise Edition](http://www.zend.com/en/products/server/) and [Zend Studio](http://www.zend.com/en/products/studio/) — together worth over $10,000. According to Zend, they “are fully supported and can be used for production on a single server.” Visit for more information. 9 | -------------------------------------------------------------------------------- /docs/v2/hooks/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | A Slim application provides a set of hooks to which you can register your own callbacks to it. 5 | 6 | ### What is a hook? 7 | 8 | A “hook” is a moment in the Slim application lifecycle at which a priority list of callables assigned to the hook 9 | will be invoked. A hook is identified by a string name. 10 | 11 | A “callable” is anything that returns `true` for `is_callable()`. A callable is assigned to a hook and is invoked 12 | when the hook is called. If multiple callables are assigned to a single hook, each callable is invoked in the order 13 | assigned. 14 | -------------------------------------------------------------------------------- /docs/v2/logging/activate.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Activate 3 | --- 4 | The Slim application’s log object provides the following public methods to enable or disable logging during runtime. 5 | 6 | log->setEnabled(true); 9 | 10 | //Disable logging 11 | $app->log->setEnabled(false); 12 | 13 | You may enable or disable the log object during application instantiation like this: 14 | 15 | true 18 | )); 19 | 20 | If logging is disabled, the log object will ignore all logged messages until it is enabled. 21 | -------------------------------------------------------------------------------- /_posts/2025-11-21-slim-4.15.1-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 4.15.1 released 3 | description: Slim 4.15.1 released 4 | layout: post 5 | --- 6 | 7 | We are pleased to release Slim 4.15.1 today, with official support for [PHP 8.5](https://www.php.net/releases/8.5/en.php) which was released yesterday. 8 | 9 | Slim 4 is a mature project and so we are keen to ensure that it remains stable for the projects that it underpins. To that end, we also upgraded our internal testing so that we can use the latest versions of PHPUnit. 10 | 11 | The full changelog can be seen [here](https://github.com/slimphp/Slim/releases/tag/4.15.1). 12 | 13 | -------------------------------------------------------------------------------- /_posts/2012-04-22-composer-and-packagist.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Use Slim Framework with Composer and Packagist 3 | description: The Slim Framework now works with Composer and is available on Packagist 4 | layout: post 5 | --- 6 | 7 | I’m happy to announce that the Slim Framework now works with [Composer](http://getcomposer.org/) and is available on [Packagist](http://packagist.org/packages/slim/slim). Andrew Smith at Silent Works has written a tutorial that demonstrates how to use Composer and Packagist to manage dependencies in your Slim application. 8 | 9 | [Read the Tutorial](http://silentworks.co.uk/blog/development/slim-composed.html) 10 | -------------------------------------------------------------------------------- /docs/v2/request/content-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Content Types 3 | --- 4 | 5 | How to Deal with Content-Types 6 | 7 | By default Slim does not parse any other content-type other than the standard form data because PHP does not support it. That means if you attempt to post application/json you will not be able to access the data via $app->request->post(); 8 | 9 | To solve this 10 | You must parse the content type yourself. You can either do this on a per-route basis 11 | 12 | ```` 13 | //For application/json 14 | $data = json_decode($app->request->getBody()); 15 | ```` 16 | 17 | or use some pre-built middleware (https://github.com/slimphp/Slim-Middleware) 18 | -------------------------------------------------------------------------------- /_posts/2019-01-15-slim-3.12.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.12.0 released 3 | description: Slim 3.12.0 released 4 | layout: post 5 | --- 6 | 7 | It's a new year, so a new Slim! Like 3.11.0, version 3.12.0 is nearly entirely bug fixes. 8 | 9 | In particular, [#2543](https://github.com/slimphp/Slim/pull/2543) & [#2558](https://github.com/slimphp/Slim/pull/2558) enable Slim to be used with Diactoros which requires `read()` to be called with an integer. 10 | 11 | Also, [#2519](https://github.com/slimphp/Slim/pull/2519) adds `getBasePath()` to the `Router` object. 12 | 13 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.12.0+is%3Aclosed) 14 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/panels.less: -------------------------------------------------------------------------------- 1 | // Panels 2 | 3 | .panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) { 4 | border-color: @border; 5 | 6 | & > .panel-heading { 7 | color: @heading-text-color; 8 | background-color: @heading-bg-color; 9 | border-color: @heading-border; 10 | 11 | + .panel-collapse > .panel-body { 12 | border-top-color: @border; 13 | } 14 | .badge { 15 | color: @heading-bg-color; 16 | background-color: @heading-text-color; 17 | } 18 | } 19 | & > .panel-footer { 20 | + .panel-collapse > .panel-body { 21 | border-bottom-color: @border; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /assets/bootstrap/less/wells.less: -------------------------------------------------------------------------------- 1 | // 2 | // Wells 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .well { 8 | min-height: 20px; 9 | padding: 19px; 10 | margin-bottom: 20px; 11 | background-color: @well-bg; 12 | border: 1px solid @well-border; 13 | border-radius: @border-radius-base; 14 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.05)); 15 | blockquote { 16 | border-color: #ddd; 17 | border-color: rgba(0,0,0,.15); 18 | } 19 | } 20 | 21 | // Sizes 22 | .well-lg { 23 | padding: 24px; 24 | border-radius: @border-radius-large; 25 | } 26 | .well-sm { 27 | padding: 9px; 28 | border-radius: @border-radius-small; 29 | } 30 | -------------------------------------------------------------------------------- /docs/v2/errors/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | Let’s face it: sometimes things go wrong. It is important to intercept errors and respond to them appropriately. A 5 | Slim application provides helper methods to respond to errors and exceptions. 6 | 7 | ### Important Notes 8 | 9 | * A Slim application respects your existing `error_reporting` setting; 10 | * A Slim application only handles errors and exceptions generated inside the Slim application; 11 | * A Slim application converts errors into `ErrorException` objects and throws them; 12 | * A Slim application uses its built-in error handler if its `debug` setting is true; otherwise, it uses the custom error handler. 13 | -------------------------------------------------------------------------------- /_posts/2012-07-31-version-165.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework Version 1.6.5 3 | description: Slim Framework 1.6.5 is a minor update recommended for all users 4 | layout: post 5 | --- 6 | 7 | I’ve just released Slim Framework 1.6.5. This minor release is recommended for everyone and includes the following changes: 8 | 9 | * Add route wildcard parameters 10 | * Let Slim_Router handle route dispatching 11 | * Let Slim_Middleware_Flash be iterable 12 | * Prevent E_NOTICE if session already started 13 | * Optimize `Slim_Route::matches` code 14 | 15 | Visit this URL to view the relevant changes to the source code: 16 | 17 | 18 | -------------------------------------------------------------------------------- /_posts/2016-11-20-slim-3.6.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.6.0 released 3 | description: Slim 3.6.0 released 4 | layout: post 5 | --- 6 | 7 | Slim 3.6.0 is a small release containing a few bug fixes and a new method. A particularly useful bug fix is that the Response's `withJson()` method now correctly removes any data currently in the body before inserting its own data. We also have a new convenience method on `Request`: `getServerParam()` allows access to a single parameter from `$_SERVER`. 8 | 9 | Finally, Slim now knows about the `421`, `444`, `499` and `599` status codes! 10 | 11 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.6.0+is%3Aclosed) 12 | -------------------------------------------------------------------------------- /_posts/2012-07-25-pagodabox-quickstart.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Launch apps on PagodaBox with the Slim Framework Quickstart 3 | description: Use the official Slim Framework quickstart to instantly launch Slim Framework applications on the PagodaBox platform. 4 | layout: post 5 | --- 6 | 7 | Now you can instantly launch new Slim Framework applications on PagodaBox with the official Slim Framework quickstart. You don’t have to worry about creating filesystem directories, downloading and installing the Slim Framework libraries, or messing with complicated deployment routines. 8 | 9 | It’s super simple to get started: visit the URL below and click “Launch”. 10 | 11 | 12 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/list-group.less: -------------------------------------------------------------------------------- 1 | // List Groups 2 | 3 | .list-group-item-variant(@state; @background; @color) { 4 | .list-group-item-@{state} { 5 | color: @color; 6 | background-color: @background; 7 | 8 | a& { 9 | color: @color; 10 | 11 | .list-group-item-heading { 12 | color: inherit; 13 | } 14 | 15 | &:hover, 16 | &:focus { 17 | color: @color; 18 | background-color: darken(@background, 5%); 19 | } 20 | &.active, 21 | &.active:hover, 22 | &.active:focus { 23 | color: #fff; 24 | background-color: @color; 25 | border-color: @color; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/hide-text.less: -------------------------------------------------------------------------------- 1 | // CSS image replacement 2 | // 3 | // Heads up! v3 launched with with only `.hide-text()`, but per our pattern for 4 | // mixins being reused as classes with the same name, this doesn't hold up. As 5 | // of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`. 6 | // 7 | // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757 8 | 9 | // Deprecated as of v3.0.1 (will be removed in v4) 10 | .hide-text() { 11 | font: ~"0/0" a; 12 | color: transparent; 13 | text-shadow: none; 14 | background-color: transparent; 15 | border: 0; 16 | } 17 | 18 | // New mixin to use as of v3.0.1 19 | .text-hide() { 20 | .hide-text(); 21 | } 22 | -------------------------------------------------------------------------------- /docs/v2/request/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | Each Slim application instance has one request object. The request object is an abstraction of the current 5 | HTTP request and allows you to easily interact with the Slim application's environment variables. Although each 6 | Slim application includes a default request object, the `\Slim\Http\Request` class is idempotent; you may 7 | instantiate the class at will (in middleware or elsewhere in your Slim application) without affecting the application 8 | as a whole. You can obtain a reference to the Slim application’s request object like this: 9 | 10 | request; 13 | -------------------------------------------------------------------------------- /docs/v2/response/status.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Status 3 | --- 4 | The HTTP response returned to the client will have a status code indicating the response’s type 5 | (e.g. 200 OK, 400 Bad Request, or 500 Server Error). You can use the Slim application’s response object to set the 6 | HTTP response’s status like this: 7 | 8 | response->setStatus(400); 10 | 11 | You only need to set the response object’s status if you intend to return an HTTP response that *does not* have 12 | a 200 OK status. You can just as easily fetch the response object’s current HTTP status by invoking the same 13 | method without an argument, like this: 14 | 15 | response->getStatus(); 17 | -------------------------------------------------------------------------------- /_posts/2012-06-24-version-164.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework Version 1.6.4 3 | description: Slim Framework 1.6.4 is a minor update recommended for all users 4 | layout: post 5 | --- 6 | 7 | I’ve just released Slim Framework 1.6.4. This minor release is recommended for everyone and includes the following changes: 8 | 9 | * Let Slim always invoke `slim.after` hook, even after halt, etc. 10 | * Let Slim_Route inject custom parameter values 11 | * Let Slim_Router return current route in middleware 12 | * Fix duplicate output when output buffering turned on 13 | * Improve unit test coverage 14 | * Visit this URL to view the relevant changes to the source code: 15 | 16 | 17 | -------------------------------------------------------------------------------- /_posts/2017-03-18-slim-3.8.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.8.0 released 3 | description: Slim 3.8.0 released 4 | layout: post 5 | --- 6 | 7 | It's been a few months since the last release, so Slim 3.8.0 has a few more things in it. This version updates Slim to be compatible with [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md) containers so that you can now use a PSR-11 container with it. 8 | 9 | There are also a number of useful bug fixes to to the `Http` component including better handling base paths with spaces in them and dealing with invalid XML and JSON in the request body. 10 | 11 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.8.0+is%3Aclosed) 12 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/clearfix.less: -------------------------------------------------------------------------------- 1 | // Clearfix 2 | // 3 | // For modern browsers 4 | // 1. The space content is one way to avoid an Opera bug when the 5 | // contenteditable attribute is included anywhere else in the document. 6 | // Otherwise it causes space to appear at the top and bottom of elements 7 | // that are clearfixed. 8 | // 2. The use of `table` rather than `block` is only necessary if using 9 | // `:before` to contain the top-margins of child elements. 10 | // 11 | // Source: http://nicolasgallagher.com/micro-clearfix-hack/ 12 | 13 | .clearfix() { 14 | &:before, 15 | &:after { 16 | content: " "; // 1 17 | display: table; // 2 18 | } 19 | &:after { 20 | clear: both; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /assets/bootstrap/less/breadcrumbs.less: -------------------------------------------------------------------------------- 1 | // 2 | // Breadcrumbs 3 | // -------------------------------------------------- 4 | 5 | 6 | .breadcrumb { 7 | padding: @breadcrumb-padding-vertical @breadcrumb-padding-horizontal; 8 | margin-bottom: @line-height-computed; 9 | list-style: none; 10 | background-color: @breadcrumb-bg; 11 | border-radius: @border-radius-base; 12 | 13 | > li { 14 | display: inline-block; 15 | 16 | + li:before { 17 | content: "@{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space 18 | padding: 0 5px; 19 | color: @breadcrumb-color; 20 | } 21 | } 22 | 23 | > .active { 24 | color: @breadcrumb-active-color; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/v2/routing/post.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: POST 3 | --- 4 | Use the Slim application's `post()` method to map a callback function to a resource URI that is requested with 5 | the HTTP POST method. 6 | 7 | post('/books', function () { 10 | //Create book 11 | }); 12 | 13 | In this example, an HTTP POST request for “/books” will invoke the associated callback function 14 | 15 | The first argument of the Slim application's `post()` method is the resource URI. The last argument is anything that 16 | returns `true` for `is_callable()`. Typically, the last argument will be an [anonymous function][anon-func]. 17 | 18 | [anon-func]: http://php.net/manual/en/functions.anonymous.php 19 | -------------------------------------------------------------------------------- /assets/less/fontawesome/rotated-flipped.less: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-rotate-90 { .fa-icon-rotate(90deg, 1); } 5 | .@{fa-css-prefix}-rotate-180 { .fa-icon-rotate(180deg, 2); } 6 | .@{fa-css-prefix}-rotate-270 { .fa-icon-rotate(270deg, 3); } 7 | 8 | .@{fa-css-prefix}-flip-horizontal { .fa-icon-flip(-1, 1, 0); } 9 | .@{fa-css-prefix}-flip-vertical { .fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .@{fa-css-prefix}-rotate-90, 15 | :root .@{fa-css-prefix}-rotate-180, 16 | :root .@{fa-css-prefix}-rotate-270, 17 | :root .@{fa-css-prefix}-flip-horizontal, 18 | :root .@{fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /assets/bootstrap/less/responsive-embed.less: -------------------------------------------------------------------------------- 1 | // Embeds responsive 2 | // 3 | // Credit: Nicolas Gallagher and SUIT CSS. 4 | 5 | .embed-responsive { 6 | position: relative; 7 | display: block; 8 | height: 0; 9 | padding: 0; 10 | overflow: hidden; 11 | 12 | .embed-responsive-item, 13 | iframe, 14 | embed, 15 | object, 16 | video { 17 | position: absolute; 18 | top: 0; 19 | left: 0; 20 | bottom: 0; 21 | height: 100%; 22 | width: 100%; 23 | border: 0; 24 | } 25 | 26 | // Modifier class for 16:9 aspect ratio 27 | &.embed-responsive-16by9 { 28 | padding-bottom: 56.25%; 29 | } 30 | 31 | // Modifier class for 4:3 aspect ratio 32 | &.embed-responsive-4by3 { 33 | padding-bottom: 75%; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /_posts/2016-03-14-tutorial-for-slim-3.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: First Application Walkthrough Tutorial 3 | description: First Application Walkthrough Tutorial 4 | layout: post 5 | --- 6 | 7 | We are very happy to have added our first Slim 3 tutorial to the documentation! 8 | Contributed by [Lorna Mitchell](http://www.lornajane.net), 9 | [First Application Walkthrough](/docs/tutorial/first-app.html) guides you through 10 | building your first application with Slim Framework. 11 | 12 | 13 | It covers everything you need to get started, from installation and 14 | configuration through to dealing with databases and logging, creating 15 | routes and the relevant view scripts along the way. Once you have gone through 16 | this tutorial, you'll have a good grounding in how Slim works. 17 | -------------------------------------------------------------------------------- /_posts/2018-04-19-slim-3.10.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.10.0 released 3 | description: Slim 3.10.0 released 4 | layout: post 5 | --- 6 | 7 | We are delighted to release Slim 3.10.0. This version has a couple of minor new features and a couple of bug fixes. 8 | 9 | The most noticeable improvement is that we now support `$app->redirect('/from', '/to')` to allow quick and easy redirecting of one path to another without having to write a route handler yourself. We have also added support for the `SameSite` flag in `Slim\Http\Cookies` 10 | 11 | As usual, there are also some bug fixes, particularly we no longer override the Host header in the request if it's already defined. 12 | 13 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.10.0+is%3Aclosed) 14 | -------------------------------------------------------------------------------- /_posts/2016-03-10-slim-3.3.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.3.0 released 3 | description: Slim 3.3.0 released 4 | layout: post 5 | --- 6 | 7 | This release tidies up a few issues found in our PSR-7 implementation around the Request's body and uploaded files. In particular, we now handle file input elements with names containing nested arrays correctly. 8 | 9 | 10 | ## Added 11 | 12 | * [#1811](https://github.com/slimphp/Slim/pull/1811) - Add `Request::reparseBody()` to provide a way to allow reparsing of the Request's body 13 | 14 | 15 | ## Fixed 16 | 17 | * [#1812](https://github.com/slimphp/Slim/pull/1812) - Handle nested uploaded files correctly. 18 | * [#1808](https://github.com/slimphp/Slim/pull/1808) - Ensure that getParsedBody() returns null if the body cannot be parsed. 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/v2/cache/overview.md: -------------------------------------------------------------------------------- 1 | A Slim application provides built-in support for HTTP caching with its `etag()`, `lastModified()`, and `expires()` 2 | helper methods. It is best to use one of `etag()` or `lastModified()` - in conjunction with `expires()` - per route; 3 | never use both `etag()` and `lastModified()` together in the same route callback. 4 | 5 | The `etag()` and `lastModified()` methods should be invoked in a route callback before other code; this allows Slim 6 | to check conditional GET requests before processing the route callback’s remaining code. 7 | 8 | Both `etag()` and `lastModified()` instruct the HTTP client to store the resource response in a client-side cache. 9 | The `expires()` method indicates to the HTTP client when the client-side cache should be considered stale. 10 | -------------------------------------------------------------------------------- /_includes/nav.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | Blog 4 |
5 | 6 |
7 | User Guide 8 |
9 | 10 |
11 | Community 12 |
13 | 14 |
15 | Contribute 16 |
17 |
18 | -------------------------------------------------------------------------------- /docs/v4/contributors/guidelines.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contributor Guidelines 3 | --- 4 | 5 | I encourage everyone to contribute to the Slim Framework project. 6 | You can find the latest code on GitHub at . 7 | 8 | ## Issue Tracker 9 | 10 | You can find outstanding issues on the [GitHub Issue Tracker](https://github.com/slimphp/Slim/issues). 11 | If you intend to work on a specific issue, leave a comment on the appropriate thread to inform other project contributors. 12 | 13 | ## Pull Requests 14 | 15 | * Each pull request should contain only one new feature or improvement. 16 | * Pull requests should be submitted to the `master` branch 17 | 18 | ## Code Style 19 | 20 | All pull requests must use the [PSR-12](https://www.php-fig.org/psr/psr-12/) code style. 21 | -------------------------------------------------------------------------------- /_posts/2016-03-01-slim-3.2.1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.2.1 released 3 | description: Slim 3.2.1 released 4 | layout: post 5 | --- 6 | 7 | Shortly after releasing version [3.2.0](https://github.com/slimphp/Slim/releases/tag/3.2.0), we discovered that we had inadvertently made life very difficult for people who write their own invocation strategies as it was now impossible to inspect the actual callable passed to the strategy. Obviously we don't like to break people's working applications, so version [3.2.1](https://github.com/slimphp/Slim/releases/tag/3.2.1) resolves this issue [(#1785)](https://github.com/slimphp/Slim/issues/1785). 8 | 9 | The only change is: 10 | 11 | ## Fixed 12 | 13 | * [#1789](https://github.com/slimphp/Slim/pull/1789) - Do not use DeferredCallable in route callable. 14 | 15 | 16 | -------------------------------------------------------------------------------- /docs/v2/routing/get.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: GET 3 | --- 4 | Use the Slim application's `get()` method to map a callback function to a resource URI that is requested with 5 | the HTTP GET method. 6 | 7 | get('/books/:id', function ($id) { 10 | //Show book identified by $id 11 | }); 12 | 13 | In this example, an HTTP GET request for “/books/1” will invoke the associated callback function, passing “1” as the 14 | callback's argument. 15 | 16 | The first argument of the Slim application's `get()` method is the resource URI. The last argument is anything that 17 | returns `true` for `is_callable()`. Typically, the last argument will be an [anonymous function][anon-func]. 18 | 19 | [anon-func]: http://php.net/manual/en/functions.anonymous.php 20 | -------------------------------------------------------------------------------- /docs/v4/features/templates.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Templates 3 | --- 4 | 5 | Slim does not have a view layer like traditional MVC frameworks. 6 | Instead, Slim's "view" _is the HTTP response_. 7 | Each Slim application route is responsible for preparing and returning an appropriate PSR-7 response object. 8 | 9 | > Slim's "view" is the HTTP response. 10 | 11 | That being said, the Slim project provides the [Twig-View](twig-view.html) and [PHP-View](php-view.html) components 12 | to help you render templates to a PSR-7 Response object. 13 | 14 | ## Other template systems 15 | 16 | You are not limited to the `Twig-View` and `PHP-View` components. 17 | You can use any PHP template system provided that you ultimately 18 | write the rendered template output to the PSR-7 Response object's body. 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/v2/errors/debug.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Debug 3 | --- 4 | You can enable debugging during application instantiation with this setting: 5 | 6 | true 9 | )); 10 | 11 | You may also enable debugging during runtime with the Slim application’s `config()` instance method: 12 | 13 | config('debug', true); 18 | 19 | //Disable debugging 20 | $app->config('debug', false); 21 | 22 | If debugging is enabled and an exception or error occurs, a diagnostic screen will appear with the error description, 23 | the affected file, the file line number, and a stack trace. If debugging is disabled, the custom Error handler will 24 | be invoked instead. 25 | -------------------------------------------------------------------------------- /docs/v2/routing/patch.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: PATCH 3 | --- 4 | Use the Slim application's `patch()` method to map a callback function to a resource URI that is requested with 5 | the HTTP PATCH method. 6 | 7 | patch('/books/:id', function ($id) { 10 | // Patch book with given ID 11 | }); 12 | 13 | In this example, an HTTP PATCH request for “/books/1” will invoke the associated callback function, passing "1" as 14 | the callback function's argument. 15 | 16 | The first argument of the Slim application's `patch()` method is the resource URI. The last argument is anything that 17 | returns `true` for `is_callable()`. Typically, the last argument will be an [anonymous function][anon-func]. 18 | 19 | [anon-func]: http://php.net/manual/en/functions.anonymous.php 20 | -------------------------------------------------------------------------------- /assets/scripts/src/setup.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | $(window).ready(function() { 3 | $('.docs ul.toc-links li a').each(function() { 4 | // flag active menu item 5 | if(this.href === window.location.href) { 6 | $(this).addClass('active'); 7 | } 8 | 9 | // change active menu item if clicking on a url with a fragment 10 | if(this.href.indexOf('#') !== -1) { 11 | $(this).click(function() { 12 | $('.docs ul.toc-links li a.active').removeClass('active'); 13 | $(this).addClass('active'); 14 | }); 15 | } 16 | }); 17 | 18 | // add anchor to docs-content 19 | $('.docs-content h2, .docs-content h3').click(function() { 20 | window.location = window.location.href.split('#')[0] + '#' + this.id; 21 | }); 22 | }); 23 | })(jQuery); 24 | 25 | -------------------------------------------------------------------------------- /_posts/2016-05-16-slim-3.4.1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.4.1 released 3 | description: Slim 3.4.1 released 4 | layout: post 5 | --- 6 | 7 | This releases fixes a infinite loop bug discovered in version 3.4.0 and also adds additional unit tests. 8 | 9 | Total issues resolved: **5** 10 | 11 | - [1866: Error handlers throws exception if content-type not supported](https://github.com/slimphp/Slim/pull/1866) 12 | - [1873: Fixing Infinite Loop in Error, Unit Test](https://github.com/slimphp/Slim/pull/1873) 13 | - [1874: Use class name constant instead of magic string.](https://github.com/slimphp/Slim/pull/1874) 14 | - [1876: Test to check if half valid content type returns default](https://github.com/slimphp/Slim/pull/1876) 15 | - [1877: Mock available contentTypes to make test run as it should](https://github.com/slimphp/Slim/pull/1877) 16 | -------------------------------------------------------------------------------- /docs/v2/request/xhr.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: XHR 3 | --- 4 | When using a Javascript framework like MooTools or jQuery to execute an XMLHttpRequest, the XMLHttpRequest will 5 | usually be sent with a **X-Requested-With** HTTP header. The Slim application will detect the HTTP 6 | request’s **X-Requested-With** header and flag the request as such. If for some reason an XMLHttpRequest cannot 7 | be sent with the **X-Requested-With** HTTP header, you can force the Slim application to assume an HTTP request 8 | is an XMLHttpRequest by setting a GET, POST, or PUT parameter in the HTTP request named “isajax” with a truthy value. 9 | 10 | Use the request object's `isAjax()` or `isXhr()` method to tell if the current request is an XHR/Ajax request: 11 | 12 | request->isAjax(); 14 | $isXHR = $app->request->isXhr(); 15 | -------------------------------------------------------------------------------- /_posts/2020-11-30-slim-4.7.0-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 4.7.0 released 3 | description: Slim 4.7.0 released 4 | layout: post 5 | --- 6 | 7 | We are excited to announce the Slim 4.7.0 release. Please direct all your feedback for this release to the [Slim 4 Release Feedback Thread](https://github.com/slimphp/Slim/issues/2770). The new docs are located [here](http://www.slimframework.com/docs/v4). 8 | 9 | # Changelog 10 | 11 | # 4.7.0 - 2020-11-30 12 | 13 | ### Fixed 14 | - [3027: Fix: FastRoute dispatcher and data generator should match](https://github.com/slimphp/Slim/pull/3027) thanks to @edudobay 15 | 16 | ### Added 17 | - [3015: PHP 8 support](https://github.com/slimphp/Slim/pull/3015) thanks to @edudobay 18 | 19 | ### Optimizations 20 | - [3024: Randomize tests](https://github.com/slimphp/Slim/pull/3024) thanks to @pawel-slowik 21 | -------------------------------------------------------------------------------- /docs/v2/cache/expires.md: -------------------------------------------------------------------------------- 1 | Used in conjunction with the Slim application’s `etag()` or `lastModified()` methods, the `expires()` method sets an 2 | **Expires** header on the HTTP response informing the HTTP client when its client-side cache for the current 3 | resource should be considered stale. The HTTP client will continue serving from its client-side cache until the 4 | expiration date is reached, at which time the HTTP client will send a conditional GET request to the Slim application. 5 | 6 | The `expires()` method accepts one argument: an integer UNIX timestamp, or a string to be parsed with `strtotime()`. 7 | 8 | get('/foo', function () use ($app) { 10 | $app->etag('unique-resource-id'); 11 | $app->expires('+1 week'); 12 | echo "This will be cached client-side for one week"; 13 | }); 14 | -------------------------------------------------------------------------------- /docs/v2/middleware/how-to-write.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How to write 3 | --- 4 | Slim application middleware must subclass `\Slim\Middleware` and implement a public `call()` method. The `call()` 5 | method does not accept arguments. Middleware may implement its own constructor, properties, and methods. I encourage 6 | you to look at Slim’s built-in middleware for working examples (e.g. Slim/Middleware/ContentTypes.php or 7 | Slim/Middleware/SessionCookie.php). 8 | 9 | This example is the simplest implementation of Slim application middleware. It extends `\Slim\Middleware`, 10 | implements a public `call()` method, and calls the next inner middleware. 11 | 12 | next->call(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /assets/less/fontawesome/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('@{fa-font-path}/fontawesome-webfont.eot?v=@{fa-version}'); 7 | src: url('@{fa-font-path}/fontawesome-webfont.eot?#iefix&v=@{fa-version}') format('embedded-opentype'), 8 | url('@{fa-font-path}/fontawesome-webfont.woff2?v=@{fa-version}') format('woff2'), 9 | url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff'), 10 | url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype'), 11 | url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/table-row.less: -------------------------------------------------------------------------------- 1 | // Tables 2 | 3 | .table-row-variant(@state; @background) { 4 | // Exact selectors below required to override `.table-striped` and prevent 5 | // inheritance to nested tables. 6 | .table > thead > tr, 7 | .table > tbody > tr, 8 | .table > tfoot > tr { 9 | > td.@{state}, 10 | > th.@{state}, 11 | &.@{state} > td, 12 | &.@{state} > th { 13 | background-color: @background; 14 | } 15 | } 16 | 17 | // Hover states for `.table-hover` 18 | // Note: this is not available for cells or rows within `thead` or `tfoot`. 19 | .table-hover > tbody > tr { 20 | > td.@{state}:hover, 21 | > th.@{state}:hover, 22 | &.@{state}:hover > td, 23 | &:hover > .@{state}, 24 | &.@{state}:hover > th { 25 | background-color: darken(@background, 5%); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /_posts/2018-09-16-slim-3.11.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.11.0 released 3 | description: Slim 3.11.0 released 4 | layout: post 5 | --- 6 | 7 | With the end of summer, we are delighted to release Slim 3.11.0. This version is pretty much entirely bug fixes. 8 | 9 | There are two fixes that are particular useful: 10 | 11 | Firstly, [#2441](https://github.com/slimphp/Slim/pull/2441) ensures that Slim correctly overrides default headers when they are added to the Response object and secondly [#2487](https://github.com/slimphp/Slim/pull/2487) means that Slim now plays nicer with proxies such as ngrok when the public URL is on a different port to the internal PHP server. 12 | 13 | There are of course a number of other bug fixes that people have found and fixed for us. Thanks! 14 | 15 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.11.0+is%3Aclosed) 16 | -------------------------------------------------------------------------------- /_includes/version-selector.html: -------------------------------------------------------------------------------- 1 |

Slim Version

2 |
3 | 13 |
14 | -------------------------------------------------------------------------------- /docs/v4/middleware/content-length.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Content Length Middleware 3 | --- 4 | 5 | The Content Length Middleware will automatically append a `Content-Length` header to the response. 6 | This is to replace the `addContentLengthHeader` setting that was removed from Slim 3. 7 | This middleware should be placed on the end of the middleware stack so that it gets executed first and exited last. 8 | 9 | ## Usage 10 | ```php 11 | add($contentLengthMiddleware); 24 | 25 | // ... 26 | 27 | $app->run(); 28 | ``` 29 | -------------------------------------------------------------------------------- /assets/less/fontawesome/animated.less: -------------------------------------------------------------------------------- 1 | // Animated Icons 2 | // -------------------------- 3 | 4 | .@{fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .@{fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /assets/bootstrap/less/component-animations.less: -------------------------------------------------------------------------------- 1 | // 2 | // Component animations 3 | // -------------------------------------------------- 4 | 5 | // Heads up! 6 | // 7 | // We don't use the `.opacity()` mixin here since it causes a bug with text 8 | // fields in IE7-8. Source: https://github.com/twbs/bootstrap/pull/3552. 9 | 10 | .fade { 11 | opacity: 0; 12 | .transition(opacity .15s linear); 13 | &.in { 14 | opacity: 1; 15 | } 16 | } 17 | 18 | .collapse { 19 | display: none; 20 | visibility: hidden; 21 | 22 | &.in { display: block; visibility: visible; } 23 | tr&.in { display: table-row; } 24 | tbody&.in { display: table-row-group; } 25 | } 26 | 27 | .collapsing { 28 | position: relative; 29 | height: 0; 30 | overflow: hidden; 31 | .transition-property(~"height, visibility"); 32 | .transition-duration(.35s); 33 | .transition-timing-function(ease); 34 | } 35 | -------------------------------------------------------------------------------- /_posts/2011-11-16-slim-framework-and-phpfog.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How to run a Slim app on PHPFog 3 | description: Learn how to run a Slim Framework application on PHP Fog 4 | layout: post 5 | --- 6 | 7 | Many Slim Framework users are turning to PHPFog — a leader among a growing field of PHP PaaS providers — to host their Slim Framework PHP web applications. By default, a Slim app will not run on PHPFog. Why not? PHPFog’s backend infrastructure relies on the nginx HTTP Proxy Module to communicate between backend tiers; the nginx HTTP Proxy Module speaks HTTP/1.0 while Slim speaks HTTP/1.1. Fear not, there’s an easy workaround. To run a Slim app on PHPFog, you must tell your Slim app to speak HTTP/1.0. You can do this when you instantiate your Slim app, like this: 8 | 9 | ```php 10 | $app = new Slim(array( 11 | 'http.version' => '1.0' 12 | )); 13 | ``` 14 | 15 | And that’s it. Slim will now run on PHPFog. 16 | -------------------------------------------------------------------------------- /docs/v2/hooks/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom 3 | --- 4 | Custom hooks may be created and invoked in a Slim application. When a custom hook is invoked with `applyHook()`, it will 5 | invoke all callables assigned to that hook. This is exactly how the Slim application’s default hooks work. In this 6 | example, I apply a custom hook called “my.hook.name”. All callables previously registered for this hook will be invoked. 7 | 8 | applyHook('my.hook.name'); 11 | 12 | When you run the above code, any callables previously assigned to the hook "my.hook.name" will be invoked in order of 13 | priority (ascending). 14 | 15 | You should register callables to a hook before the hook is applied. Think of it this way: when you invoke the Slim 16 | application’s `applyHook()` method, you are asking Slim to invoke all callables already registered for that hook name. 17 | -------------------------------------------------------------------------------- /docs/v3/start/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Installation 3 | --- 4 | 5 | ## System Requirements 6 | 7 | * Web server with URL rewriting 8 | * PHP 5.5 or newer 9 | 10 | ## How to Install Slim 11 | 12 | We recommend you install Slim with [Composer](https://getcomposer.org/). 13 | Navigate into your project's root directory and execute the bash command 14 | shown below. This command downloads the Slim Framework and its third-party 15 | dependencies into your project's `vendor/` directory. 16 | 17 | ```bash 18 | composer require slim/slim:3.* 19 | ``` 20 | 21 | Require the Composer autoloader into your PHP script, and you are ready 22 | to start using Slim. 23 | 24 | ```php 25 | get('/hello/:name', function ($name) { 11 | echo "Hello, $name!"; 12 | })->name('hello'); 13 | 14 | You may now generate URLs for this route using the `urlFor()` method, described later in this documentation. 15 | The route `name()` method is also chainable: 16 | 17 | get('/hello/:name', function ($name) { 20 | echo "Hello, $name!"; 21 | })->name('hello')->conditions(array('name' => '\w+')); 22 | -------------------------------------------------------------------------------- /assets/bootstrap/less/close.less: -------------------------------------------------------------------------------- 1 | // 2 | // Close icons 3 | // -------------------------------------------------- 4 | 5 | 6 | .close { 7 | float: right; 8 | font-size: (@font-size-base * 1.5); 9 | font-weight: @close-font-weight; 10 | line-height: 1; 11 | color: @close-color; 12 | text-shadow: @close-text-shadow; 13 | .opacity(.2); 14 | 15 | &:hover, 16 | &:focus { 17 | color: @close-color; 18 | text-decoration: none; 19 | cursor: pointer; 20 | .opacity(.5); 21 | } 22 | 23 | // Additional properties for button version 24 | // iOS requires the button element instead of an anchor tag. 25 | // If you want the anchor version, it requires `href="#"`. 26 | // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile 27 | button& { 28 | padding: 0; 29 | cursor: pointer; 30 | background: transparent; 31 | border: 0; 32 | -webkit-appearance: none; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /assets/bootstrap/less/thumbnails.less: -------------------------------------------------------------------------------- 1 | // 2 | // Thumbnails 3 | // -------------------------------------------------- 4 | 5 | 6 | // Mixin and adjust the regular image class 7 | .thumbnail { 8 | display: block; 9 | padding: @thumbnail-padding; 10 | margin-bottom: @line-height-computed; 11 | line-height: @line-height-base; 12 | background-color: @thumbnail-bg; 13 | border: 1px solid @thumbnail-border; 14 | border-radius: @thumbnail-border-radius; 15 | .transition(border .2s ease-in-out); 16 | 17 | > img, 18 | a > img { 19 | &:extend(.img-responsive); 20 | margin-left: auto; 21 | margin-right: auto; 22 | } 23 | 24 | // Add a hover state for linked versions only 25 | a&:hover, 26 | a&:focus, 27 | a&.active { 28 | border-color: @link-color; 29 | } 30 | 31 | // Image captions 32 | .caption { 33 | padding: @thumbnail-caption-padding; 34 | color: @thumbnail-caption-color; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /docs/v4/middleware/method-overriding.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Method Overriding Middleware 3 | --- 4 | 5 | The Method Overriding Middleware enables you to use the `X-Http-Method-Override` request header or the request body parameter `_METHOD` to override an incoming request's method. 6 | The middleware should be placed after the routing middleware has been added. 7 | 8 | ## Usage 9 | ```php 10 | addRoutingMiddleware(); 21 | 22 | // Add MethodOverride middleware 23 | $methodOverrideMiddleware = new MethodOverrideMiddleware(); 24 | $app->add($methodOverrideMiddleware); 25 | 26 | // ... 27 | 28 | $app->run(); 29 | ``` 30 | -------------------------------------------------------------------------------- /_posts/2017-11-04-slim-3.9.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.9.0 released 3 | description: Slim 3.9.0 released 4 | layout: post 5 | --- 6 | 7 | We are delighted to release Slim 3.9.0. As Slim 3 is stable, there's mostly bug fixes in this version. 8 | 9 | Probably the most noticeable changes are that we now allow any HTTP method name in the Request object and the Uri now correctly encodes the user information, which will ensure user names and passwords with reserved characters such as `@` will work as you expect. Also in the HTTP component, the Request's `getParams()` now allows you to provide a list of the parameters you want returned, allowing you to filter for a specific set. 10 | 11 | As usual, there are also some bug fixes, particularly around the output buffering setting and you can now use any HTTP method you want to without getting an error. 12 | 13 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.9.0+is%3Aclosed) 14 | -------------------------------------------------------------------------------- /_posts/2012-06-17-version-163.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework Version 1.6.3 3 | description: Slim Framework 1.6.3 is a minor update recommended for all users 4 | layout: post 5 | --- 6 | 7 | I’ve just released Slim Framework 1.6.3. This minor release is recommended for everyone and includes the following changes: 8 | 9 | * Fix potential view data and view variable naming collisions 10 | * Let Slim_Router use internal iteration 11 | * Let Slim_Router expose current route with `getCurrentRoute()` method 12 | * Let Slim `applyHook()` method pass argument(s) to each registered callback 13 | * Let Slim_Http_Request parse request body only if body is a string and URL-encoded 14 | * Fix cookie parsing when multiple cookies exist with same name and signature 15 | * Fix Slim_Middleware_SessionCookie file locking for high-traffic Slim applications 16 | * Rename Slim_LogFileWriter class to Slim_LogWriter 17 | * Add optional log file writer (rotated daily, weekly, or yearly) to Slim-Extras 18 | -------------------------------------------------------------------------------- /docs/v2/response/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | Each Slim application instance has one response object. The response object is an abstraction of your Slim application's 5 | HTTP response that is returned to the HTTP client. Although each Slim application includes a default response object, 6 | the `\Slim\Http\Response` class is idempotent; you may instantiate the class at will (in middleware or elsewhere in 7 | your Slim application) without affecting the application as a whole. You can obtain a reference to the Slim 8 | application’s response object with: 9 | 10 | response; 13 | 14 | An HTTP response has three primary properties: 15 | 16 | * Status 17 | * Header 18 | * Body 19 | 20 | The response object provides helper methods, described next, that help you interact with these HTTP response 21 | properties. The default response object will return a **200 OK** HTTP response with the **text/html** content type. 22 | -------------------------------------------------------------------------------- /_posts/2019-08-06-slim-4.1.0-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 4.1.0 released 3 | description: Slim 4.1.0 released 4 | layout: post 5 | --- 6 | 7 | We are excited to announce the Slim 4.1.0 release. Please direct all your feedback for this release to the [Slim 4 Release Feedback Thread](https://github.com/slimphp/Slim/issues/2770). The new docs are located [here](http://www.slimframework.com/docs/v4). 8 | 9 | # Changelog 10 | 11 | ### Added 12 | - [#2779](https://github.com/slimphp/Slim/pull/2774) Add support for Slim callables `Class:method` resolution & Container Closure auto-binding in `MiddlewareDispatcher` 13 | - [#2774](https://github.com/slimphp/Slim/pull/2774) Add possibility for custom `RequestHandler` invocation strategies 14 | 15 | ### Fixed 16 | - [#2776](https://github.com/slimphp/Slim/pull/2774) Fix group middleware on multiple nested groups 17 | 18 | ### Unaddressed BC Break From 4.0.0 19 | - [#2777](https://github.com/slimphp/Slim/pull/2777) - Routes can no longer return `null` 20 | -------------------------------------------------------------------------------- /docs/v2/request/headers.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Headers 3 | --- 4 | A Slim application will automatically parse all HTTP request headers. You can access the request headers using the 5 | request object's public `headers` property. The `headers` property is an instance of `\Slim\Helper\Set`, meaning 6 | it provides a simple, standardized interface to interactive with the HTTP request headers. 7 | 8 | request->headers; 13 | 14 | // Get the ACCEPT_CHARSET header 15 | $charset = $app->request->headers->get('ACCEPT_CHARSET'); 16 | 17 | The HTTP specification states that HTTP header names may be uppercase, lowercase, or mixed-case. Slim is smart enough 18 | to parse and return header values whether you request a header value using upper, lower, or mixed case header name, 19 | with either underscores or dashes. So use the naming convention with which you are most comfortable. 20 | -------------------------------------------------------------------------------- /blog/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Blog 4 | --- 5 | 6 |
7 |
8 |
9 |

Latest News

10 |

11 | This is the official Slim Framework blog where you'll find 12 | release announcements and community news. 13 |

14 | Subscribe with RSS 15 |
16 | 17 | {% for post in site.posts %} 18 |
19 | 20 |

{{ post.title }}

21 |
22 | {{ post.excerpt }} 23 |
24 |
25 | {% endfor %} 26 |
27 |
28 | -------------------------------------------------------------------------------- /docs/v2/response/headers.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Headers 3 | --- 4 | The HTTP response returned to the HTTP client will have a header. The HTTP header is a list of keys and values that 5 | provide metadata about the HTTP response. You can use the Slim application’s response object to set the HTTP 6 | response’s header. The response object has a public property `headers` that is an instance of `\Slim\Helper\Set`; 7 | this provides a simple, standardized interface to manipulate the HTTP response headers. 8 | 9 | response->headers->set('Content-Type', 'application/json'); 12 | 13 | You may also fetch headers from the response object's `headers` property, too: 14 | 15 | response->headers->get('Content-Type'); 17 | 18 | If a header with the given name does not exist, `null` is returned. You may specify header names with upper, lower, 19 | or mixed case with dashes or underscores. Use the naming convention with which you are most comfortable. 20 | -------------------------------------------------------------------------------- /docs/v4/cookbook/route-patterns.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Trailing / in route patterns 3 | --- 4 | 5 | Slim treats a URL pattern with a trailing slash as different to one without. 6 | That is, `/user` and `/user/` are different and so can have different callbacks attached. 7 | 8 | For GET requests a permanent redirect is fine, but for other request methods like POST or PUT the browser will send the second request with the GET method. 9 | To avoid this you simply need to remove the trailing slash in the `Request` object and pass the manipulated url to the next middleware. 10 | 11 | If you want to redirect/rewrite all URLs that end in a `/` to the non-trailing `/` equivalent, consider [middlewares/trailing-slash](//github.com/middlewares/trailing-slash) middleware. 12 | Alternatively, the middlware also allows you to force a trailing slash to be appended to all URLs. 13 | 14 | ```php 15 | use Middlewares\TrailingSlash; 16 | 17 | $app->add(new TrailingSlash(trailingSlash: true)); // true adds the trailing slash (false removes it) 18 | ``` 19 | -------------------------------------------------------------------------------- /docs/v2/logging/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | A Slim application provides a log object that writes data to a specific output. The actual writing of data is 5 | delegated to a log writer. 6 | 7 | ### How to log data 8 | 9 | To log data in a Slim application, get a reference to the log object: 10 | 11 | log; 13 | 14 | The log object provides the following PSR-3 interface 15 | 16 | $app->log->debug(mixed $object); 17 | $app->log->info(mixed $object); 18 | $app->log->notice(mixed $object); 19 | $app->log->warning(mixed $object); 20 | $app->log->error(mixed $object); 21 | $app->log->critical(mixed $object); 22 | $app->log->alert(mixed $object); 23 | $app->log->emergency(mixed $object); 24 | 25 | Each log object method accepts one mixed argument. The argument is usually a string, but the argument can be 26 | anything. The log object will pass the argument to its log writer. It is the log writer’s responsibility to write 27 | arbitrary input to the appropriate destination. 28 | -------------------------------------------------------------------------------- /docs/v4/middleware/routing.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Routing Middleware 3 | --- 4 | 5 | The routing has been implemented as middleware. 6 | We are still using [FastRoute](https://github.com/nikic/FastRoute) as the default router but it is not tightly coupled to it. 7 | If you wanted to implement another routing library you could by creating your own implementations of the routing interfaces. 8 | `DispatcherInterface`, `RouteCollectorInterface`, `RouteParserInterface` and `RouteResolverInterface` create a bridge between Slim's components and the routing library. 9 | If you were using `determineRouteBeforeAppMiddleware`, you need to add the `Middleware\RoutingMiddleware` middleware to your application just before your call to `run()` to maintain the previous behaviour. 10 | 11 | ## Usage 12 | ```php 13 | addRoutingMiddleware(); 23 | 24 | // ... 25 | 26 | $app->run(); 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/v3/cookbook/ip-address.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Retrieving IP address 3 | --- 4 | 5 | The best way to retrieve the current IP address of the client is via middleware using 6 | a component such as [ip-address-middleware](https://github.com/akrabat/ip-address-middleware/). 7 | 8 | This component can be installed via composer: 9 | 10 | ```bash 11 | composer require akrabat/ip-address-middleware 12 | ``` 13 | 14 | To use it, register the middleware with the App, providing a list 15 | of trusted proxies (e.g. varnish servers) if you are using them.: 16 | 17 | ```php 18 | $checkProxyHeaders = true; 19 | $trustedProxies = ['10.0.0.1', '10.0.0.2']; 20 | $app->add(new RKA\Middleware\IpAddress($checkProxyHeaders, $trustedProxies)); 21 | 22 | $app->get('/', function ($request, $response, $args) { 23 | $ipAddress = $request->getAttribute('ip_address'); 24 | 25 | return $response; 26 | }); 27 | ``` 28 | 29 | The middleware stores the client's IP address in a request attribute, so access 30 | is via $request->getAttribute('ip_address'). 31 | -------------------------------------------------------------------------------- /assets/bootstrap/less/utilities.less: -------------------------------------------------------------------------------- 1 | // 2 | // Utility classes 3 | // -------------------------------------------------- 4 | 5 | 6 | // Floats 7 | // ------------------------- 8 | 9 | .clearfix { 10 | .clearfix(); 11 | } 12 | .center-block { 13 | .center-block(); 14 | } 15 | .pull-right { 16 | float: right !important; 17 | } 18 | .pull-left { 19 | float: left !important; 20 | } 21 | 22 | 23 | // Toggling content 24 | // ------------------------- 25 | 26 | // Note: Deprecated .hide in favor of .hidden or .sr-only (as appropriate) in v3.0.1 27 | .hide { 28 | display: none !important; 29 | } 30 | .show { 31 | display: block !important; 32 | } 33 | .invisible { 34 | visibility: hidden; 35 | } 36 | .text-hide { 37 | .text-hide(); 38 | } 39 | 40 | 41 | // Hide from screenreaders and browsers 42 | // 43 | // Credit: HTML5 Boilerplate 44 | 45 | .hidden { 46 | display: none !important; 47 | visibility: hidden !important; 48 | } 49 | 50 | 51 | // For Affix plugin 52 | // ------------------------- 53 | 54 | .affix { 55 | position: fixed; 56 | } 57 | -------------------------------------------------------------------------------- /_posts/2012-02-18-slim-framework-moves-to-pagodabox.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework Moves to Pagoda Box 3 | description: The Slim Framework for PHP 5 website is now hosted by Pagoda Box, a scalable and flexible PHP PaaS 4 | layout: post 5 | --- 6 | 7 | The Slim Framework website is now hosted with [Pagoda Box](http://pagodabox.com/). I’m super excited about the move. If you haven’t heard already, Pagoda Box is a PHP PaaS that provides a very flexible and scalable architecture for your PHP applications. 8 | 9 | Pagoda Box allows me to develop and test Slim’s website locally in my own Git repository where I can experiment with new website features in separate Git branches. When I’m ready to push a new feature into production, I `git push` my changes to the Pagoda Box platform where they are instantly distributed and deployed. 10 | 11 | I want to extend a big “thank you” to Steve, Scott, and the rest of the Pagoda Box team for hosting Slim’s website and for helping with Slim’s continued growth and future development. 12 | 13 | [Learn more about Pagoda Box](http://pagodabox.com/) 14 | -------------------------------------------------------------------------------- /assets/bootstrap/less/media.less: -------------------------------------------------------------------------------- 1 | .media { 2 | // Proper spacing between instances of .media 3 | margin-top: 15px; 4 | 5 | &:first-child { 6 | margin-top: 0; 7 | } 8 | } 9 | 10 | .media, 11 | .media-body { 12 | zoom: 1; 13 | overflow: hidden; 14 | } 15 | 16 | .media-body { 17 | width: 10000px; 18 | } 19 | 20 | .media-object { 21 | display: block; 22 | } 23 | 24 | .media-right, 25 | .media > .pull-right { 26 | padding-left: 10px; 27 | } 28 | 29 | .media-left, 30 | .media > .pull-left { 31 | padding-right: 10px; 32 | } 33 | 34 | .media-left, 35 | .media-right, 36 | .media-body { 37 | display: table-cell; 38 | vertical-align: top; 39 | } 40 | 41 | .media-middle { 42 | vertical-align: middle; 43 | } 44 | 45 | .media-bottom { 46 | vertical-align: bottom; 47 | } 48 | 49 | // Reset margins on headings for tighter default spacing 50 | .media-heading { 51 | margin-top: 0; 52 | margin-bottom: 5px; 53 | } 54 | 55 | // Media list variation 56 | // 57 | // Undo default ul/ol styles 58 | .media-list { 59 | padding-left: 0; 60 | list-style: none; 61 | } 62 | -------------------------------------------------------------------------------- /_posts/2011-12-26-multimarkdown-community-documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: MultiMarkdown Community Documentation 3 | description: The Slim Framework for PHP 5 documentation has moved into the core Git repository and is written in MultiMarkdown format 4 | layout: post 5 | --- 6 | 7 | The Slim Framework documentation has moved into the Git repository as of v1.5.2 (currently in the development branch). This change makes it easy for the community to suggest additions or changes to the framework documentation. 8 | 9 | The documentation files are located in the `docs/` directory. Each documentation section has its own MultiMarkdown file. The `index.txt` manifest file specifies the order and hierarchy of the documentation files. Use the MultiMarkdown `mmd_merge` utility to consolidate the documentation files into your preferred format (e.g. HTML, LaTeX, PDF, ODT, or OPML); this is how I generate the HTML documentation. Be sure you download and install both MultiMarkdown and the MultiMarkdown Utility packages. 10 | 11 | [Get MultiMarkdown](https://github.com/fletcher/peg-multimarkdown/downloads/) 12 | -------------------------------------------------------------------------------- /assets/bootstrap/less/pager.less: -------------------------------------------------------------------------------- 1 | // 2 | // Pager pagination 3 | // -------------------------------------------------- 4 | 5 | 6 | .pager { 7 | padding-left: 0; 8 | margin: 30px 0; 9 | list-style: none; 10 | text-align: center; 11 | &:extend(.clearfix all); 12 | li { 13 | display: inline; 14 | > a, 15 | > span { 16 | display: inline-block; 17 | padding: 5px 14px; 18 | background-color: @pager-bg; 19 | border: 1px solid @pager-border; 20 | border-radius: 4px; 21 | } 22 | 23 | > a:hover, 24 | > a:focus { 25 | text-decoration: none; 26 | background-color: @pager-hover-bg; 27 | } 28 | } 29 | 30 | .next { 31 | > a, 32 | > span { 33 | float: right; 34 | } 35 | } 36 | 37 | .previous { 38 | > a, 39 | > span { 40 | float: left; 41 | } 42 | } 43 | 44 | .disabled { 45 | > a, 46 | > a:hover, 47 | > a:focus, 48 | > span { 49 | color: @pager-disabled-color; 50 | background-color: @pager-bg; 51 | cursor: @cursor-disabled; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /blog/feed.rss: -------------------------------------------------------------------------------- 1 | --- 2 | layout: blank 3 | --- 4 | 5 | 6 | 7 | {{ site.title }} Blog 8 | {{ site.url }}/blog/ 9 | 10 | en-us 11 | Copyright Josh Lockhart 12 | http://blogs.law.harvard.edu/tech/rss 13 | hello@joshlockhart.com 14 | hello@joshlockhart.com 15 | {% for post in site.posts limit:10 %} 16 | 17 | {{ post.title }} 18 | {{ site.url }}{{ post.url }} 19 | 20 | 23 | 24 | {{ post.date|date_to_rfc822 }} 25 | {{ site.url }}{{ post.url }} 26 | 27 | {% endfor %} 28 | 29 | 30 | -------------------------------------------------------------------------------- /_includes/maintainers.html: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /_posts/2011-12-29-version-numbers.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Version Numbers 3 | description: The Slim Framework for PHP 5 will migrate to a major, minor, revision versioning scheme 4 | layout: post 5 | --- 6 | 7 | Thus far, the Slim Framework’s version numbers have mostly adhered to the major.minor.revision scheme. However, sometimes the version numbers have strayed from this practice. Slim is my first large open source project, and it is an ongoing learning experience for me as Slim’s user base continues to flourish. 8 | 9 | The latest stable Slim Framework release is version 1.5.1.4. The next planned release is tentatively 1.5.2. Because the tentative 1.5.2 release is still in the development branch, I will use this opportunity to return to the major.minor.revision scheme and tag it as version 1.6.0. 10 | 11 | With version 1.6.0 and all subsequent releases, the version number will always use the major.minor.revision scheme. 12 | 13 | Version 1.6.0 will introduce the `Slim::VERSION` constant. This constant will be a string version number (e.g. “1.6.0”) so you can reference the framework version in your code if necessary. 14 | -------------------------------------------------------------------------------- /_posts/2015-02-23-modx-cms-and-slim.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: MODX to be rebuilt on top of Slim 3.x 3 | description: The popular MODX content management platform will be rebuilt on top of the Slim Framework. 4 | layout: post 5 | --- 6 | 7 | MODX Logo 8 | 9 | The popular [MODX](http://modx.com) content management platform will be rebuilt on top of the upcoming Slim Framework 3.x release. This is exciting news! [Jason Coward](https://twitter.com/drumshaman), co-founder and lead architect of MODX, announced the decision this morning [on his Medium blog](https://medium.com/@drumshaman/keeping-modx-relevant-part-two-15a37eab5b48). Jason attributes his decision to Slim's early adoption of the [PSR-7 standard](https://github.com/php-fig/fig-standards/blob/master/proposed/http-message.md), Slim's abundant unit tests, Slim's middleware architecture, and Slim's overall minimalist approach. I can't wait to see what MODX has in store! 10 | 11 | * [Read the Announcement](https://medium.com/@drumshaman/keeping-modx-relevant-part-two-15a37eab5b48) 12 | * [Visit MODX](http://modx.com) 13 | -------------------------------------------------------------------------------- /assets/less/fontawesome/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | .fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | 15 | .fa-icon-rotate(@degrees, @rotation) { 16 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation); 17 | -webkit-transform: rotate(@degrees); 18 | -ms-transform: rotate(@degrees); 19 | transform: rotate(@degrees); 20 | } 21 | 22 | .fa-icon-flip(@horiz, @vert, @rotation) { 23 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation, mirror=1); 24 | -webkit-transform: scale(@horiz, @vert); 25 | -ms-transform: scale(@horiz, @vert); 26 | transform: scale(@horiz, @vert); 27 | } 28 | -------------------------------------------------------------------------------- /docs/v2/errors/output.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Output 3 | --- 4 | The Slim application's environment will always contain a key **slim.errors** with a value that is a writable 5 | resource to which log and error messages may be written. The Slim application’s log object will write log messages 6 | to **slim.errors** whenever an Exception is caught or the log object is manually invoked. 7 | 8 | If you want to redirect error output to a different location, you can define your own writable resource by 9 | modifying the Slim application’s environment settings. I recommend you use middleware to update the environment: 10 | 11 | app->environment; 18 | $env['slim.errors'] = fopen('/path/to/output', 'w'); 19 | 20 | // Call next middleware 21 | $this->next->call(); 22 | } 23 | } 24 | 25 | Remember, **slim.errors** does not have to point to a file; it can point to any valid writable resource. 26 | -------------------------------------------------------------------------------- /_posts/2012-04-21-version-161.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework Version 1.6.1 3 | description: Slim Framework 1.6.1 provides several bug fixes and general improvements to the previous Slim Framework 1.6.0 release. 4 | layout: post 5 | --- 6 | 7 | I’ve just released Slim Framework 1.6.1 into the stable branch. This release includes several bug fixes and general improvements to the recent 1.6.0 release. Changes in this version include: 8 | 9 | * Add support for `X-Forwarded-For` header in `Slim_Http_Request::getIp()` 10 | * Add improved encryption with more unpredictable encryption IV in Slim_Http_Util 11 | * Add DELETE request body parsing in `Slim_Http_Request::delete()` 12 | * Fix host name and port parsing in Slim_Http_Request 13 | * Fix HTTP header parsing in Slim_Environment, trim whitespace from values 14 | * Fix logging and pass log level as second argument to custom log writers’ * `write()` method 15 | * Fix request body parsing for multipart HTTP requests in Slim_Http_Request 16 | * Fix URI parsing regression for Windows users in Slim_Environment 17 | * Replace logo.png in repo with base64-encoded image tag 18 | 19 | Enjoy! 20 | -------------------------------------------------------------------------------- /_posts/2015-02-25-slim-github-organization.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework GitHub Organization 3 | description: The Slim Framework code repositories have a new home in their very own GitHub Organization. 4 | layout: post 5 | --- 6 | 7 | The Slim Framework code repositories have a new home in their very own [GitHub Organization](https://github.com/slimphp). As much as I'd like to keep the project beneath my own GitHub handle for the notoriety and what not, the project is best served with its own GitHub Organization. This solves several problems. 8 | 9 | First, it solves the bus factor. Should anyone decide to run me over with a bus (please don't), the GitHub project is not owned by a single individual. Instead, it is owned by a team of dedicated users who all have access to the necessary repositories. Second, it consolidates all of Slim's related repositories beneath a single umbrella to simplify discovery and improve the project's brand. 10 | 11 | For those of you who install Slim with Composer, you do not need to change anything. Composer installation works exactly the same as before. 12 | 13 | [Visit the GitHub Organization page](https://github.com/slimphp) 14 | -------------------------------------------------------------------------------- /_posts/2020-04-14-slim-4.5.0-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 4.5.0 released 3 | description: Slim 4.5.0 released 4 | layout: post 5 | --- 6 | 7 | We are excited to announce the Slim 4.5.0 release. Please direct all your feedback for this release to the [Slim 4 Release Feedback Thread](https://github.com/slimphp/Slim/issues/2770). The new docs are located [here](http://www.slimframework.com/docs/v4). 8 | 9 | # Changelog 10 | 11 | ## 4.5.0 - 2020-04-14 12 | 13 | ### Added 14 | - [2928](https://github.com/slimphp/Slim/pull/2928) Test against PHP 7.4 15 | - [2937](https://github.com/slimphp/Slim/pull/2937) Add support for PSR-3 16 | 17 | ### Fixed 18 | - [2916](https://github.com/slimphp/Slim/pull/2916) Rename phpcs.xml to phpcs.xml.dist 19 | - [2917](https://github.com/slimphp/Slim/pull/2917) Update .editorconfig 20 | - [2925](https://github.com/slimphp/Slim/pull/2925) ResponseEmitter: Don't remove Content-Type and Content-Length when body is empt 21 | - [2932](https://github.com/slimphp/Slim/pull/2932) Update the Tidelift enterprise language 22 | - [2938](https://github.com/slimphp/Slim/pull/2938) Modify usage of deprecated expectExceptionMessageRegExp() method 23 | -------------------------------------------------------------------------------- /docs/v2/flash/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 |
5 | Heads Up! Flash messages require sessions. If you do not use the 6 | \Slim\Middleware\SessionCookie middleware, you must start a native PHP session yourself. 7 |
8 | 9 | Slim supports flash messaging much like Rails and other larger web frameworks. Flash messaging allows you to define 10 | messages that will persist until the next HTTP request but no further. This is helpful to display messages to the user 11 | after a given event or error occurs. 12 | 13 | As shown below, the Slim application’s `flash()` and `flashNow()` methods accept two arguments: a key and a message. 14 | The key may be whatever you want and defines how the message will be accessed in the view templates. For example, 15 | if I invoke the Slim application’s `flash('foo', 'The foo message')` method with those arguments, I can access that 16 | message in the next request’s templates with `flash['foo']`. 17 | 18 | Flash messages are persisted with sessions; sessions are required for flash messages to work. Flash messages are 19 | stored in `$_SESSION['slim.flash']`. 20 | -------------------------------------------------------------------------------- /_posts/2012-08-27-version-166.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework Version 1.6.6 3 | description: Slim Framework 1.6.6 is a minor update recommended for all users 4 | layout: post 5 | --- 6 | 7 | I’ve just released Slim Framework 1.6.6. This minor release is recommended for everyone and includes the following changes: 8 | 9 | * Simplify, optimize router regular expressions 10 | * Revert SPL autoloader to previous state 11 | * Reduce global namespace footprint 12 | * Numerous documentation fixes 13 | * Fix content type for Slim’s debugging error handler 14 | * Delay resource URI injection into Slim_Router 15 | * Add Travis CI integration 16 | * Add PHPUnit XML configuration 17 | 18 | Before version 1.6.6, Slim had a large global namespace footprint. Version 1.6.6 removes Slim’s global namespace footprint entirely. This means: 19 | 20 | * Slim requires libmcrypt; 21 | * Your existing `error_reporting` setting will be used; 22 | * Slim’s error handler is used only within `Slim::run`; afterward, the previous error handler is restored. 23 | 24 | Visit this URL to view the relevant changes to the source code: 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/v2/response/body.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Body 3 | --- 4 | The HTTP response returned to the client will have a body. The HTTP body is the actual content of the HTTP response 5 | delivered to the client. You can use the Slim application’s response object to set the HTTP response’s body: 6 | 7 | response->setBody('Foo'); 12 | 13 | // Append response body 14 | $app->response->write('Bar'); 15 | 16 | When you overwrite or append the response object’s body, the response object will automatically set the 17 | **Content-Length** header based on the bytesize of the new response body. 18 | 19 | You can fetch the response object’s body like this: 20 | 21 | response->getBody(); 23 | 24 | Usually, you will never need to manually set the response body with the `setBody()` or `write()` methods; instead, 25 | the Slim app will do this for you. Whenever you `echo()` content inside a route's callback function, the 26 | `echo()`’d content is captured in an output buffer and appended to the response body before the HTTP response 27 | is returned to the client. 28 | -------------------------------------------------------------------------------- /_posts/2016-11-27-starting-slim-framework-v4.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: We're getting ready to start work on Slim Framework v4.0 3 | description: We're getting ready to start work on Slim Framework v4.0 4 | layout: post 5 | --- 6 | 7 | We are happy to announce that we will soon start work on Slim Framework version 4.0. You can see our project road map on our [GitHub issue tracker](https://github.com/slimphp/Slim/issues?q=is%3Aopen+is%3Aissue+milestone%3A4.0). 8 | 9 | I wanted to extend a big thank you to Rob Allen, Andrew Smith, and all of Slim's contributors who have helped keep the project moving along while I've been focused elsewhere. I am happy to announce that I'm finally available to contribute more of my time to Slim again. I look forward to working with Rob, Andrew, and the rest of the Slim Framework contributors to make a big push toward version 4.0! 10 | 11 | If you have any questions, or if you would like to help work on version 4.0, please reach out via the GitHub issue tracker or on [Slim's Slack channel](https://www.slimframework.com/#community). 12 | 13 | Thank you, 14 | 15 | Josh 16 | 17 | -- 18 | Josh Lockhart 19 | Founder, Slim Framework 20 | http://slimframework.com 21 | 22 | -------------------------------------------------------------------------------- /docs/v2/view/rendering.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Rendering 3 | --- 4 | You can use the Slim application’s `render()` method to ask the current view object to render a template with a 5 | given set of variables. The Slim application's `render()` method will `echo()` the output returned from the view 6 | object to be captured by an output buffer and appended automatically to the response object’s body. This assumes 7 | nothing about how the template is rendered; that is delegated to the view object. 8 | 9 | get('/books/:id', function ($id) use ($app) { 12 | $app->render('myTemplate.php', array('id' => $id)); 13 | }); 14 | 15 | If you need to pass data from the route callback into the view object, you must explicitly do so by passing an 16 | array as the second argument of the Slim application’s `render()` method like this: 17 | 18 | render( 20 | 'myTemplate.php', 21 | array( 'name' => 'Josh' ) 22 | ); 23 | 24 | You can also set the HTTP response status when you render a template: 25 | 26 | render( 28 | 'myTemplate.php', 29 | array( 'name' => 'Josh' ), 30 | 404 31 | ); 32 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/image.less: -------------------------------------------------------------------------------- 1 | // Image Mixins 2 | // - Responsive image 3 | // - Retina image 4 | 5 | 6 | // Responsive image 7 | // 8 | // Keep images from scaling beyond the width of their parents. 9 | .img-responsive(@display: block) { 10 | display: @display; 11 | max-width: 100%; // Part 1: Set a maximum relative to the parent 12 | height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching 13 | } 14 | 15 | 16 | // Retina image 17 | // 18 | // Short retina mixin for setting background-image and -size. Note that the 19 | // spelling of `min--moz-device-pixel-ratio` is intentional. 20 | .img-retina(@file-1x; @file-2x; @width-1x; @height-1x) { 21 | background-image: url("@{file-1x}"); 22 | 23 | @media 24 | only screen and (-webkit-min-device-pixel-ratio: 2), 25 | only screen and ( min--moz-device-pixel-ratio: 2), 26 | only screen and ( -o-min-device-pixel-ratio: 2/1), 27 | only screen and ( min-device-pixel-ratio: 2), 28 | only screen and ( min-resolution: 192dpi), 29 | only screen and ( min-resolution: 2dppx) { 30 | background-image: url("@{file-2x}"); 31 | background-size: @width-1x @height-1x; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /assets/bootstrap/less/jumbotron.less: -------------------------------------------------------------------------------- 1 | // 2 | // Jumbotron 3 | // -------------------------------------------------- 4 | 5 | 6 | .jumbotron { 7 | padding: @jumbotron-padding (@jumbotron-padding / 2); 8 | margin-bottom: @jumbotron-padding; 9 | color: @jumbotron-color; 10 | background-color: @jumbotron-bg; 11 | 12 | h1, 13 | .h1 { 14 | color: @jumbotron-heading-color; 15 | } 16 | 17 | p { 18 | margin-bottom: (@jumbotron-padding / 2); 19 | font-size: @jumbotron-font-size; 20 | font-weight: 200; 21 | } 22 | 23 | > hr { 24 | border-top-color: darken(@jumbotron-bg, 10%); 25 | } 26 | 27 | .container &, 28 | .container-fluid & { 29 | border-radius: @border-radius-large; // Only round corners at higher resolutions if contained in a container 30 | } 31 | 32 | .container { 33 | max-width: 100%; 34 | } 35 | 36 | @media screen and (min-width: @screen-sm-min) { 37 | padding: (@jumbotron-padding * 1.6) 0; 38 | 39 | .container &, 40 | .container-fluid & { 41 | padding-left: (@jumbotron-padding * 2); 42 | padding-right: (@jumbotron-padding * 2); 43 | } 44 | 45 | h1, 46 | .h1 { 47 | font-size: (@font-size-base * 4.5); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /docs/v2/routing/groups.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Groups 3 | --- 4 | Slim lets you group related routes. This is helpful when you find yourself repeating the same URL segments 5 | for multiple routes. This is best explained with an example. Let's pretend we are building an API for 6 | books. 7 | 8 | group('/api', function () use ($app) { 13 | 14 | // Library group 15 | $app->group('/library', function () use ($app) { 16 | 17 | // Get book with ID 18 | $app->get('/books/:id', function ($id) { 19 | 20 | }); 21 | 22 | // Update book with ID 23 | $app->put('/books/:id', function ($id) { 24 | 25 | }); 26 | 27 | // Delete book with ID 28 | $app->delete('/books/:id', function ($id) { 29 | 30 | }); 31 | 32 | }); 33 | 34 | }); 35 | 36 | The routes defined above would be accessible at, respectively: 37 | 38 | GET /api/library/books/:id 39 | PUT /api/library/books/:id 40 | DELETE /api/library/books/:id 41 | 42 | Route groups are very useful to group related routes and avoid repeating common URL segments 43 | for each route definition. 44 | -------------------------------------------------------------------------------- /docs/v2/cache/etag.md: -------------------------------------------------------------------------------- 1 | A Slim application provides built-in support for HTTP caching using ETags. An ETag is a unique identifier for a 2 | resource URI. When an ETag header is set with the Slim application's `etag()` method, the HTTP client will send 3 | an **If-None-Match** header with each subsequent HTTP request of the same resource URI. If the ETag value for the 4 | resource URI matches the **If-None-Match** HTTP request header, the Slim application will return a 5 | **304 Not Modified** HTTP response that will prompt the HTTP client to continue using its cache; this also prevents 6 | the Slim application from serving the entire markup for the resource URI, saving bandwidth and response time. 7 | 8 | Setting an ETag with Slim is very simple. Invoke the Slim application's `etag()` method in your route callback, 9 | passing it a unique ID as the first and only argument. 10 | 11 | get('/foo', function () use ($app) { 13 | $app->etag('unique-id'); 14 | echo "This will be cached after the initial request!"; 15 | }); 16 | 17 | That’s it. Make sure the ETag ID is unique for the given resource. Also make sure the ETag ID changes as your 18 | resource changes; otherwise, the HTTP client will continue serving its outdated cache. 19 | -------------------------------------------------------------------------------- /_posts/2012-08-29-moving-forward.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Moving Forward 3 | description: The next version of the Slim Framework will provide namespaces and PSR-2 compliance 4 | layout: post 5 | --- 6 | 7 | The next version of the Slim Framework will introduce PHP [namespaces](http://us3.php.net/manual/language.namespaces.php) and [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) compliance. Because this is a large departure from the past, I will tag this version “2.0” when it is released (soon). 8 | 9 | Why the big change? I started and maintain [PHP The Right Way](http://www.phptherightway.com/), and I believe I should practice what I preach. The Slim Framework currently supports PHP 5.2 or newer. Unfortunately, providing backwards compatibility prevents me from introducing newer features and improvements to the framework. I’ve decided it’s time to adopt modern best practices and move forward. 10 | 11 | The next version of the Slim Framework will require PHP 5.3 or newer. Starting today, the develop branch includes the PHP >= 5.3 code. 12 | 13 | I’m currently updating the framework documentation to reflect these changes. The framework documentation will move into its own separate GitHub Pages repository before the 2.0 release. 14 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------------------------------- 3 | 4 | // Utilities 5 | @import "mixins/hide-text.less"; 6 | @import "mixins/opacity.less"; 7 | @import "mixins/image.less"; 8 | @import "mixins/labels.less"; 9 | @import "mixins/reset-filter.less"; 10 | @import "mixins/resize.less"; 11 | @import "mixins/responsive-visibility.less"; 12 | @import "mixins/size.less"; 13 | @import "mixins/tab-focus.less"; 14 | @import "mixins/text-emphasis.less"; 15 | @import "mixins/text-overflow.less"; 16 | @import "mixins/vendor-prefixes.less"; 17 | 18 | // Components 19 | @import "mixins/alerts.less"; 20 | @import "mixins/buttons.less"; 21 | @import "mixins/panels.less"; 22 | @import "mixins/pagination.less"; 23 | @import "mixins/list-group.less"; 24 | @import "mixins/nav-divider.less"; 25 | @import "mixins/forms.less"; 26 | @import "mixins/progress-bar.less"; 27 | @import "mixins/table-row.less"; 28 | 29 | // Skins 30 | @import "mixins/background-variant.less"; 31 | @import "mixins/border-radius.less"; 32 | @import "mixins/gradients.less"; 33 | 34 | // Layout 35 | @import "mixins/clearfix.less"; 36 | @import "mixins/center-block.less"; 37 | @import "mixins/nav-vertical-align.less"; 38 | @import "mixins/grid-framework.less"; 39 | @import "mixins/grid.less"; 40 | -------------------------------------------------------------------------------- /docs/v2/errors/500.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 500 Errors 3 | --- 4 | You may use the Slim application’s `error()` method to specify a custom error handler to be invoked when an error or 5 | exception occurs. Custom error handlers are only invoked if application debugging is disabled. 6 | 7 | A custom error handler should render a user-friendly message that mitigates user confusion. Similar to the Slim 8 | application’s `notFound()` method, the `error()` method acts as both a getter and a setter. 9 | 10 | ### Set custom error handler 11 | 12 | You may set a custom error handler by passing a callable into the Slim application's `error()` method as its first 13 | and only argument. 14 | 15 | error(function (\Exception $e) use ($app) { 18 | $app->render('error.php'); 19 | }); 20 | 21 | In this example, the custom error handler accepts the caught Exception as its argument. This allows you to respond 22 | appropriately to different exceptions. 23 | 24 | ### Invoke custom error handler 25 | 26 | Usually, the Slim application will automatically invoke the error handler when an exception or error occurs. 27 | However, you may also manually invoke the error handler with the Slim application’s `error()` method 28 | (without an argument). 29 | -------------------------------------------------------------------------------- /docs/v2/start/get-started.md: -------------------------------------------------------------------------------- 1 | # System Requirements 2 | 3 | * PHP >= 5.3.0 4 | 5 | The `mcrypt` extension is required *only* if you use encrypted cookies. 6 | 7 | # Installation 8 | 9 | ## Composer Install 10 | 11 | Install composer in your project: 12 | 13 | curl -s https://getcomposer.org/installer | php 14 | 15 | Create a `composer.json` file in your project root: 16 | 17 | { 18 | "require": { 19 | "slim/slim": "2.*" 20 | } 21 | } 22 | 23 | Install via composer: 24 | 25 | php composer.phar install 26 | 27 | Add this line to your application's `index.php` file: 28 | 29 | get('/hello/:name', function ($name) { 50 | echo "Hello, $name"; 51 | }); 52 | 53 | Run the Slim application: 54 | 55 | $app->run(); 56 | -------------------------------------------------------------------------------- /docs/v4/middleware/output-buffering.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Output Buffering Middleware 3 | --- 4 | 5 | The Output Buffering Middleware enables you to switch between two modes of output buffering: `APPEND` (default) and `PREPEND` mode. 6 | The `APPEND` mode will use the existing response body to append the contents. 7 | The `PREPEND` mode will create a new response body object and prepend the contents to the output from the existing response body. 8 | This middleware should be placed in the center of the middleware stack so it gets executed last. 9 | 10 | ## Usage 11 | 12 | ```php 13 | add($outputBufferingMiddleware); 33 | 34 | // ... 35 | 36 | $app->run(); 37 | ``` 38 | -------------------------------------------------------------------------------- /_posts/2011-12-27-support-forum-now-uses-tender.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Our support forum now uses Tender 3 | description: The Slim Framework for PHP 5 support forum now runs on Tender 4 | layout: post 5 | --- 6 | 7 | I am happy to announce that Slim’s support forum and knowledge base now run on Tender™. We previously used the Vanilla forum software, but it proved unstable and unreliable for many users. I want to extend a big thank you to Tender for setting up an open source account for us. Our initial impression is that it is a phenomenal platform, and we cannot wait to put it to good use. 8 | 9 | If you have questions about how something in Slim works, or if you run into a problem, open a new discussion at and our support team (just me at the moment) will try to help you as best we can. 10 | 11 | The new support forum is also a great place for you to help others and share your work. If you have a cool project you built with Slim, definitely show it off in the forum. We’d love to see and promote what you’ve done with Slim. 12 | 13 | If you run a business of your own and need a support forum, I highly recommend Tender™; it seems like a brilliant platform, and I know first-hand that the folks on its support team are top notch. 14 | 15 | [Visit Our Support Forum](http://help.slimframework.com/) 16 | -------------------------------------------------------------------------------- /docs/v2/errors/404.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 404 Errors 3 | --- 4 | It is an inevitability that someone will request a page that does not exist. The Slim application lets you easily 5 | define a custom Not Found handler with the Slim application’s `notFound()` method. The Not Found handler will be 6 | invoked when a matching route is not found for the current HTTP request. This method acts as both a getter and a setter. 7 | 8 | ### Set not found handler 9 | 10 | If you invoke the Slim application’s `notFound()` method and specify a callable object as its first and only 11 | argument, this method will register the callable object as the Not Found handler. However, the registered handler 12 | will not be invoked. 13 | 14 | notFound(function () use ($app) { 17 | $app->render('404.html'); 18 | }); 19 | 20 | ### Invoke not found handler 21 | 22 | If you invoke the Slim application’s `notFound()` method without any arguments, this method will invoke the 23 | previously registered Not Found handler. 24 | 25 | get('/hello/:name', function ($name) use ($app) { 28 | if ( $name === 'Waldo' ) { 29 | $app->notFound(); 30 | } else { 31 | echo "Hello, $name"; 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /assets/bootstrap/less/mixins/buttons.less: -------------------------------------------------------------------------------- 1 | // Button variants 2 | // 3 | // Easily pump out default styles, as well as :hover, :focus, :active, 4 | // and disabled options for all buttons 5 | 6 | .button-variant(@color; @background; @border) { 7 | color: @color; 8 | background-color: @background; 9 | border-color: @border; 10 | 11 | &:hover, 12 | &:focus, 13 | &.focus, 14 | &:active, 15 | &.active, 16 | .open > .dropdown-toggle& { 17 | color: @color; 18 | background-color: darken(@background, 10%); 19 | border-color: darken(@border, 12%); 20 | } 21 | &:active, 22 | &.active, 23 | .open > .dropdown-toggle& { 24 | background-image: none; 25 | } 26 | &.disabled, 27 | &[disabled], 28 | fieldset[disabled] & { 29 | &, 30 | &:hover, 31 | &:focus, 32 | &.focus, 33 | &:active, 34 | &.active { 35 | background-color: @background; 36 | border-color: @border; 37 | } 38 | } 39 | 40 | .badge { 41 | color: @background; 42 | background-color: @color; 43 | } 44 | } 45 | 46 | // Button sizes 47 | .button-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) { 48 | padding: @padding-vertical @padding-horizontal; 49 | font-size: @font-size; 50 | line-height: @line-height; 51 | border-radius: @border-radius; 52 | } 53 | -------------------------------------------------------------------------------- /docs/v3/features/flash.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Flash Messages 3 | --- 4 | 5 | ## Install 6 | 7 | Via Composer 8 | 9 | ``` bash 10 | $ composer require slim/flash 11 | ``` 12 | 13 | Requires Slim 3.0.0 or newer. 14 | 15 | ## Usage 16 | 17 | ```php 18 | // Start PHP session 19 | session_start(); //by default requires session storage 20 | 21 | $app = new \Slim\App(); 22 | 23 | // Fetch DI Container 24 | $container = $app->getContainer(); 25 | 26 | // Register provider 27 | $container['flash'] = function () { 28 | return new \Slim\Flash\Messages(); 29 | }; 30 | 31 | $app->get('/foo', function ($req, $res, $args) { 32 | // Set flash message for next request 33 | $this->flash->addMessage('Test', 'This is a message'); 34 | 35 | // Redirect 36 | return $res->withStatus(302)->withHeader('Location', '/bar'); 37 | }); 38 | 39 | $app->get('/bar', function ($req, $res, $args) { 40 | // Add message to be used in current request 41 | $this->flash->addMessageNow('Test', 'This is another message'); 42 | 43 | // Get flash messages from previous request 44 | $messages = $this->flash->getMessages(); 45 | 46 | // Returns both flash messages 47 | print_r($messages); 48 | }); 49 | 50 | $app->run(); 51 | ``` 52 | 53 | Please note that a message could be a string, object or array. Please check what your storage can handle. 54 | -------------------------------------------------------------------------------- /docs/v2/cache/lastmodified.md: -------------------------------------------------------------------------------- 1 | A Slim application provides built-in support for HTTP caching using the resource’s last modified date. When you 2 | specify a last modified date, Slim tells the HTTP client the date and time the current resource was last modified. 3 | The HTTP client will then send a **If-Modified-Since** header with each subsequent HTTP request for the given 4 | resource URI. If the last modification date you specify matches the **If-Modified-Since** HTTP request header, 5 | the Slim application will return a **304 Not Modified** HTTP response that will prompt the HTTP client to use 6 | its cache; this also prevents the Slim application from serving the entire markup for the resource URI saving 7 | bandwidth and response time. 8 | 9 | Setting a last modified date with Slim is very simple. You only need to invoke the Slim application's `lastModified()` 10 | method in your route callback passing in a UNIX timestamp of the last modification date for the given resource. 11 | Be sure the `lastModified()` method’s timestamp updates along with the resource’s last modification date; otherwise, 12 | the browser client will continue serving its outdated cache. 13 | 14 | get('/foo', function () use ($app) { 16 | $app->lastModified(1286139652); 17 | echo "This will be cached after the initial request!"; 18 | }); 19 | -------------------------------------------------------------------------------- /_posts/2013-03-24-cookie-handling-updates.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Cookie handling updates 3 | description: Learn about updates to cookie handling in Slim Framework applications. 4 | layout: post 5 | --- 6 | 7 | The next major point release to the Slim Framework will simplify how you get and set encrypted cookies. Previously, you would use the Slim application’s `getEncryptedCookie()` and `setEncryptedCookie()` methods to get or set an encrypted cookie. 8 | 9 | In the next major point release, you will instead set the new `cookies.encrypt` application setting to true and use the Slim application’s existing `getCookie()` and `setCookie()` methods; all application cookies will be encrypted automatically. 10 | 11 | And with the addition of the new \Slim\Helper\Set interface described in my previous post, you can easily change an encrypted cookie’s settings (name, value, expiration, path, domain, etc.) any time, either in the Slim app or its surrounding middleware; encryption is not applied until the cookies are serialized into raw HTTP headers after the last middleware is run, just before the HTTP response is returned to the client. 12 | 13 | This change is available now in the develop branch for you to test and update your applications. The to-be-deprecated `getEncryptedCookie()` and `setEncryptedCookie()` methods will continue to work until the next major point release. 14 | -------------------------------------------------------------------------------- /assets/bootstrap/less/bootstrap.less: -------------------------------------------------------------------------------- 1 | // Core variables and mixins 2 | @import "variables.less"; 3 | @import "mixins.less"; 4 | 5 | // Reset and dependencies 6 | @import "normalize.less"; 7 | @import "print.less"; 8 | @import "glyphicons.less"; 9 | 10 | // Core CSS 11 | @import "scaffolding.less"; 12 | @import "type.less"; 13 | @import "code.less"; 14 | @import "grid.less"; 15 | @import "tables.less"; 16 | @import "forms.less"; 17 | @import "buttons.less"; 18 | 19 | // Components 20 | @import "component-animations.less"; 21 | @import "dropdowns.less"; 22 | @import "button-groups.less"; 23 | @import "input-groups.less"; 24 | @import "navs.less"; 25 | @import "navbar.less"; 26 | @import "breadcrumbs.less"; 27 | @import "pagination.less"; 28 | @import "pager.less"; 29 | @import "labels.less"; 30 | @import "badges.less"; 31 | @import "jumbotron.less"; 32 | @import "thumbnails.less"; 33 | @import "alerts.less"; 34 | @import "progress-bars.less"; 35 | @import "media.less"; 36 | @import "list-group.less"; 37 | @import "panels.less"; 38 | @import "responsive-embed.less"; 39 | @import "wells.less"; 40 | @import "close.less"; 41 | 42 | // Components w/ JavaScript 43 | @import "modals.less"; 44 | @import "tooltip.less"; 45 | @import "popovers.less"; 46 | @import "carousel.less"; 47 | 48 | // Utility classes 49 | @import "utilities.less"; 50 | @import "responsive-utilities.less"; 51 | -------------------------------------------------------------------------------- /docs/v2/request/method.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Method 3 | --- 4 | Every HTTP request has a method (e.g. GET or POST). You can obtain the current HTTP request method via the Slim 5 | application’s request object: 6 | 7 | /** 8 | * What is the request method? 9 | * @return string (e.g. GET, POST, PUT, DELETE) 10 | */ 11 | $app->request->getMethod(); 12 | 13 | /** 14 | * Is this a GET request? 15 | * @return bool 16 | */ 17 | $app->request->isGet(); 18 | 19 | /** 20 | * Is this a POST request? 21 | * @return bool 22 | */ 23 | $app->request->isPost(); 24 | 25 | /** 26 | * Is this a PUT request? 27 | * @return bool 28 | */ 29 | $app->request->isPut(); 30 | 31 | /** 32 | * Is this a DELETE request? 33 | * @return bool 34 | */ 35 | $app->request->isDelete(); 36 | 37 | /** 38 | * Is this a HEAD request? 39 | * @return bool 40 | */ 41 | $app->request->isHead(); 42 | 43 | /** 44 | * Is this a OPTIONS request? 45 | * @return bool 46 | */ 47 | $app->request->isOptions(); 48 | 49 | /** 50 | * Is this a PATCH request? 51 | * @return bool 52 | */ 53 | $app->request->isPatch(); 54 | 55 | /** 56 | * Is this a XHR/AJAX request? 57 | * @return bool 58 | */ 59 | $app->request->isAjax(); 60 | -------------------------------------------------------------------------------- /assets/bootstrap/less/labels.less: -------------------------------------------------------------------------------- 1 | // 2 | // Labels 3 | // -------------------------------------------------- 4 | 5 | .label { 6 | display: inline; 7 | padding: .2em .6em .3em; 8 | font-size: 75%; 9 | font-weight: bold; 10 | line-height: 1; 11 | color: @label-color; 12 | text-align: center; 13 | white-space: nowrap; 14 | vertical-align: baseline; 15 | border-radius: .25em; 16 | 17 | // Add hover effects, but only for links 18 | a& { 19 | &:hover, 20 | &:focus { 21 | color: @label-link-hover-color; 22 | text-decoration: none; 23 | cursor: pointer; 24 | } 25 | } 26 | 27 | // Empty labels collapse automatically (not available in IE8) 28 | &:empty { 29 | display: none; 30 | } 31 | 32 | // Quick fix for labels in buttons 33 | .btn & { 34 | position: relative; 35 | top: -1px; 36 | } 37 | } 38 | 39 | // Colors 40 | // Contextual variations (linked labels get darker on :hover) 41 | 42 | .label-default { 43 | .label-variant(@label-default-bg); 44 | } 45 | 46 | .label-primary { 47 | .label-variant(@label-primary-bg); 48 | } 49 | 50 | .label-success { 51 | .label-variant(@label-success-bg); 52 | } 53 | 54 | .label-info { 55 | .label-variant(@label-info-bg); 56 | } 57 | 58 | .label-warning { 59 | .label-variant(@label-warning-bg); 60 | } 61 | 62 | .label-danger { 63 | .label-variant(@label-danger-bg); 64 | } 65 | -------------------------------------------------------------------------------- /docs/v2/request/variables.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Variables 3 | --- 4 | An HTTP request may have associated variables (not to be confused with route variables). The GET, POST, or PUT 5 | variables sent with the current HTTP request are exposed via the Slim application’s request object. 6 | 7 | If you want to quickly fetch a request variable value without considering its type, use the request object's `params()` 8 | method: 9 | 10 | request->params('paramName'); 13 | 14 | The `params()` method will first search PUT variables, then POST variables, then GET variables. If no variables 15 | are found, `null` is returned. If you only want to search for a specific type of variable, you can use these 16 | methods instead: 17 | 18 | request->get('paramName'); 21 | 22 | //POST variable 23 | $paramValue = $app->request->post('paramName'); 24 | 25 | //PUT variable 26 | $paramValue = $app->request->put('paramName'); 27 | 28 | If a variable does not exist, each method above will return `null`. You can also invoke any of these functions without 29 | an argument to obtain an array of all variables of the given type: 30 | 31 | request->get(); 33 | $allPostVars = $app->request->post(); 34 | $allPutVars = $app->request->put(); 35 | -------------------------------------------------------------------------------- /docs/v2/hooks/how-to-use.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How to use 3 | --- 4 | A callable is assigned to a hook using the Slim application’s `hook()` method: 5 | 6 | hook('the.hook.name', function () { 9 | //Do something 10 | }); 11 | 12 | The first argument is the hook name, and the second argument is the callable. Each hook maintains a priority 13 | list of registered callables. By default, each callable assigned to a hook is given a priority of 10. You can give 14 | your callable a different priority by passing an integer as the third parameter of the `hook()` method: 15 | 16 | hook('the.hook.name', function () { 19 | //Do something 20 | }, 5); 21 | 22 | The example above assigns a priority of 5 to the callable. When the hook is called, it will sort all callables 23 | assigned to it by priority (ascending). A callable with priority 1 will be invoked before a callable with priority 10. 24 | 25 | Hooks do not pass arguments to their callables. If a callable needs to access the Slim application, you can inject 26 | the application into the callback with the `use` keyword or with the Slim application's static `getInstance()` method: 27 | 28 | hook('the.hook.name', function () use ($app) { 31 | // Do something 32 | }); 33 | -------------------------------------------------------------------------------- /_posts/2017-11-26-slim-3.9.1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.9.1 (and 3.9.2) released 3 | description: Slim 3.9.1 (and 3.9.2) released 4 | layout: post 5 | --- 6 | 7 | After the release of 3.9.0, a regression and an unexpected side-effect of a bug fix were noticed. 8 | 9 | Firstly, you could not clear the user's password when using `Uri::withUserInfo('')`, so this is fixed in [#2332](https://github.com/slimphp/Slim/pull/2332). 10 | 11 | Secondly, we discovered that `return $response->withHeader('Location', '/login');` no longer redirected in a browser. This isn't a surprise as the `302` status code isn't explicitly set developers were relying on a feature of PHP's [`header()`](http://php.net/manual/en/function.header.php) function that set `302` for them. This side-effect was causing other issues such as [#1730](https://github.com/slimphp/Slim/issues/1730), so it was fixed in 3.9.0. To mitigate the effect of this change, 3.9.1 includes [#2345](https://github.com/slimphp/Slim/pull/2345) which sets the status code to `302` when you add a `Location` header if the status code is currently 200. This change will not be forward-ported to 4.x though. 12 | 13 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.9.1+is%3Aclosed) 14 | 15 | *Update:* Shortly after the release of 3.9.1, it was discovered that [#2342](https://github.com/slimphp/Slim/pull/2342) should not have been merged as it breaks BC, so this PR was reverted in 3.9.2. 16 | -------------------------------------------------------------------------------- /docs/v2/logging/levels.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Levels 3 | --- 4 | 5 |
6 | Heads Up! Use the \Slim\Log constants when setting the log level instead 7 | of using raw integers. 8 |
9 | 10 | The Slim application’s log object will respect or ignore logged messages based on its log level setting. When you 11 | invoke the log object’s methods, you are inherently assigning a level to the logged message. 12 | The available log levels are: 13 | 14 | \Slim\Log::EMERGENCY 15 | : Level 1 16 | 17 | \Slim\Log::ALERT 18 | : Level 2 19 | 20 | \Slim\Log::CRITICAL 21 | : Level 3 22 | 23 | \Slim\Log::ERROR 24 | : Level 4 25 | 26 | \Slim\Log::WARN 27 | : Level 5 28 | 29 | \Slim\Log::NOTICE 30 | : Level 6 31 | 32 | \Slim\Log::INFO 33 | : Level 7 34 | 35 | \Slim\Log::DEBUG 36 | : Level 8 37 | 38 | Only messages that have a level less than the current log object’s level will be logged. For example, if the log 39 | object’s level is `\Slim\Log::WARN` (5), the log object will ignore `\Slim\Log::DEBUG` and `\Slim\Log::INFO` messages 40 | but will accept `\Slim\Log::WARN`, `\Slim\Log::ERROR`, and `\Slim\Log::CRITICAL` messages. 41 | 42 | ### How to set the log level 43 | 44 | log->setLevel(\Slim\Log::WARN); 46 | 47 | You can set the log object’s level during application instantiation, too: 48 | 49 | \Slim\Log::WARN 52 | )); 53 | -------------------------------------------------------------------------------- /docs/v2/request/cookies.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Cookies 3 | --- 4 | ### Get Cookies 5 | 6 | A Slim application will automatically parse cookies sent with the current HTTP request. You can fetch cookie values 7 | with the Slim application’s `getCookie()` helper method like this: 8 | 9 | getCookie('foo'); 12 | 13 | Only Cookies sent with the current HTTP request are accessible with this method. If you set a cookie during the 14 | current request, it will not be accessible with this method until the subsequent request. Bear in mind the \Slim\Slim 15 | object's `getCookie()` method is a convenience. You may also retrieve the complete set of HTTP request cookies 16 | directly from the \Slim\Http\Request object like this: 17 | 18 | request->cookies; 20 | 21 | This will return an instance of \Slim\Helper\Set so you can use its simple, standardized interface to inspect the 22 | request's cookies. 23 | 24 | ### Cookie Encryption 25 | 26 | You can optionally choose to encrypt all cookies stored on the HTTP client with the Slim app's `cookies.encrypt` 27 | setting. When this setting is `true`, all cookies will be encrypted using your designated secret key and cipher. 28 | 29 | It's really that easy. Cookies will be encrypted automatically before they are sent to the client. They will also 30 | be decrypted on-demand when you request them with `\Slim\Slim::getCookie()` during subsequent requests. 31 | -------------------------------------------------------------------------------- /docs/v2/view/data.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Data 3 | --- 4 |
5 | Heads Up! Rarely will you set or append data directly on the view object. Usually, you 6 | pass data to the view with the Slim application's `render()` method. 7 | See Rendering Templates. 8 |
9 | 10 | The view object's `setData()` and `appendData()` methods inject data into the view object; the injected data is 11 | available to view templates. View data is stored internally as a key-value array. 12 | 13 | ### Setting Data 14 | 15 | The view object's `setData()` instance method will overwrite existing view data. You may use this method to set a 16 | single variable to a given value: 17 | 18 | view->setData('color', 'red'); 20 | 21 | The view’s data will now contain a key “color” with value “red”. You may also use the view’s `setData()` method 22 | to batch assign an entire array of data: 23 | 24 | view->setData(array( 26 | 'color' => 'red', 27 | 'size' => 'medium' 28 | )); 29 | 30 | Remember, the view’s `setData()` method will replace all previous data. 31 | 32 | ### Appending Data 33 | 34 | The view object also has a `appendData()` method that appends data to the view’s existing data. This method accepts 35 | an array as its one and only argument: 36 | 37 | view->appendData(array( 39 | 'foo' => 'bar' 40 | )); 41 | -------------------------------------------------------------------------------- /assets/bootstrap/less/badges.less: -------------------------------------------------------------------------------- 1 | // 2 | // Badges 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .badge { 8 | display: inline-block; 9 | min-width: 10px; 10 | padding: 3px 7px; 11 | font-size: @font-size-small; 12 | font-weight: @badge-font-weight; 13 | color: @badge-color; 14 | line-height: @badge-line-height; 15 | vertical-align: baseline; 16 | white-space: nowrap; 17 | text-align: center; 18 | background-color: @badge-bg; 19 | border-radius: @badge-border-radius; 20 | 21 | // Empty badges collapse automatically (not available in IE8) 22 | &:empty { 23 | display: none; 24 | } 25 | 26 | // Quick fix for badges in buttons 27 | .btn & { 28 | position: relative; 29 | top: -1px; 30 | } 31 | 32 | .btn-xs & { 33 | top: 0; 34 | padding: 1px 5px; 35 | } 36 | 37 | // Hover state, but only for links 38 | a& { 39 | &:hover, 40 | &:focus { 41 | color: @badge-link-hover-color; 42 | text-decoration: none; 43 | cursor: pointer; 44 | } 45 | } 46 | 47 | // Account for badges in navs 48 | .list-group-item.active > &, 49 | .nav-pills > .active > a > & { 50 | color: @badge-active-color; 51 | background-color: @badge-active-bg; 52 | } 53 | 54 | .list-group-item > & { 55 | float: right; 56 | } 57 | 58 | .list-group-item > & + & { 59 | margin-right: 5px; 60 | } 61 | 62 | .nav-pills > li > a > & { 63 | margin-left: 3px; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /docs/v2/hooks/defaults.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Defaults 3 | --- 4 | These are the default hooks always invoked in a Slim application. 5 | 6 | slim.before 7 | : 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. 8 | 9 | slim.before.router 10 | : 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. 11 | 12 | slim.before.dispatch 13 | : 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. 14 | 15 | slim.after.dispatch 16 | : 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. 17 | 18 | slim.after.router 19 | : 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. 20 | 21 | slim.after 22 | : 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. 23 | -------------------------------------------------------------------------------- /_posts/2012-07-04-skeleton-application.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim Framework Skeleton Application for Rapid Development 3 | description: Use the Slim Framework skeleton application and Composer for rapid application development 4 | layout: post 5 | --- 6 | 7 | After launching a ton of Slim Framework applications, I grew tired of re-configuring the same filesystem structure, the same libraries, and the same boilerplate code time and time again. No more. 8 | 9 | Now, you can quickly install and configure a Slim Framework skeleton application with Composer. The skeleton application uses the latest Slim and Slim-Extras repositories. It also uses Sensio Labs’ Twig template library. 10 | 11 | ## Install Composer 12 | 13 | If you have not installed Composer, do that now. I prefer to install Composer globally in `/usr/local/bin`, but you may also install Composer locally in your current working directory. For this tutorial, I assume you have installed Composer locally. 14 | 15 | 16 | 17 | ## Create A Slim Framework Application 18 | 19 | After you install Composer, run this command from the directory in which you want to install your new Slim Framework application. 20 | 21 | ```bash 22 | php composer.phar create-project slim/slim-skeleton [my-app-name] 23 | ``` 24 | 25 | Replace *[my-app-name]* with the desired directory name for your new application. You’ll want to point your virtual host document root to your new application’s `public/` directory. 26 | 27 | That’s it! Now go build something cool. 28 | -------------------------------------------------------------------------------- /docs/v2/routing/put.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: PUT 3 | --- 4 | Use the Slim application's `put()` method to map a callback function to a resource URI that is requested with 5 | the HTTP PUT method. 6 | 7 | put('/books/:id', function ($id) { 10 | //Update book identified by $id 11 | }); 12 | 13 | In this example, an HTTP PUT request for “/books/1” will invoke the associated callback function, passing "1" as 14 | the callback function's argument. 15 | 16 | The first argument of the Slim application's `put()` method is the resource URI. The last argument is anything that 17 | returns `true` for `is_callable()`. Typically, the last argument will be an [anonymous function][anon-func]. 18 | 19 | ### Method Override 20 | 21 | Unfortunately, modern browsers do not provide native support for HTTP PUT requests. To work around this limitation, 22 | ensure your HTML form’s method attribute is “post”, then add a method override parameter to your HTML form like this: 23 | 24 |
25 | ... other form fields here... 26 | 27 | 28 |
29 | 30 | If you are using [Backbone.js][backbone] or a command-line HTTP client, you may also override the HTTP method by 31 | using the **X-HTTP-Method-Override** header. 32 | 33 | [anon-func]: http://php.net/manual/en/functions.anonymous.php 34 | [backbone]: http://documentcloud.github.com/backbone/ 35 | -------------------------------------------------------------------------------- /docs/v2/routing/delete.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: DELETE 3 | --- 4 | Use the Slim application's `delete()` method to map a callback function to a resource URI that is requested with 5 | the HTTP DELETE method. 6 | 7 | delete('/books/:id', function ($id) { 10 | //Delete book identified by $id 11 | }); 12 | 13 | In this example, an HTTP DELETE request for “/books/1” will invoke the associated callback function, passing "1" as 14 | the callback function's argument. 15 | 16 | The first argument of the Slim application's `delete()` method is the resource URI. The last argument is anything that 17 | returns `true` for `is_callable()`. Typically, the last argument will be an [anonymous function][anon-func]. 18 | 19 | ### Method Override 20 | 21 | Unfortunately, modern browsers do not provide native support for HTTP DELETE requests. To work around this limitation, 22 | ensure your HTML form’s method attribute is “post”, then add a method override parameter to your HTML form like this: 23 | 24 |
25 | ... other form fields here... 26 | 27 | 28 |
29 | 30 | If you are using [Backbone.js][backbone] or a command-line HTTP client, you may also override the HTTP method by 31 | using the **X-HTTP-Method-Override** header. 32 | 33 | [anon-func]: http://php.net/manual/en/functions.anonymous.php 34 | [backbone]: http://backbonejs.org 35 | -------------------------------------------------------------------------------- /docs/v2/middleware/how-to-use.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How to use 3 | --- 4 | Use the Slim application’s `add()` instance method to add new middleware to a Slim application. New middleware will 5 | surround previously added middleware, or the Slim application itself if no middleware has yet been added. 6 | 7 | ### Example Middleware 8 | 9 | This example middleware will capitalize the Slim application's HTTP response body. 10 | 11 | app; 18 | 19 | // Run inner middleware and application 20 | $this->next->call(); 21 | 22 | // Capitalize response body 23 | $res = $app->response; 24 | $body = $res->getBody(); 25 | $res->setBody(strtoupper($body)); 26 | } 27 | } 28 | 29 | ### Add Middleware 30 | 31 | add(new \AllCapsMiddleware()); 34 | $app->get('/foo', function () use ($app) { 35 | echo "Hello"; 36 | }); 37 | $app->run(); 38 | 39 | The Slim application’s `add()` method accepts one argument: a middleware instance. If the middleware instance requires 40 | special configuration, it may implement its own constructor so that it may be configured before it is added to the 41 | Slim application. 42 | 43 | When the example Slim application above is run, the HTTP response body will be an enthusiastic "HELLO"; 44 | -------------------------------------------------------------------------------- /docs/v2/routing/options.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: OPTIONS 3 | --- 4 | Use the Slim application's `options()` method to map a callback function to a resource URI that is requested with 5 | the HTTP OPTIONS method. 6 | 7 | options('/books/:id', function ($id) { 10 | //Return response headers 11 | }); 12 | 13 | In this example, an HTTP OPTIONS request for “/books/1” will invoke the associated callback function, passing "1" as 14 | the callback function's argument. 15 | 16 | The first argument of the Slim application's `options()` method is the resource URI. The last argument is anything that 17 | returns `true` for `is_callable()`. Typically, the last argument will be an [anonymous function][anon-func]. 18 | 19 | ### Method Override 20 | 21 | Unfortunately, modern browsers do not provide native support for HTTP OPTIONS requests. To work around this limitation, 22 | ensure your HTML form’s method attribute is “post”, then add a method override parameter to your HTML form like this: 23 | 24 |
25 | ... other form fields here... 26 | 27 | 28 |
29 | 30 | If you are using [Backbone.js][backbone] or a command-line HTTP client, you may also override the HTTP method by 31 | using the **X-HTTP-Method-Override** header. 32 | 33 | [anon-func]: http://php.net/manual/en/functions.anonymous.php 34 | [backbone]: http://documentcloud.github.com/backbone/ 35 | -------------------------------------------------------------------------------- /docs/v2/routing/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Custom 3 | --- 4 | ### One route, multiple HTTP methods 5 | 6 | Sometimes you may need a route to respond to multiple HTTP methods; sometimes you may need a route to respond to a 7 | custom HTTP method. You can accomplish both with the Route object's `via()` method. This example demonstrates how 8 | to map a resource URI to a callback that responds to multiple HTTP methods. 9 | 10 | map('/foo/bar', function() { 13 | echo "I respond to multiple HTTP methods!"; 14 | })->via('GET', 'POST'); 15 | $app->run(); 16 | 17 | The route defined in this example will respond to both GET and POST requests for the resource identified by “/foo/bar”. 18 | Specify each appropriate HTTP method as a separate string argument to the Route object's `via()` method. Like other 19 | Route methods (e.g. `name()` and `conditions()`), the `via()` method is chainable: 20 | 21 | map('/foo/bar', function() { 24 | echo "Fancy, huh?"; 25 | })->via('GET', 'POST')->name('foo'); 26 | $app->run(); 27 | 28 | ### One route, custom http methods 29 | 30 | The Route object's `via()` method is not limited to just GET, POST, PUT, DELETE, and OPTIONS methods. You may also 31 | specify your own custom HTTP methods (e.g. if you were responding to WebDAV HTTP requests). You can define a route 32 | that responds to a custom “FOO” HTTP method like this: 33 | 34 | map('/hello', function() { 37 | echo "Hello"; 38 | })->via('FOO'); 39 | $app->run(); 40 | -------------------------------------------------------------------------------- /_posts/2016-01-08-slim-3.1.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.1.0 released! 3 | description: Slim 3.1.0 released! 4 | layout: post 5 | --- 6 | 7 | We have released Slim version [3.1.0](https://github.com/slimphp/Slim/releases/tag/3.1.0). This version makes a number of minor issues and improvements since the release of 3.0.0 8 | 9 | 10 | The key changes are: 11 | 12 | ## Added 13 | 14 | * [#1620](https://github.com/slimphp/Slim/pull/1620) - Add `getParsedBodyParam()` and `getQueryParam()` to `Slim\Http\Request`. 15 | * [#1688](https://github.com/slimphp/Slim/pull/1688) - Add `App::process()` to allow running a Slim application when you already have a request and response object. This allows a Slim application to be used within the middleware of another middleware pipeline. 16 | * [#1697](https://github.com/slimphp/Slim/pull/1697) - Add HTTP 451 status code to `Slim\Http\Response`. 17 | 18 | ## Improved 19 | 20 | * [#1670](https://github.com/slimphp/Slim/pull/1670) - Removed `final` from `Slim\Container` to allow extension. 21 | * [#1684](https://github.com/slimphp/Slim/pull/1684) - `withJson()` will now thrown an Exception if it fails to encode. 22 | * [#1706](https://github.com/slimphp/Slim/pull/1706) - Calling a non-existent method on `App` will now throw BadMethodCallException. 23 | 24 | ## Fixed 25 | 26 | * [#1682](https://github.com/slimphp/Slim/pull/1682) - Parse `REQUEST_URL` correctly in `Slim\Http\Uri`. 27 | * [#1698](https://github.com/slimphp/Slim/pull/1698) - `Slim\Http\Request` now correctly determines the HTTP protocol version. 28 | 29 | 30 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.1.0+is%3Aclosed) 31 | 32 | -------------------------------------------------------------------------------- /docs/v2/request/paths.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Paths 3 | --- 4 | Every HTTP request received by a Slim application will have a root URI and a resource URI. 5 | 6 | ### Root URI 7 | 8 | The **root URI** is the physical URL path of the directory in which the Slim application is instantiated and run. 9 | If a Slim application is instantiated in **index.php** within the top-most directory of the virtual host’s 10 | document root, the root URI will be an empty string. If a Slim application is instantiated and run in **index.php** 11 | within a physical subdirectory of the virtual host’s document root, the root URI will be the path to that 12 | subdirectory with a leading slash and without a trailing slash. 13 | 14 | ### Resource URI 15 | 16 | The **resource URI** is the virtual URI path of an application resource. The resource URI will be matched to the 17 | Slim application’s routes. 18 | 19 | Assume the Slim application is installed in a physical subdirectory **/foo** beneath your virtual host’s document root. 20 | Also assume the full HTTP request URL (what you’d see in the browser location bar) is **/foo/books/1**. The root URI 21 | is **/foo** (the path to the physical directory in which the Slim application is instantiated) and the resource URI 22 | is **/books/1** (the path to the application resource). 23 | 24 | You can get the HTTP request’s root URI and resource URI with the request object's 25 | `getRootUri()` and `getResourceUri()` methods: 26 | 27 | request; 32 | 33 | //Get root URI 34 | $rootUri = $req->getRootUri(); 35 | 36 | //Get resource URI 37 | $resourceUri = $req->getResourceUri(); 38 | -------------------------------------------------------------------------------- /docs/v3/cookbook/retrieving-current-route.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Retrieving Current Route 3 | --- 4 | 5 | If you ever need to get access to the current route within your application all you have to do is call the request class' `getAttribute` method with an argument of `'route'` and it will return the current route, which is an instance of the `Slim\Route` class. 6 | 7 | From there you can get the route's name by using `getName()` or get the methods supported by this route via `getMethods()`, etc. 8 | 9 | Note: If you need to access the route from within your app middleware you must set `'determineRouteBeforeAppMiddleware'` to true in your configuration otherwise `getAttribute('route')` will return null. Also `getAttribute('route')` will return null on non-existent routes. 10 | 11 | Example: 12 | ```php 13 | use Slim\App; 14 | use Slim\Exception\NotFoundException; 15 | use Slim\Http\Request; 16 | use Slim\Http\Response; 17 | 18 | $app = new App([ 19 | 'settings' => [ 20 | // Only set this if you need access to route within middleware 21 | 'determineRouteBeforeAppMiddleware' => true 22 | ] 23 | ]); 24 | 25 | // routes... 26 | $app->add(function (Request $request, Response $response, callable $next) { 27 | $route = $request->getAttribute('route'); 28 | 29 | // return NotFound for non-existent route 30 | if (empty($route)) { 31 | throw new NotFoundException($request, $response); 32 | } 33 | 34 | $name = $route->getName(); 35 | $groups = $route->getGroups(); 36 | $methods = $route->getMethods(); 37 | $arguments = $route->getArguments(); 38 | 39 | // do something with that information 40 | 41 | return $next($request, $response); 42 | }); 43 | ``` 44 | -------------------------------------------------------------------------------- /assets/bootstrap/less/code.less: -------------------------------------------------------------------------------- 1 | // 2 | // Code (inline and block) 3 | // -------------------------------------------------- 4 | 5 | 6 | // Inline and block code styles 7 | code, 8 | kbd, 9 | pre, 10 | samp { 11 | font-family: @font-family-monospace; 12 | } 13 | 14 | // Inline code 15 | code { 16 | padding: 2px 4px; 17 | font-size: 90%; 18 | color: @code-color; 19 | background-color: @code-bg; 20 | border-radius: @border-radius-base; 21 | } 22 | 23 | // User input typically entered via keyboard 24 | kbd { 25 | padding: 2px 4px; 26 | font-size: 90%; 27 | color: @kbd-color; 28 | background-color: @kbd-bg; 29 | border-radius: @border-radius-small; 30 | box-shadow: inset 0 -1px 0 rgba(0,0,0,.25); 31 | 32 | kbd { 33 | padding: 0; 34 | font-size: 100%; 35 | font-weight: bold; 36 | box-shadow: none; 37 | } 38 | } 39 | 40 | // Blocks of code 41 | pre { 42 | display: block; 43 | padding: ((@line-height-computed - 1) / 2); 44 | margin: 0 0 (@line-height-computed / 2); 45 | font-size: (@font-size-base - 1); // 14px to 13px 46 | line-height: @line-height-base; 47 | word-break: break-all; 48 | word-wrap: break-word; 49 | color: @pre-color; 50 | background-color: @pre-bg; 51 | border: 1px solid @pre-border-color; 52 | border-radius: @border-radius-base; 53 | 54 | // Account for some code outputs that place code tags in pre tags 55 | code { 56 | padding: 0; 57 | font-size: inherit; 58 | color: inherit; 59 | white-space: pre-wrap; 60 | background-color: transparent; 61 | border-radius: 0; 62 | } 63 | } 64 | 65 | // Enable scrollable blocks of code 66 | .pre-scrollable { 67 | max-height: @pre-scrollable-max-height; 68 | overflow-y: scroll; 69 | } 70 | -------------------------------------------------------------------------------- /docs/v2/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 2 Documentation 3 | --- 4 | # Slim Framework v2 5 | 6 | [![Build Status](https://travis-ci.org/slimphp/Slim.svg?branch=develop)](https://travis-ci.org/slimphp/Slim) 7 | 8 | Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. Learn more at these links: 9 | 10 | - [Website](http://www.slimframework.com) 11 | - [Documentation](http://docs.slimframework.com) 12 | - [Support Forum](http://help.slimframework.com) 13 | - [Twitter](https://twitter.com/slimphp) 14 | 15 | This repository contains documentation for the legacy 2.x branch. 16 | 17 | ## Install 18 | 19 | Via [Composer](https://getcomposer.org/) 20 | 21 | ```bash 22 | $ composer require slim/slim:~2.0 23 | ``` 24 | 25 | Requires PHP 5.3.0 or newer. 26 | 27 | ## Usage 28 | 29 | ```php 30 | $app = new \Slim\Slim(); 31 | $app->get('/hello/:name', function ($name) { 32 | echo "Hello, " . $name; 33 | }); 34 | $app->run(); 35 | ``` 36 | 37 | ## Testing 38 | 39 | ```bash 40 | phpunit 41 | ``` 42 | 43 | ## Contributing 44 | 45 | Please see [CONTRIBUTING](https://github.com/slimphp/Slim/blob/master/CONTRIBUTING.md) for details. 46 | 47 | ## Security 48 | 49 | If you discover any security related issues, please email security@slimframework.com instead of using the issue tracker. 50 | 51 | ## Credits 52 | 53 | - [Josh Lockhart](https://github.com/codeguy) 54 | - [Andrew Smith](https://github.com/silentworks) 55 | - [Gabriel Manricks](https://github.com/gmanricks) 56 | - [All Contributors](https://github.com/slimphp/Slim/graphs/contributors) 57 | 58 | ## License 59 | 60 | The MIT License (MIT). Please see [License File](https://github.com/slimphp/Slim/blob/master/LICENSE.md) for more information. 61 | -------------------------------------------------------------------------------- /_posts/2021-10-04-slim-4.9.0-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 4.9.0 released 3 | description: Slim 4.9.0 released 4 | layout: post 5 | --- 6 | 7 | We are excited to announce the Slim 4.9.0 release. The docs are located [here](http://www.slimframework.com/docs/v4). 8 | 9 | # Changelog 10 | 11 | # 4.9.0 - 2021-10-04 12 | 13 | - [3058: Implement exception class for Gone Http error](https://github.com/slimphp/Slim/pull/3058) thanks to @TheKernelPanic 14 | - [3086: Update slim/psr7 requirement from ^1.3 to ^1.4](https://github.com/slimphp/Slim/pull/3086) thanks to @dependabot[bot] 15 | - [3087: Update nyholm/psr7-server requirement from ^1.0.1 to ^1.0.2](https://github.com/slimphp/Slim/pull/3087) thanks to @dependabot[bot] 16 | - [3093: Update phpstan/phpstan requirement from ^0.12.85 to ^0.12.90](https://github.com/slimphp/Slim/pull/3093) thanks to @dependabot[bot] 17 | - [3099: Allow updated psr log](https://github.com/slimphp/Slim/pull/3099) thanks to @t0mmy742 18 | - [3104: Drop php7.2](https://github.com/slimphp/Slim/pull/3104) thanks to @t0mmy742 19 | - [3106: Use PSR-17 factory from Guzzle/psr7 2.0](https://github.com/slimphp/Slim/pull/3106) thanks to @t0mmy742 20 | - [3108: Update README file](https://github.com/slimphp/Slim/pull/3108) thanks to @t0mmy742 21 | - [3112: Update laminas/laminas-diactoros requirement from ^2.6 to ^2.8](https://github.com/slimphp/Slim/pull/3112) thanks to @dependabot[bot] 22 | - [3114: Update slim/psr7 requirement from ^1.4 to ^1.5](https://github.com/slimphp/Slim/pull/3114) thanks to @dependabot[bot] 23 | - [3115: Update phpstan/phpstan requirement from ^0.12.96 to ^0.12.99](https://github.com/slimphp/Slim/pull/3115) thanks to @dependabot[bot] 24 | - [3116: Remove Zend Diactoros references](https://github.com/slimphp/Slim/pull/3116) thanks to @l0gicgate 25 | -------------------------------------------------------------------------------- /assets/bootstrap/less/grid.less: -------------------------------------------------------------------------------- 1 | // 2 | // Grid system 3 | // -------------------------------------------------- 4 | 5 | 6 | // Container widths 7 | // 8 | // Set the container width, and override it for fixed navbars in media queries. 9 | 10 | .container { 11 | .container-fixed(); 12 | 13 | @media (min-width: @screen-sm-min) { 14 | width: @container-sm; 15 | } 16 | @media (min-width: @screen-md-min) { 17 | width: @container-md; 18 | } 19 | @media (min-width: @screen-lg-min) { 20 | width: @container-lg; 21 | } 22 | } 23 | 24 | 25 | // Fluid container 26 | // 27 | // Utilizes the mixin meant for fixed width containers, but without any defined 28 | // width for fluid, full width layouts. 29 | 30 | .container-fluid { 31 | .container-fixed(); 32 | } 33 | 34 | 35 | // Row 36 | // 37 | // Rows contain and clear the floats of your columns. 38 | 39 | .row { 40 | .make-row(); 41 | } 42 | 43 | 44 | // Columns 45 | // 46 | // Common styles for small and large grid columns 47 | 48 | .make-grid-columns(); 49 | 50 | 51 | // Extra small grid 52 | // 53 | // Columns, offsets, pushes, and pulls for extra small devices like 54 | // smartphones. 55 | 56 | .make-grid(xs); 57 | 58 | 59 | // Small grid 60 | // 61 | // Columns, offsets, pushes, and pulls for the small device range, from phones 62 | // to tablets. 63 | 64 | @media (min-width: @screen-sm-min) { 65 | .make-grid(sm); 66 | } 67 | 68 | 69 | // Medium grid 70 | // 71 | // Columns, offsets, pushes, and pulls for the desktop device range. 72 | 73 | @media (min-width: @screen-md-min) { 74 | .make-grid(md); 75 | } 76 | 77 | 78 | // Large grid 79 | // 80 | // Columns, offsets, pushes, and pulls for the large desktop device range. 81 | 82 | @media (min-width: @screen-lg-min) { 83 | .make-grid(lg); 84 | } 85 | -------------------------------------------------------------------------------- /docs/v4/features/php-view.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: PHP Templates 3 | --- 4 | 5 | ## The slim/php-view component 6 | 7 | The [PHP-View](https://github.com/slimphp/PHP-View) PHP component helps you render PHP templates. 8 | 9 | ## Installation 10 | 11 | ``` 12 | composer require slim/php-view 13 | ``` 14 | 15 | ## Usage 16 | 17 | You can use it with Slim like this: 18 | 19 | ```php 20 | get('/hello', function ($request, $response) { 31 | $renderer = new PhpRenderer(__DIR__ . '/../templates'); 32 | 33 | $viewData = [ 34 | 'name' => 'John', 35 | ]; 36 | 37 | return $renderer->render($response, 'hello.php', $viewData); 38 | })->setName('profile'); 39 | 40 | $app->run(); 41 | ``` 42 | 43 | Create a directory in your project root: `templates/` 44 | 45 | Create a template file within the templates directory: `templates/hello.php` 46 | 47 | **Template content:** 48 | 49 | ```php 50 | 51 | 52 | 53 | 54 | 55 | Slim Example 56 | 57 | 58 |

Hello,

59 | 60 | 61 | ``` 62 | 63 | Output: 64 | 65 | ``` 66 | Hello John 67 | ``` 68 | 69 | **Security note:** It's important to ensure that the dynamic 70 | output is properly [escaped](https://github.com/slimphp/PHP-View?tab=readme-ov-file#escaping-values). 71 | 72 | ## Read more 73 | 74 | * [PHP-View documentation](https://github.com/slimphp/PHP-View) 75 | -------------------------------------------------------------------------------- /_includes/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {% if page.url contains "/docs" %} 5 | 6 | 31 | {% endif %} 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/v2/configuration/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Configuration Overview 3 | --- 4 | 5 | There are two ways to apply settings to the Slim application. First during Slim application instantiation and second 6 | after instantiation. All settings can be applied at instantiation time by passing Slim’s constructor an associative 7 | array. All settings can be retrieved and modified after instantiation, however some of them can not be done simply by 8 | using the config application instance method but will be demonstrated as necessary below. Before I list the available 9 | settings, I want to quickly explain how you may define and inspect settings with your Slim application. 10 | 11 | ### During Instantiation 12 | 13 | To define settings upon instantiation, pass an associative array into the Slim constructor. 14 | 15 | true 18 | )); 19 | 20 | ### After Instantiation 21 | 22 | To define settings after instantiation, the majority can use the config application instance method; the first 23 | argument is the setting name and the second argument is the setting value. 24 | 25 | config('debug', false); 27 | 28 | You may also define multiple settings at once using an associative array: 29 | 30 | config(array( 32 | 'debug' => true, 33 | 'templates.path' => '../templates' 34 | )); 35 | 36 | To retrieve the value of a setting, you also use the config application instance method; however, you only pass one 37 | argument - the name of the setting you wish to inspect. If the setting you request does not exist, `null` is returned. 38 | 39 | config('templates.path'); //returns "../templates" 41 | 42 | You are not limited to the settings shown below; you may also define your own. 43 | -------------------------------------------------------------------------------- /assets/bootstrap/less/alerts.less: -------------------------------------------------------------------------------- 1 | // 2 | // Alerts 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base styles 7 | // ------------------------- 8 | 9 | .alert { 10 | padding: @alert-padding; 11 | margin-bottom: @line-height-computed; 12 | border: 1px solid transparent; 13 | border-radius: @alert-border-radius; 14 | 15 | // Headings for larger alerts 16 | h4 { 17 | margin-top: 0; 18 | // Specified for the h4 to prevent conflicts of changing @headings-color 19 | color: inherit; 20 | } 21 | 22 | // Provide class for links that match alerts 23 | .alert-link { 24 | font-weight: @alert-link-font-weight; 25 | } 26 | 27 | // Improve alignment and spacing of inner content 28 | > p, 29 | > ul { 30 | margin-bottom: 0; 31 | } 32 | 33 | > p + p { 34 | margin-top: 5px; 35 | } 36 | } 37 | 38 | // Dismissible alerts 39 | // 40 | // Expand the right padding and account for the close button's positioning. 41 | 42 | .alert-dismissable, // The misspelled .alert-dismissable was deprecated in 3.2.0. 43 | .alert-dismissible { 44 | padding-right: (@alert-padding + 20); 45 | 46 | // Adjust close link position 47 | .close { 48 | position: relative; 49 | top: -2px; 50 | right: -21px; 51 | color: inherit; 52 | } 53 | } 54 | 55 | // Alternate styles 56 | // 57 | // Generate contextual modifier classes for colorizing the alert. 58 | 59 | .alert-success { 60 | .alert-variant(@alert-success-bg; @alert-success-border; @alert-success-text); 61 | } 62 | 63 | .alert-info { 64 | .alert-variant(@alert-info-bg; @alert-info-border; @alert-info-text); 65 | } 66 | 67 | .alert-warning { 68 | .alert-variant(@alert-warning-bg; @alert-warning-border; @alert-warning-text); 69 | } 70 | 71 | .alert-danger { 72 | .alert-variant(@alert-danger-bg; @alert-danger-border; @alert-danger-text); 73 | } 74 | -------------------------------------------------------------------------------- /_posts/2016-02-25-slim-3.2.0.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 3.2.0 released! 3 | description: Slim 3.2.0 released! 4 | layout: post 5 | --- 6 | 7 | We have released Slim version [3.2.0](https://github.com/slimphp/Slim/releases/tag/3.2.0). There are not that many changes since 3.1.0, but we found a few bugs to fix and have added a few nice improvements, particularly around error handling. 8 | 9 | 10 | The key changes are: 11 | 12 | ## Added 13 | 14 | * [#1736](https://github.com/slimphp/Slim/pull/1736) - Support the `hostOnly` cookie flag 15 | * [#1764](https://github.com/slimphp/Slim/pull/1764) - Write to the PHP error log if displayErrorDetails is false to make it easier to find out what's gone wrong! 16 | * [#1770](https://github.com/slimphp/Slim/pull/1770) - Support PHP 7+ errors in the same way that Exceptions are handled. 17 | 18 | ## Improved 19 | 20 | * [#1716](https://github.com/slimphp/Slim/pull/1716) - Middleware is now only resolved when required. 21 | * [#1745](https://github.com/slimphp/Slim/pull/1745) - Separate service registration from the container to make it easier to use your own Pimple container and then register the default Slim services. 22 | 23 | ## Fixed 24 | 25 | * [#1733](https://github.com/slimphp/Slim/pull/1733) & [#1734](https://github.com/slimphp/Slim/pull/1734) - Allow setting an empty array into the Request's query params and parsed body. 26 | * [#1737](https://github.com/slimphp/Slim/pull/1737) - Do not explicitly set the HTTP status code in `withJson`. 27 | * [#1738](https://github.com/slimphp/Slim/pull/1738) - Named routes added after a call to `pathFor` can now be resolved in subsequent calls to `pathFor`. 28 | * [#1739](https://github.com/slimphp/Slim/pull/1739) - Responses with a body of indeterminate length can now have their content sent. 29 | 30 | 31 | The full list of changes is [here](https://github.com/slimphp/Slim/issues?q=milestone%3A3.2.0+is%3Aclosed) 32 | 33 | -------------------------------------------------------------------------------- /_posts/2024-06-13-slim-4.14.0-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 4.14.0 released 3 | description: Slim 4.14.0 released 4 | layout: post 5 | --- 6 | 7 | We are pleased to have released Slim 4.14.0. As a mature release, there aren't many changes and all are minor and 8 | can be seen [here](https://github.com/slimphp/Slim/releases/tag/4.14.0). 9 | 10 | ## Type hinting with template generics 11 | 12 | This release introduces of [template generic docblocks](https://phpstan.org/blog/generics-in-php-using-phpdocs) into Slim. 13 | 14 | As Slim\App has a getContainer(): ?ContainerInterface method, the generics docblock enables you to specify what type is actually returned when this method is called. 15 | i.e. consider that you are using [PHP-DI](https://php-di.org) and have this code: 16 | 17 | ``` 18 | $container = $this->app->getContainer(); 19 | $entries = $container->getKnownEntryNames(); 20 | ``` 21 | 22 | [Psalm](https://psalm.dev) or [PHPStan](https://phpstan.org/) have no way of knowing that $container is an instance of DI\Container which has a getKnownEntryNames() method and so will complain. 23 | 24 | To inform the static analyzer that we created Slim\App with PHP-DI, we change: /** @var \Slim\App $app */ to /** @var \Slim\App $app */ and now PHPStan knows that getKnownEntryNames() is a valid method call on $container. 25 | 26 | 27 | ### Update your type hints 28 | 29 | For your codebase, if you type hint Slim\App instance variables using /** @var \Slim\App $app */, then you will need to change it to either: 30 | 31 | * /** @var \Slim\App<null> $app */ if you are not using a DI container, or 32 | * /** @var \Slim\App<\Psr\Container\ContainerInterface> $app */ if you are. 33 | 34 | As noted above, you can also type hint to the concrete instance of the container you are using too. 35 | -------------------------------------------------------------------------------- /docs/v2/sessions/cookies.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Cookies 3 | --- 4 | You may also use the `\Slim\Middleware\SessionCookie` middleware to persist session data in encrypted, hashed 5 | HTTP cookies. To enable the session cookie middleware, add the `\Slim\Middleware\SessionCookie` middleware to your 6 | Slim application: 7 | 8 | add(new \Slim\Middleware\SessionCookie(array( 11 | 'expires' => '20 minutes', 12 | 'path' => '/', 13 | 'domain' => null, 14 | 'secure' => false, 15 | 'httponly' => false, 16 | 'name' => 'slim_session', 17 | 'secret' => 'CHANGE_ME', 18 | 'cipher' => MCRYPT_RIJNDAEL_256, 19 | 'cipher_mode' => MCRYPT_MODE_CBC 20 | ))); 21 | 22 | The second argument is optional; it is shown here so you can see the default middleware settings. The session cookie 23 | middleware will work seamlessly with the `$_SESSION` superglobal so you can easily migrate to this session storage 24 | middleware with zero changes to your application code. 25 | 26 | If you use the session cookie middleware, you DO NOT need to start a native PHP session. The `$_SESSION` superglobal 27 | will still be available, and it will be persisted into an HTTP cookie via the middleware layer rather than with 28 | PHP’s native session management. 29 | 30 | Remember, HTTP cookies are inherently limited to only 4 kilobytes of data. If your encrypted session data will exceed 31 | this length, you should instead rely on PHP’s native sessions or an alternate session store. 32 | 33 |
34 | PLEASE NOTE: Client-side storage of session data is not recommended if you are 35 | dealing with sensitive information, even when using Slim's encrypted session cookie middleware. 36 | If you need to store sensitive information, you should encrypt and store the session information 37 | on your server. 38 |
39 | -------------------------------------------------------------------------------- /_posts/2023-04-17-slim-psr7-advisory-CVE-2023-30536.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Security Advisory: Improper header validation in Slim-Psr7" 3 | description: Improper header validation in Slim-Psr7 security advisory released for v1.6.0 and below. This advisory has been assigned CVE-2023-30536. Please upgrade to 1.6.1 to resolve this issue. 4 | layout: post 5 | --- 6 | 7 | A security issue has recently been reported in Slim-Psr7 with the handling of new lines in headers. 8 | 9 | ## Impact 10 | 11 | An attacker could sneak in a newline (\n) into both the header names and values. While the specification states that \r\n\r\n is used to terminate the header list, many servers in the wild will also accept \n\n. An attacker that is able to control the header names that are passed to Slilm-Psr7 would be able to intentionally craft invalid messages, possibly causing application errors or invalid HTTP requests being sent out with an PSR-18 HTTP client. The latter might present a denial of service vector if a remote service’s web application firewall bans the application due to the receipt of malformed requests. 12 | 13 | ## Affected versions 14 | 15 | All versions less than 1.6.1. 16 | 17 | ## Patches 18 | 19 | The issue is patched in version 1.6.1. 20 | 21 | ## Workarounds 22 | 23 | In Slim-Psr7 1.6.0 and below, validate HTTP header keys and/or values, and if using user-supplied values, filter them to strip off leading or trailing newline characters before calling withHeader(). 24 | 25 | For example: 26 | 27 | $request = $request->withHeader(trim($headerName), trim($headerValue)); 28 | 29 | ## Acknowledgments 30 | 31 | We are very grateful to and thank Graham Campbell for reporting this issue, providing a patch and working with us on this issue. 32 | 33 | ## Further information 34 | 35 | * Slim-Psr7 advisory on GitHub 36 | -------------------------------------------------------------------------------- /_posts/2019-10-05-slim-4.3.0-release.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Slim 4.3.0 released 3 | description: Slim 4.3.0 released 4 | layout: post 5 | --- 6 | 7 | We are excited to announce the Slim 4.3.0 release. Please direct all your feedback for this release to the [Slim 4 Release Feedback Thread](https://github.com/slimphp/Slim/issues/2770). The new docs are located [here](http://www.slimframework.com/docs/v4). 8 | 9 | # Changelog 10 | 11 | ## 4.3.0 - 2019-10-05 12 | 13 | ### Added 14 | - [2819](https://github.com/slimphp/Slim/pull/2819) Added description to addRoutingMiddleware() 15 | - [2820](https://github.com/slimphp/Slim/pull/2820) Update link to homepage in composer.json 16 | - [2828](https://github.com/slimphp/Slim/pull/2828) Allow URIs with leading multi-slashes 17 | - [2832](https://github.com/slimphp/Slim/pull/2832) Refactor `FastRouteDispatcher` 18 | - [2835](https://github.com/slimphp/Slim/pull/2835) Rename `pathFor` to `urlFor` in docblock 19 | - [2846](https://github.com/slimphp/Slim/pull/2846) Correcting the branch name as per issue-2843 20 | - [2849](https://github.com/slimphp/Slim/pull/2849) Create class alias for FastRoute\RouteCollector 21 | - [2855](https://github.com/slimphp/Slim/pull/2855) Add list of allowed methods to HttpMethodNotAllowedException 22 | - [2860](https://github.com/slimphp/Slim/pull/2860) Add base path to `$request` and use `RouteContext` to read 23 | 24 | ### Fixed 25 | - [2839](https://github.com/slimphp/Slim/pull/2839) Fix description for handler signature in phpdocs 26 | - [2844](https://github.com/slimphp/Slim/pull/2844) Handle base path by routeCollector instead of RouteCollectorProxy 27 | - [2845](https://github.com/slimphp/Slim/pull/2845) Fix composer scripts 28 | - [2851](https://github.com/slimphp/Slim/pull/2851) Fix example of 'Hello World' app 29 | - [2854](https://github.com/slimphp/Slim/pull/2854) Fix undefined property in tests 30 | 31 | ### Removed 32 | - [2853](https://github.com/slimphp/Slim/pull/2853) Remove unused classes 33 | -------------------------------------------------------------------------------- /assets/less/typography.less: -------------------------------------------------------------------------------- 1 | .brandonLight { 2 | font-family: "brandon-grotesque"; 3 | font-weight: 300; 4 | font-style: normal; 5 | } 6 | .brandonBold { 7 | font-family: "brandon-grotesque"; 8 | font-weight: 700; 9 | font-style: normal; 10 | } 11 | 12 | .latoLight { 13 | font-family: "Lato", sans-serif; 14 | font-weight: 400; 15 | font-style: normal; 16 | } 17 | .latoBold { 18 | font-family: "Lato", sans-serif; 19 | font-weight: 700; 20 | font-style: normal; 21 | } 22 | 23 | html, body { 24 | font-size: 16px; 25 | line-height: @baseline; 26 | } 27 | 28 | h1, h2, h3, h4, h5{ 29 | .latoLight; 30 | } 31 | 32 | a{ 33 | &:hover{ 34 | text-decoration: none; 35 | } 36 | } 37 | 38 | dl{ 39 | dd{ 40 | margin-bottom: 1em; 41 | margin-left: 1em; 42 | } 43 | } 44 | 45 | .divider{ 46 | border-top: 1px solid #CCC; 47 | margin-bottom: 0; 48 | margin-top: @baseline; 49 | text-align: center; 50 | 51 | span{ 52 | background: white; 53 | display: inline-block; 54 | padding: 0 @baseline; 55 | position: relative; 56 | top: -@baseline; 57 | } 58 | } 59 | 60 | blockquote{ 61 | border: none; 62 | padding-top: 1em; 63 | padding-left: 30px; 64 | position: relative; 65 | font-family: "Georgia", sans-serif; 66 | font-size: 24px; 67 | font-style: italic; 68 | line-height: 40px; 69 | 70 | &:before{ 71 | content: "\f10d"; 72 | display: block; 73 | position: absolute; 74 | left: 0; 75 | top: 0.5em; 76 | font-family: "FontAwesome"; 77 | font-size: 24px; 78 | } 79 | } 80 | 81 | figure{ 82 | margin: 0; 83 | padding: 10px 0 20px 0; 84 | 85 | pre{ 86 | margin-bottom: 10px !important; 87 | } 88 | 89 | figcaption{ 90 | color: #777; 91 | font-size: 11px; 92 | line-height: 16px; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /docs/v3/contributors/guidelines.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contributor Guidelines 3 | --- 4 | 5 | I encourage everyone to contribute to the Slim Framework project. You can find the latest code on GitHub at . 6 | 7 | ## Issue Tracker 8 | 9 | You can find outstanding issues on the [GitHub Issue Tracker](https://github.com/slimphp/Slim/issues). If you intend to work on a specific issue, leave a comment on the appropriate thread to inform other project contributors. 10 | 11 | ## Pull Requests 12 | 13 | * Each pull request should contain only one new feature or improvement. 14 | * Pull requests should be submitted to the `master` branch 15 | 16 | ## Code Style 17 | 18 | All pull requests must use the [PSR-2](http://www.php-fig.org/psr/psr-2/) code style. 19 | 20 | * Code MUST use the [PSR-1](http://www.php-fig.org/psr/psr-1/) code style. 21 | * Code MUST use 4 spaces for indenting, not tabs. 22 | * There MUST NOT be a hard limit on line length; the soft limit MUST be 120 characters; lines SHOULD be 80 characters or less. 23 | * There MUST be one blank line after the namespace declaration, and there MUST be one blank line after the block of use declarations. 24 | * Opening braces for classes MUST go on the next line, and closing braces MUST go on the next line after the body. 25 | * Opening braces for methods MUST go on the next line, and closing braces MUST go on the next line after the body. 26 | * Visibility MUST be declared on all properties and methods; abstract and final MUST be declared before the visibility; static MUST be declared after the visibility. 27 | * Control structure keywords MUST have one space after them; method and function calls MUST NOT. 28 | * Opening braces for control structures MUST go on the same line, and closing braces MUST go on the next line after the body. 29 | * Opening parentheses for control structures MUST NOT have a space after them, and closing parentheses for control structures MUST NOT have a space before. 30 | -------------------------------------------------------------------------------- /docs/v3/handlers/not-allowed.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 405 Not Allowed Handler 3 | --- 4 | 5 | If your Slim Framework application has a route that matches the current HTTP request URI **but NOT the HTTP request method**, the application invokes its Not Allowed handler and returns a `HTTP/1.1 405 Not Allowed` response to the HTTP client. 6 | 7 | ## Default Not Allowed handler 8 | 9 | Each Slim Framework application has a default Not Allowed handler. This handler sets the Response status to `405`, it sets the content type to `text/html`, it adds a `Allowed:` HTTP header with a comma-delimited list of allowed HTTP methods, and it writes a simple explanation to the Response body. 10 | 11 | ## Custom Not Allowed handler 12 | 13 | A Slim Framework application's Not Allowed handler is a Pimple service. You can substitute your own Not Allowed handler by defining a custom Pimple factory method with the application container. 14 | 15 | ```php 16 | // Create Slim 17 | $app = new \Slim\App(); 18 | // get the app's di-container 19 | $c = $app->getContainer(); 20 | $c['notAllowedHandler'] = function ($c) { 21 | return function ($request, $response, $methods) use ($c) { 22 | return $response->withStatus(405) 23 | ->withHeader('Allow', implode(', ', $methods)) 24 | ->withHeader('Content-type', 'text/html') 25 | ->write('Method must be one of: ' . implode(', ', $methods)); 26 | }; 27 | }; 28 | ``` 29 | 30 | > **N.B** Check out [Not Found](/docs/v3/handlers/not-found.html) docs for pre-slim creation method using a new instance of `\Slim\Container` 31 | 32 | In this example, we define a new `notAllowedHandler` factory that returns a callable. The returned callable accepts three arguments: 33 | 34 | 1. A `\Psr\Http\Message\ServerRequestInterface` instance 35 | 2. A `\Psr\Http\Message\ResponseInterface` instance 36 | 3. A numeric array of allowed HTTP method names 37 | 38 | The callable **MUST** return an appropriate `\Psr\Http\Message\ResponseInterface` instance. 39 | -------------------------------------------------------------------------------- /_includes/search-box.html: -------------------------------------------------------------------------------- 1 |

Search

2 | 8 | -------------------------------------------------------------------------------- /docs/v4/cookbook/retrieving-current-route.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Retrieving Current Route 3 | --- 4 | 5 | If you ever need to get access to the current route within your application, you will need to instantiate the `RouteContext` object using the incoming `ServerRequestInterface`. 6 | 7 | From there you can get the route via `$routeContext->getRoute()` and access the route's name by using `getName()` or get the methods supported by this route via `getMethods()`, etc. 8 | 9 | **Note:** If you need to access the `RouteContext` object during the middleware cycle before reaching the route handler you will need to add the `RoutingMiddleware` as the outermost middleware before the error handling middleware (See example below). 10 | 11 | Example: 12 | 13 | ```php 14 | add(function (Request $request, RequestHandler $handler) { 26 | $routeContext = RouteContext::fromRequest($request); 27 | $route = $routeContext->getRoute(); 28 | 29 | // return NotFound for non-existent route 30 | if (empty($route)) { 31 | throw new HttpNotFoundException($request); 32 | } 33 | 34 | $name = $route->getName(); 35 | $groups = $route->getGroups(); 36 | $methods = $route->getMethods(); 37 | $arguments = $route->getArguments(); 38 | 39 | // ... do something with the data ... 40 | 41 | return $handler->handle($request); 42 | }); 43 | 44 | // The RoutingMiddleware should be added after our CORS middleware so routing is performed first 45 | $app->addRoutingMiddleware(); 46 | 47 | // The ErrorMiddleware should always be the outermost middleware 48 | $app->addErrorMiddleware(true, true, true); 49 | 50 | // ... 51 | 52 | $app->run(); 53 | ``` 54 | -------------------------------------------------------------------------------- /_posts/2011-09-15-hello-world.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Say Hello World with Slim 3 | description: Build a simple Hello World application with the Slim Framework for PHP 5 4 | layout: post 5 | --- 6 | 7 | This tutorial demonstrates the typical process for writing a Slim Framework application. The Slim Framework uses the front controller pattern to send all HTTP requests through a single file — usually `index.php`. By default, Slim comes with a `.htaccess` file for use with the Apache web server. You'll typically initialize your app, define your routes, and run your app in the ``index.php`. 8 | 9 | ## Step 1: Initialize your app 10 | 11 | First, instantiate your Slim application. Provide an optional array of settings to configure the application. 12 | 13 | ```php 14 | //With default settings 15 | $app = new Slim(); 16 | 17 | //With custom settings 18 | $app = new Slim(array( 19 | 'log.enable' => true, 20 | 'log.path' => './logs', 21 | 'log.level' => 4, 22 | 'view' => 'MyCustomViewClassName' 23 | )); 24 | ``` 25 | 26 | ## Step 2: Define Routes 27 | 28 | Third, define the application’s routes with the methods shown in the example below. 29 | 30 | I recommend PHP >= 5.3 to enjoy Slim’s support for anonymous functions. If using a lesser PHP version, the final argument may be anything that returns true for `is_callable()`. 31 | 32 | ```php 33 | //GET route 34 | $app->get('/hello/:name', function ($name) { 35 | echo "Hello, $name"; 36 | }); 37 | 38 | //POST route 39 | $app->post('/person', function () { 40 | //Create new Person 41 | }); 42 | 43 | //PUT route 44 | $app->put('/person/:id', function ($id) { 45 | //Update Person identified by $id 46 | }); 47 | 48 | //DELETE route 49 | $app->delete('/person/:id', function ($id) { 50 | //Delete Person identified by $id 51 | }); 52 | ``` 53 | 54 | ## Step 3: Run The Application 55 | 56 | Finally, run your Slim application. This will usually be the final statement executed in the `index.php` file. 57 | 58 | ```php 59 | $app->run(); 60 | ``` 61 | -------------------------------------------------------------------------------- /docs/v2/logging/writers.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Writers 3 | --- 4 | The Slim application’s log object has a log writer. The log writer is responsible for sending a logged message to 5 | the appropriate output (e.g. STDERR, a log file, a remote web service, Twitter, or a database). Out of the box, 6 | the Slim application’s log object has a log writer of class `\Slim\LogFileWriter`; this log writer directs output 7 | to the resource handle referenced by the application environment’s **slim.errors** key (by default, this is 8 | “php://stderr”). You may also define and use a custom log writer. 9 | 10 | ### How to use a custom log writer 11 | 12 | A custom log writer must implement the following public interface: 13 | 14 | new MyLogWriter() 23 | )); 24 | 25 | You may also set a custom log writer with middleware like this: 26 | 27 | app->log->setWriter(new \MyLogWriter()); 34 | 35 | //Call next middleware 36 | $this->next->call(); 37 | } 38 | } 39 | 40 | You can set the log writer similarly in an application hook or route callback like this: 41 | 42 | hook('slim.before', function () use ($app) { 44 | $app->log->setWriter(new \MyLogWriter()); 45 | }); 46 | 47 | If you only need to redirect error output to a different resource handle, use the Slim application's default log writer; 48 | it writes log messages to a resource handle. All you need to do is set the **slim.errors** environment variable to a 49 | valid resource handle. 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Slim Framework Website 2 | 3 | This is the repository for the Slim website ([slimframework.com][slimframework-url]). 4 | 5 | ## Want to contribute? 6 | 7 | If you spot any errors, typos, or missing information, please submit [a pull request][pr-url]. 8 | 9 | ### The documentation style guide 10 | 11 | Unless otherwise stated, the documentation follows [the AP Stylebook][ap-stylebook-url]. 12 | 13 | ### Are you a Microsoft Windows user 14 | 15 | You need to make sure you have [Ruby Devkit Installed (MSYS2)](https://rubyinstaller.org/add-ons/devkit.html). 16 | 17 | ### Building and running the documentation locally 18 | 19 | To run this site locally so that you can test your changes: 20 | 21 | ```bash 22 | $ sudo gem install bundler 23 | $ bundle install 24 | ``` 25 | 26 | Now, run the local [Jekyll][jekyll-url] installation: 27 | 28 | ```bash 29 | $ bundle exec jekyll serve 30 | ``` 31 | 32 | Then, browse to http://localhost:4000 in your browser of choice. 33 | 34 | #### Editing the site's CSS 35 | 36 | The CSS uses Less and is managed by `grunt`. 37 | 38 | Install the tool chain: 39 | 40 | ```bash 41 | $ npm install -g grunt-cli 42 | $ npm install 43 | ``` 44 | 45 | To change any CSS, edit the appropriate files in `assets\less` and then run: 46 | 47 | ```bash 48 | grunt 49 | ``` 50 | 51 | You can also run `grunt watch` to automatically rebuild when you make CSS changes. 52 | 53 | ### Build instructions for deployment 54 | 55 | ```bash 56 | bundle exec jekyll build 57 | ``` 58 | 59 | ### Update the Algolia search database 60 | 61 | Ensure you set the environment variable `ALGOLIA_API_KEY` before running these commands. 62 | See [algolia docs](https://community.algolia.com/jekyll-algolia/getting-started.html) for more information. 63 | 64 | ```bash 65 | bundle install 66 | bundle exec jekyll algolia 67 | ``` 68 | 69 | [ap-stylebook-url]: https://www.apstylebook.com 70 | [jekyll-url]: https://jekyllrb.com 71 | [pr-url]: https://github.com/slimphp/Slim-Website/compare 72 | [slimframework-url]: https://slimframework.com -------------------------------------------------------------------------------- /docs/v3/cookbook/route-patterns.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Trailing / in route patterns 3 | --- 4 | 5 | Slim treats a URL pattern with a trailing slash as different to one without. That is, `/user` and `/user/` are different and so can have different callbacks attached. 6 | 7 | For GET requests a permanent redirect is fine, but for other request methods like POST or PUT the browser will send the second request with the GET method. To avoid this you simply need to remove the trailing slash and pass the manipulated url to the next middleware. 8 | 9 | If you want to redirect/rewrite all URLs that end in a `/` to the non-trailing `/` equivalent, then you can add this middleware: 10 | 11 | ```php 12 | use Psr\Http\Message\RequestInterface as Request; 13 | use Psr\Http\Message\ResponseInterface as Response; 14 | 15 | $app->add(function (Request $request, Response $response, callable $next) { 16 | $uri = $request->getUri(); 17 | $path = $uri->getPath(); 18 | if ($path != '/' && substr($path, -1) == '/') { 19 | // recursively remove slashes when its more than 1 slash 20 | while(substr($path, -1) == '/') { 21 | $path = substr($path, 0, -1); 22 | } 23 | 24 | // permanently redirect paths with a trailing slash 25 | // to their non-trailing counterpart 26 | $uri = $uri->withPath($path); 27 | 28 | if($request->getMethod() == 'GET') { 29 | return $response->withRedirect((string)$uri, 301); 30 | } 31 | else { 32 | return $next($request->withUri($uri), $response); 33 | } 34 | } 35 | 36 | return $next($request, $response); 37 | }); 38 | ``` 39 | 40 | Alternatively, consider [oscarotero/psr7-middlewares' TrailingSlash](//github.com/oscarotero/psr7-middlewares#trailingslash) middleware which also allows you to force a trailing slash to be appended to all URLs: 41 | 42 | ```php 43 | use Psr7Middlewares\Middleware\TrailingSlash; 44 | 45 | $app->add(new TrailingSlash(true)); // true adds the trailing slash (false removes it) 46 | ``` 47 | -------------------------------------------------------------------------------- /docs/v2/di/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | Slim has a built-in resource locator, providing an easy way to inject objects into a Slim app, or 5 | to override any of the Slim app's internal objects (e.g. Request, Response, Log). 6 | 7 | ## Injecting simple values 8 | 9 | If you want to use Slim as a simple key-value store, it is as simple as this: 10 | 11 | foo = 'bar'; 14 | 15 | Now, you can fetch this value anywhere with `$app->foo` and get its value `bar`. 16 | 17 | ## Using the resource locator 18 | 19 | You can also use Slim as a resource locator by injecting closures that define how 20 | your desired objects will be constructed. When the injected closure is requested, it will 21 | be invoked and the closure's return value will be returned. 22 | 23 | uuid = function () { 28 | return exec('uuidgen'); 29 | }; 30 | 31 | // Get a new UUID 32 | $uuid = $app->uuid; 33 | 34 | ### Singleton resources 35 | 36 | Sometimes, you may want your resource definitions to stay the same each time they are requested 37 | (i.e. they should be singletons within the scope of the Slim app). This is easy to do: 38 | 39 | container->singleton('log', function () { 44 | return new \My\Custom\Log(); 45 | }); 46 | 47 | // Get log resource 48 | $log = $app->log; 49 | 50 | Every time you request the log resource with `$app->log`, it will return the same instance. 51 | 52 | ### Closure resources 53 | 54 | What if you want to literally store a closure as the raw value and not have it invoked? You can do that 55 | like this: 56 | 57 | myClosure = $app->container->protect(function () {}); 62 | 63 | // Return raw closure without invoking it 64 | $myClosure = $app->myClosure; 65 | -------------------------------------------------------------------------------- /docs/v4/middleware/body-parsing.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Body Parsing Middleware 3 | --- 4 | 5 | It’s very common in web APIs to send data in JSON or XML format. 6 | Out of the box, PSR-7 implementations do not support these formats, you have to decode the Request object’s getBody() yourself. 7 | As this is a common requirement, Slim 4 provides `BodyParsingMiddleware` to handle this task. 8 | 9 | ## Usage 10 | 11 | It's recommended to put the body parsing middleware before the call to `addErrorMiddlware`, so that the stack looks like this: 12 | 13 | ```php 14 | addBodyParsingMiddleware(); 24 | 25 | $app->addRoutingMiddleware(); 26 | 27 | $app->addErrorMiddleware(true, true, true); 28 | 29 | // ... 30 | 31 | $app->run(); 32 | ``` 33 | 34 | ## Posted JSON, form or XML data 35 | 36 | No changes are required to the POST handler because the `BodyParsingMiddleware` detects that the `Content-Type` is set to a `JSON` media type and so places the decoded body into the Request’s parsed body property. 37 | 38 | For data posted to the website from a browser, you can use the $request’s `getParsedBody()` method. 39 | 40 | This will return an array of the posted data. 41 | 42 | ```php 43 | $app->post('/', function (Request $request, Response $response, $args): Response { 44 | $data = $request->getParsedBody(); 45 | 46 | $html = var_export($data, true); 47 | $response->getBody()->write($html); 48 | 49 | return $response; 50 | }); 51 | ``` 52 | 53 | ## Media type detection 54 | 55 | * The middleware reads the `Content-Type` from the request header to detect the media type. 56 | * Checks if this specific media type has a parser registered. 57 | * If not, look for a media type with a structured syntax suffix (RFC 6839), e.g. `application/`. 58 | 59 | ## Supported media types 60 | 61 | * application/json 62 | * application/x-www-form-urlencoded 63 | * application/xml 64 | * text/xml --------------------------------------------------------------------------------