Download the PHP package snootbeest/tantrum without Composer

On this page you can find all versions of the php package snootbeest/tantrum. 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 tantrum

Tantrum

Tantrum is a RESTful API framework based on Slim 3 framework.
It extends Slim 3 in a number of useful ways:

Configurable Services

Tantrum comes with a service layer based on configuration and dependency injection.
To create services, all that is needed is a class that implements the SnootBeest\Tantrum\Service\ServiceProvider interface, and a few lines of configuration.

Here we see a section of the configuration detailing the dependencies(services).
This particular service provides a LoggerInterface instance. Psr\Log\LoggerInterface is the key that will be used inside the dependency injection container.
Using fully qualified interface namespaces as container keys - whilst not required - provides several benefits:

providerClass

The providerClass is the ServiceProvider which will be invoked from the dependency injection container, and which will ultimately return the LoggerInterface instance. It contains all the logic needed for instanciation.

dependencyType

The dependencyType key is optional, and can have three possible values:

dependencies

The dependency injection container is not available to the ServiceProvider to avoid the global service locator anti-pattern. Therefore we define a list of sub dependencies here (fully namespaced interfaces, hopefully!). These are injected into the ServiceProvider constructor in the order in which they are defined (no reflection here). There they can be made available to the service itself.
This means that they must be defined elsewhere in the application dependencies to be available in the container.

configuration

In the example above, the ORM will obviously need a database connection, the details of which are not provided to it here.
In a different part of the config we define the configuration values for the dependencies, keyed once again by the interface.

Why not define the configuration values alongside the dependencies?

The dependencies are generally far less dynamic than the configuration of the application. For example, your application will always need it's LoggerInterface implementation, but the database will be different for every environment. In addition configuration values may be shared and modified between many different services, and it is best that these are defined elsewhere.

Route Inspection

One of the best things about Slim 3 is the ability to quickly add routes to the application. This is excellent for rapid development, but I have found that adding routes using closures is that in large applications they soon become unwieldy. In addition it is difficult to unit test closures.

Tantrum brings route inspection during the build process (I always create a build script which runs after composer install) This technique reflects the routes at build time and caches the results, ready for runtime. Having the routes pre-processed and stored in this way allows for constructor injection, making the controllers easy to test, but also gives us the opportunity to pass named query parameters directly into the route method.

The controllers are configured under the key controllers, and are simply a list of namespaces:

All that it asks is that your controllers extend a small class; SnootBeest\Tantrum\Controller, and that your controller classes include some simple annotations to help the router. Let's look at an example:

Here is the widget controller for our shop.

Constructor injection

Note that our __construct method has a few dependencies. You can see that it requires a Psr\Log\LoggerInterface instance as the first parameter. This is configured using the process above, and automatically provided from the dependency injection container.

The second parameter $requiredParameter is also required, but not type-hinted. The dispatcher will attempt to fetch this from the container too. If it is not found there, it will be fetched from config. If it is still not found, an exception will be thrown, resulting in a 500 response.

The third parameter $optionalParameter has a default value. If its name isn't found in the container or config, the default value will be returned instead.

We can also see some custom annotations in the route declaration.

@httpMethod

Multiple @httpMethod annotations can be provided if necessary.

@route

The @route annotation is the regex that the slim router needs to resolve the request to this method. Any named placeholders are passed in as method parameters. See https://www.slimframework.com/docs/objects/router.html#route-placeholders

Of course, you can still add routes in the methods described in the Slim 3 documentation if you need to take advantage of its more advanced features. I'll try to add more of these to the route detection as time goes on.


All versions of tantrum with dependencies

PHP Build Version
Package Version
Requires slim/slim Version ^3.8
hassankhan/config Version ^0.10.0
monolog/monolog Version ^1.23
phpdocumentor/reflection-docblock Version ^4.2
psr/simple-cache Version ^1.0
psr/log Version ^1.0
psr/http-message Version ^1.0
symfony/cache Version ^4.0
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 snootbeest/tantrum contains the following files

Loading the files please wait ....