slim / extras
Extras package for the Slim Framework
Installs: 451 071
Dependents: 12
Suggesters: 0
Security: 0
Stars: 482
Watchers: 42
Forks: 128
Open Issues: 25
Requires
- php: >=5.3.0
- slim/slim: >=2.0.0
This package is not auto-updated.
Last update: 2024-11-09 14:45:15 UTC
README
This repository contains extra resources that complement the Slim Framework, a PHP micro framework that helps you quickly write simple yet powerful web applications.
For custom views we are now recommending using the Slim Views repo instead. We are simplifying the amount of views we officially support and will be splitting up the Slim Extras repo into smaller chunks.
For custom loggers we are now recommending using the Slim Logger repo instead.
Custom Views
This repository contains custom views for your Slim Framework applications. Custom views let you easily use popular third-party templating frameworks, like Twig or Smarty, with your Slim Framework application.
- Smarty
- Twig
- Mustache
- Haml
- Haanga
- Blitz
- Dwoo
- Sugar
- Savant
- Rain
- H2o
This example demonstrates how to use the custom Twig view in your Slim Framework application:
<?php
// Setup custom Twig view
$twigView = new \Slim\Extras\Views\Twig();
// Instantiate application
$app = new \Slim\Slim(array(
'view' => $twigView
));
This example assumes you are autoloading dependencies using Composer. If you are not
using Composer, you must manually require
the custom view class before instantiating it.
Read the Slim Framework documentation to learn how to write your own custom view.
Middleware
This repository also contains middleware for your Slim Framework application. This example demonstrates how to apply HTTP basic authentication to a Slim Framework application:
<?php
$app = new \Slim\Slim();
$app->add(new \Slim\Extras\Middleware\HttpBasicAuth('username', 'password'));
This example assumes you are autoloading dependencies using Composer. If you are not
using Composer, you must manually require
the custom middleware class before instantiating it.
Log Writers
This repository also contains custom log writers for your Slim Framwork application. This example
demonstrates how to use the custom DateTimeLogWriter
to write rolling log files from your Slim Framework application:
<?php
$app = new \Slim\Slim(array(
'log.writer' => new \Slim\Extras\Log\DateTimeFileWriter(array(
'path' => './logs',
'name_format' => 'Y-m-d',
'message_format' => '%label% - %date% - %message%'
))
));
This example assumes you are autoloading dependencies using Composer. If you are not
using Composer, you must manually require
the log writer class before instantiating it.
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.
The Slim Framework Extras repository is maintained by Andrew Smith.
License
The Slim Framework is released under the MIT public license.