GithubHelp home page GithubHelp logo

slim's Introduction

Slim Framework

Build Status

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
  • Secure cookies with AES-256 encryption
  • 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.

Read how to install Slim

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]

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
}

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>

Documentation

http://docs.slimframework.com/

How to Contribute

Pull Requests

  1. Fork the Slim Framework repository
  2. Create a new branch for each feature or improvement
  3. 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.

Learn about PHPUnit

Community

Forum and Knowledgebase

Visit Slim's official forum and knowledge base at http://help.slimframework.com where you can find announcements, chat with fellow Slim users, ask questions, help others, or show off your cool Slim Framework apps.

Twitter

Follow @slimphp 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.

http://www.slimframework.com/license

slim's People

Contributors

adamnbowen avatar adriencarbonne avatar akzhan avatar bebna avatar benpjohnson avatar bigbluehat avatar bobdia avatar briannesbitt avatar dannykopping avatar fgalassi avatar gmanricks avatar hashchange avatar hexa2k9 avatar j4mie avatar jeremykendall avatar jkaflik avatar jwpage avatar kampfcaspar avatar mac2000 avatar maikg avatar matthewcallis avatar neverender avatar nortron avatar pborreli avatar shello avatar silentworks avatar solarissmoke avatar williamwa avatar yuya-takeyama avatar zomble avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.