lcloss / slim2
Forked from Slim Framework, a PHP micro framework (http://github.com/codeguy/Slim)
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- nikic/fast-route: ^1.3
- psr/container: ^1.0 || ^2.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- psr/log: ^1.1 || ^2.0 || ^3.0
Requires (Dev)
- ext-simplexml: *
- adriansuter/php-autoload-override: ^1.3
- guzzlehttp/psr7: ^2.4
- httpsoft/http-message: ^1.0
- httpsoft/http-server-request: ^1.0
- laminas/laminas-diactoros: ^2.17
- nyholm/psr7: ^1.5
- nyholm/psr7-server: ^1.0
- phpspec/prophecy: ^1.15
- phpspec/prophecy-phpunit: ^2.0
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
- slim/http: ^1.2
- slim/psr7: ^1.5
- squizlabs/php_codesniffer: ^3.7
Suggests
- ext-simplexml: Needed to support XML format in BodyParsingMiddleware
- ext-xml: Needed to support XML format in BodyParsingMiddleware
- php-di/php-di: PHP-DI is the recommended container library to be used with Slim
- slim/psr7: Slim PSR-7 implementation. See https://www.slimframework.com/docs/v4/start/installation.html for more information.
- 4.x-dev
- 4.11.0
- 4.10.0
- 4.9.0
- 4.8.1
- 4.8.0
- 4.7.1
- 4.7.0
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.0
- 4.2.0
- 4.1.0
- 4.0.0
- 4.0.0-beta
- 4.0.0-alpha
- 3.x-dev
- 3.12.4
- 3.12.3
- 3.12.2
- 3.12.1
- 3.12.0
- 3.11.0
- 3.10.0
- 3.9.2
- 3.9.1
- 3.9.0
- 3.8.1
- 3.8.0
- 3.7.0
- 3.6.0
- 3.5.0
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.0
- 3.0.0-RC3
- 3.0.0-RC2
- 3.0.0-RC1
- 3.0.0-beta2
- 3.0.0-beta1
- 2.x-dev
- 2.6.3.5
- 2.6.3.4
- 2.6.3.3
- 2.6.3.2
- 2.6.3.1
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.0
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.0
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
This package is auto-updated.
Last update: 2024-12-26 19:55:41 UTC
README
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. Slim is easy to use for both beginners and professionals. Slim favors cleanliness over terseness and common cases over edge cases. Its interface is simple, intuitive, and extensively documented — both online and in the code itself. Thank you for choosing the Slim Framework for your next project. I think you're going to love it.
Features
- Powerful router
- Standard and custom HTTP methods
- Route parameters with wildcards and conditions
- Route redirect, halt, and pass
- Route middleware
- Resource Locator and DI container
- Template rendering with custom views
- Flash messages
- Encrypt cookie data
- HTTP caching
- Logging with custom log writers
- Error handling and debugging
- Middleware and hook architecture
- Simple configuration
Getting Started
Install
You may install the Slim Framework with Composer (recommended) or manually.
System Requirements
You need PHP >= 5.3.0. If you use encrypted cookies, you'll also need the mcrypt
extension.
Hello World Tutorial
Instantiate a Slim application:
$app = new \Slim\Slim();
Define a HTTP GET route:
$app->get('/hello/:name', function ($name) { echo "Hello, $name"; });
Run the Slim application:
$app->run();
Setup your web server
Apache
Ensure the .htaccess
and index.php
files are in the same public-accessible directory. The .htaccess
file
should contain this code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Additionally, make sure your virtual host is configured with the AllowOverride option so that the .htaccess rewrite rules can be used:
AllowOverride All
Nginx
The nginx configuration file should contain this code (along with other settings you may need) in your location
block:
try_files $uri $uri/ /index.php?$args;
This assumes that Slim's index.php
is in the root folder of your project (www root).
HipHop Virtual Machine for PHP
Your HipHop Virtual Machine configuration file should contain this code (along with other settings you may need).
Be sure you change the ServerRoot
setting to point to your Slim app's document root directory.
Server {
SourceRoot = /path/to/public/directory
}
ServerVariables {
SCRIPT_NAME = /index.php
}
VirtualHost {
* {
Pattern = .*
RewriteRules {
* {
pattern = ^(.*)$
to = index.php/$1
qsa = true
}
}
}
}
lighttpd
Your lighttpd configuration file should contain this code (along with other settings you may need). This code requires lighttpd >= 1.4.24.
url.rewrite-if-not-file = ("(.*)" => "/index.php/$0")
This assumes that Slim's index.php
is in the root folder of your project (www root).
IIS
Ensure the Web.config
and index.php
files are in the same public-accessible directory. The Web.config
file should contain this code:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="slim" patternSyntax="Wildcard"> <match url="*" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
Google App Engine
Two steps are required to successfully run your Slim application on Google App Engine. First, ensure the app.yaml
file includes a default handler to index.php
:
application: your-app-name
version: 1
runtime: php
api_version: 1
handlers:
# ...
- url: /.*
script: public_html/index.php
Next, edit your index.php
file so Slim knows about the incoming URI:
$app = new Slim(); // Google App Engine doesn't set $_SERVER['PATH_INFO'] $app->environment['PATH_INFO'] = $_SERVER['REQUEST_URI']; // ... $app->run();
Documentation
http://docs.slimframework.com/
How to Contribute
NOTE: We are only accepting security fixes for Slim 2 (master branch). All development is concentrated on Slim 3 which is on the develop branch.
Pull Requests
- Fork the Slim Framework repository
- Create a new branch for each feature or improvement
- Send a pull request from each feature branch to the develop branch
It is very important to separate new features or improvements into separate feature branches, and to send a pull request for each branch. This allows me to review and pull in new features or improvements individually.
Style Guide
All pull requests must adhere to the PSR-2 standard.
Unit Testing
All pull requests must be accompanied by passing unit tests and complete code coverage. The Slim Framework uses
phpunit
for testing.
Community
Forum and Knowledgebase
Visit Slim's official forum and knowledge base at http://help.slimframework.com where you can find announcements, chat with fellow Slim users, ask questions, help others, or show off your cool Slim Framework apps.
Follow @slimphp on Twitter to receive news and updates about the framework.
Author
The Slim Framework is created and maintained by Josh Lockhart. Josh is a senior web developer at New Media Campaigns. Josh also created and maintains PHP: The Right Way, a popular movement in the PHP community to introduce new PHP programmers to best practices and good information.
License
The Slim Framework is released under the MIT public license.