Download the PHP package statical/slim-static without Composer
On this page you can find all versions of the php package statical/slim-static. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download statical/slim-static
More information about statical/slim-static
Files in statical/slim-static
Package slim-static
Short Description Static proxy implementation for Slim framework
License MIT
Homepage http://github.com/johnstevenson/slim-static
Informations about the package slim-static
SlimStatic
Slim PHP static proxy library.
Contents
- About
- Usage
- API
- Customizing
- License
About
SlimStatic provides a simple static interface to various features in the Slim micro framework. Turn this:
into this:
This library is based on Slim-Facades from Miroslav Rigler, but uses Statical to provide the static proxy interface.
Usage
Install via composer
Create your Slim app and boot SlimStatic:
Now you can start using the static proxies listed below. In addition there is a proxy to
Statical itself, aliased as Statical
and available in any namespace, so you
can easily use the library to add your own proxies (see Customizing) or define
namespaces.
If your app is namespaced you can avoid syntax like \App::method
or use statements
by employing the namespacing feature:
API
The following static proxies are available:
Statical Alias | Proxy |
---|---|
App | to Slim instance |
Config | calling the Slim config method |
Container | to Slim container instance |
Input | to Slim\Http\Request instance |
Log | to Slim\Log instance |
Request | to Slim\Http\Request instance |
Response | to Slim\Http\Response instance |
Route | calling Slim route-matching methods |
View | to Slim\View instance |
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 proxy instead.
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)
Container
Proxy to the Slim container instance. Use this to access the built-in resource locator.
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
Log
Proxy to the Slim\Log instance.
Request
Proxy to the Slim\Http\Request instance.
Response
Proxy to the Slim\Http\Response instance.
Route
Sugar for the following Slim instance route-mapping methods:
map
,get
,post
,put
,patch
,delete
,options
,group
,any
,urlFor
Note that because these methods call the Slim instance you can also invoke them with App::get
,
App::post
etc.
View
Proxy to the Slim\View instance
Customizing
Since 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:
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:
Using the Slim container:
Note that for namespaced code, the namespace must be included in the $proxy
param.
License
SlimStatic is licensed under the MIT License - see the LICENSE
file for details