PHPackages                             statical/slim-static - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. statical/slim-static

ActiveLibrary

statical/slim-static
====================

Static proxy implementation for Slim framework

v1.0.0(11y ago)186105[2 issues](https://github.com/johnstevenson/slim-static/issues)[1 PRs](https://github.com/johnstevenson/slim-static/pulls)MITPHPPHP &gt;=5.3.0

Since Nov 13Pushed 5y ago2 watchersCompare

[ Source](https://github.com/johnstevenson/slim-static)[ Packagist](https://packagist.org/packages/statical/slim-static)[ Docs](http://github.com/johnstevenson/slim-static)[ RSS](/packages/statical-slim-static/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

\#SlimStatic

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ea7f36b1e88310af29b510af27df7f9c15a31dd5ca8a07ed7f399dea0cc24799/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f686e73746576656e736f6e2f736c696d2d7374617469632f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/johnstevenson/slim-static/?branch=master)[![Build Status](https://camo.githubusercontent.com/caae1cd86a09c13a00d05762fbb6cd8c1794239c02ea8fc3595b1ae922196c53/68747470733a2f2f7472617669732d63692e6f72672f6a6f686e73746576656e736f6e2f736c696d2d7374617469632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/johnstevenson/slim-static)

Slim PHP static proxy library.

Contents
--------

[](#contents)

- [About](#About)
- [Usage](#Usage)
- [API](#Api)
- [Customizing](#Custom)
- [License](#License)

About
-----

[](#about)

SlimStatic provides a simple static interface to various features in the [Slim](https://github.com/codeguy/slim)micro framework. Turn this:

```
$app->get('/hello-world', function()
{
	$app = Slim::getInstance();

	$app->view()->display('hello.html', array(
        'name' => $app->request()->get('name', 'world')
    ));
});

$app->run();
```

into this:

```
Route::get('/hello-world', function()
{
	View::display('hello.html', array(
        'name' => Input::get('name', 'world')
    ));
});

App::run();
```

This library is based on [Slim-Facades](https://github.com/itsgoingd/slim-facades) from Miroslav Rigler, but uses [Statical](https://github.com/johnstevenson/statical) to provide the static proxy interface.

Usage
-----

[](#usage)

Install via [composer](https://getcomposer.org)

```
composer require statical/slim-static

```

Create your Slim app and boot SlimStatic:

```
use Slim\Slim;
use Statical\SlimStatic\SlimStatic;

$app = new Slim();

SlimStatic::boot($app);
```

Now you can start using the static proxies listed below. In addition there is a proxy to [Statical](https://github.com/johnstevenson/statical) itself, aliased as `Statical` and available in any namespace, so you can easily use the library to add your own proxies (see [Customizing](#Custom)) or define namespaces.

If your app is namespaced you can avoid syntax like `\App::method` or *use* statements by employing the namespacing feature:

```
# Allow any registered proxy to be called anywhere in the `App\Name` namespace

Statical::addNamespace('*', 'App\\Name\\*');
```

API
---

[](#api)

The following static proxies are available:

Statical AliasProxy[App](#App)to Slim instance[Config](#Config)calling the Slim config method[Container](#Container)to Slim container instance[Input](#Input)to Slim\\Http\\Request instance[Log](#Log)to Slim\\Log instance[Request](#Request)to Slim\\Http\\Request instance[Response](#Response)to Slim\\Http\\Response instance[Route](#Route)calling Slim route-matching methods[View](#View)to Slim\\View instance

#### App

[](#app)

Proxy to the Slim instance. Note that you cannot use the built-in resource locator statically, because `App::foo = 'bar'` is not a method call. Use the [Container](#Container) proxy instead.

```
App::expires('+1 week');
App::halt();
```

#### Config

[](#config)

Sugar for Slim config, using the following methods:

- `get($key)` - returns value of `$app->config($key)`
- `set($key, $value = null)` - calls `$app->config($key, $value)`

```
$debug = Config::get('debug');
Config::set('log.enable', true);

# Note that you could also use:
$debug = App::config('debug');
App::config('log.enable', true);
```

#### Container

[](#container)

Proxy to the Slim container instance. Use this to access the built-in resource locator.

```
# $app->foo = 'bar'
Container::set('foo', 'bar');

# $bar = $app->foo
$bar = Container::get('foo');

Container::singleton('log', function () {...});
$rawClosure = Container::protect(function () {...});
```

#### Input

[](#input)

Proxy to the Slim\\Http\\Request instance with an additional method:

- `file($name)` - returns `$_FILES[$name]`, or null if the file was not sent in the request

```
$avatar = Input::file('avatar');
$username = Input::get('username', 'default');
$password = Input::post('password');
```

#### Log

[](#log)

Proxy to the Slim\\Log instance.

```
Log::info('My info');
Log::debug('Degug info');
```

#### Request

[](#request)

Proxy to the Slim\\Http\\Request instance.

```
$path = Request::getPath();
$xhr = Request::isAjax();
```

#### Response

[](#response)

Proxy to the Slim\\Http\\Response instance.

```
Response::redirect('/success');
Response::headers->set('Content-Type', 'application/json');
```

#### Route

[](#route)

Sugar for the following Slim instance route-mapping methods:

- `map`, `get`, `post`, `put`, `patch`, `delete`, `options`, `group`, `any`, `urlFor`

```
Route::get('/users/:id', function ($id) {...});
Route::post('/users',  function () {...});
Route::urlFor('admin');
```

Note that because these methods call the Slim instance you can also invoke them with `App::get`, `App::post` etc.

#### View

[](#view)

Proxy to the Slim\\View instance

```
View::display('hello.html');
$output = View::render('world.html');
```

Customizing
-----------

[](#customizing)

Since [Statical](https://github.com/johnstevenson/statical) is already loaded, you can use it to create your own static proxies. Let's take a `PaymentService` class as an example, that you want to alias as `Payment`.

The first step is to create a proxy class that extends the `Statical\BaseProxy` class. It is normally empty and you can name it whatever you wish:

```
class PaymentProxy extends \Statical\BaseProxy {}
```

You must then register this with Statical, using `addProxyInstance` if you use a class instance, or `addProxyService` if you want to use the Slim container. Using a class instance:

```
# create our PaymentService class
$instance = new \PaymentService();

$alias = 'Payment';             # The static alias to call
$proxy = 'PaymentProxy';        # The proxy class you just created

Statical::addProxyInstance($alias, $proxy, $instance);

# Now we can call PaymentService methods via the static alias Payment
Payment::process();
```

Using the Slim container:

```
# Register our service with Slim's DI container
Container::set('payment', function () {
    return new \PaymentService();
});

$alias = 'Payment';             # The static alias to call
$proxy = 'PaymentProxy';        # The proxy class you just created
$id = 'payment';                # The id of our service in the Slim container

Statical::addProxyService($alias, $proxy, Container::getInstance(), $id);

# Now we can call PaymentService methods via the static alias Payment
Payment::process();
```

Note that for namespaced code, the namespace must be included in the `$proxy` param.

License
-------

[](#license)

SlimStatic is licensed under the MIT License - see the `LICENSE` file for details

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4203d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/27d8b7d4cfabb5ee43654da874119af04150f7a3da33bd70f66cc311a0bea8cf?d=identicon)[johnstevenson](/maintainers/johnstevenson)

---

Top Contributors

[![johnstevenson](https://avatars.githubusercontent.com/u/881777?v=4)](https://github.com/johnstevenson "johnstevenson (7 commits)")

---

Tags

slimfacadestatic proxystatical

### Embed Badge

![Health badge](/badges/statical-slim-static/health.svg)

```
[![Health](https://phpackages.com/badges/statical-slim-static/health.svg)](https://phpackages.com/packages/statical-slim-static)
```

###  Alternatives

[slim/twig-view

Slim Framework 4 view helper built on top of the Twig 3 templating component

3708.0M210](/packages/slim-twig-view)[bryanjhv/slim-session

Session middleware and helper for Slim framework 4.

233961.5k16](/packages/bryanjhv-slim-session)[palanik/corsslim

Cross-origin resource sharing (CORS) middleware for PHP Slim.

94375.3k3](/packages/palanik-corsslim)[itsgoingd/slim-facades

"Static" interface for various Slim features

7651.4k5](/packages/itsgoingd-slim-facades)[docler-labs/codeception-slim-module

Codeception Module for Slim framework.

13178.0k1](/packages/docler-labs-codeception-slim-module)[mathmarques/smarty-view

Slim Framework 4 view helper built on top of the Smarty templating component

24134.7k1](/packages/mathmarques-smarty-view)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
