Total: 1

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Pimple - A simple PHP Dependency Injection Container
    function c return new Session c session storage Notice that the anonymous function has access to the current container instance allowing references to other services or parameters As objects are only created when you get them the order of the definitions does not matter Using the defined services is also very easy 1 2 3 4 5 6 get the session object session container session the above call is roughly equivalent to the following code storage new SessionStorage SESSION ID session new Session storage Defining Factory Services By default each time you get a service Pimple returns the same instance of it If you want a different instance to be returned for all calls wrap your anonymous function with the factory method 1 2 3 container session container factory function c return new Session c session storage Now each call to container session returns a new instance of the session Defining Parameters Defining a parameter allows to ease the configuration of your container from the outside and to store global values 1 2 3 define some parameters container cookie name SESSION ID container session storage class SessionStorage If you change the session storage service definition like below 1 2 3 container session storage function c return new c session storage class c cookie name You can now easily change the cookie name by overriding the session storage class parameter instead of redefining the service definition Protecting Parameters Because Pimple sees anonymous functions as service definitions you need to wrap anonymous functions with the protect method to store them as parameters 1 2 3 container random func container protect function return rand Modifying Services after Definition In some cases you may want to modify a service definition after it has been defined You can use the extend method to define additional

    Original URL path: (2016-02-13)
    Open archived version from archive