Download the PHP package kod/bootstrap-slim without Composer

On this page you can find all versions of the php package kod/bootstrap-slim. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bootstrap-slim

Bootstrap SLIM

This package provides a library for bootstrapping Slim framework 4 application. (Release 1 is for Slim 3)

Purpose

Installation

Add this package to require section of the composer.json

Implementation in 3 steps

Bootstrap - step 1

On index.php for handling public requests.

Of course, Bootstrap class does not provide any route or middleware except native Slim RoutingMiddleware and ErrorMiddleware. You need to extend it and declare your routes in Bootstrap::addAppRoutes() and middleware stack in Bootstrap::addAppMiddlewares() methods. It can be done easily by declaring class names like in example below.

Declare application routes and middleware stack

None of those classes exists yet. So, let's start with the most important. Let's create our route.

Routing - step 2

You have 2 options for creating routes. If you are a fun of OOP you can create a class containing your routes by extending RouteDefintions abstract class and declare your routes in __invoke($app) method of this class. As said above, you can but you are not obliged to. The MUST is to implement the __invoke($app) method in your class which receives Slim\App instance as a parameter. The instance of the class is executed like a function.

And here comes the 2nd option. You can declare your routes as Closure which gets Slim\App instance as a parameter. The 2nd approach is quite useful for unit tests if you need to create a route on the fly. But what am I saying? I'm getting obsolete. With php we can create anonymous classes! ¡Ay, caramba!

Anyway, just keep in mind that in both cases the Slim\App instance is passed as a parameter. That means you can organize your routes in groups and attach middleware to some route or group.

Route as a class:

Application routes' declaration as a Closure

Middleware - step 3

You can create a middleware in 2 ways: as a class or a closure. To create it as a class simply extend invokable Middleware abstract class, implement your business logic in it and trigger its execution in Middleware::__invoke( ServerRequestInterface $request,RequestHandlerInterface $handler) method.

Slim 4 middleware implements PSR-15 Middleware Interface which means that you do not have to use Middleware abstract class but write your own implementing the PSR-15 Middleware Interface. That'll do the job as well.

Either way, the application container will be pushed into the constructor of the middleware class by Slim\MiddlewareDispatcher.In Middleware derived classes the container will be stocked in $this->ci property.

To create a middleware as a closure simply respect the function signature.

Middleware as invokable class

Application middleware declaration

Route/Group middleware

Slim allows to attach a middleware to a route or a group of routes. This can be done in routes' definition like in example below.

Container

Slim 4 has a breaking change. It does not have container anymore. But no worry! This package provides an implementation of ContainerInterface built on top of Pimple\Container with same methods as in Slim 3. If your application relies on some other container implementation simply provide the instance of your container to Bootstrap. Another way to customize the container is to override Bootstrap::init method in your Bootstrap class and declare it in there.

Unit Testing

The keyword in unit testing is UNIT. Once your application is well organized and weakly coupled unit testing is like playing LEGO with your code. You can assemble routes and middleware, declare them on the fly as you wish.

Slim dependency

Slim framework 4 now makes part of project dependencies due to quite sophisticated request/response forgery introduced with the latest version. To get rid of that dependency and rely on the slim version installed on your project you need to override Bootstrap::init method and use AppFactory and ServerRequestCreatorFactory coming with your project.


All versions of bootstrap-slim with dependencies

PHP Build Version
Package Version
Requires psr/container Version ^1.0
psr/http-message Version ^1.0
psr/http-server-handler Version ^1.0
pimple/pimple Version ^3.2
slim/psr7 Version ^0.5.0
slim/slim Version ^4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kod/bootstrap-slim contains the following files

Loading the files please wait ....