Download the PHP package ergy/slim-annotations-router without Composer

On this page you can find all versions of the php package ergy/slim-annotations-router. 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 slim-annotations-router

Latest Stable Version Total Downloads Latest Unstable Version License

Slim Annotations Router

Controller and annotations based router for Slim Framework V3

Installation

Via Composer :

Initialization

To initialize the annotations router, simply add this lines to your index.php file that loads your Slim application :

If your application contains controllers in multiple folders, you can add them by passing an array in the second parameter to the constructor instead of a string, eg :

Controller files

The annotations router detects all files with names ending in "Controller.php" and all public methods with names ending in "Action". It then parses their annotations to generate routes recognized by Slim framework.

The following annotations are supported :

Name Level Type Required Description
@RoutePrefix Class string no The route prefix, used for all routes in the current class
@Route Method Object yes The route definition

The @Route object accepts the following syntaxes :

Let's see an example :

By opening the url http://your_site_url/home/hello/foobar, you should see "Hello foobar !".

Get Slim dependency container

Once your controller loaded, you might need to interact with the current HTTP request and response, to get theses objects, your controller simply has to extends the Ergy\Slim\Annotations\Controller class.

Extending this class allows you to retrieve a reference to the Slim dependency container, so to retrieve the current request, you simply have to ask for $this->request.

Let's see an example with the previous class :

Since we have a reference to the Slim dependency container, we can retrieve any object it contains, for example if you want to retrieve the applications settings, simply ask for $this->settings.

Routing events

The annotations router exposes the methods beforeExecuteRoute and afterExecuteRoute.

These methods take as a parameter a Ergy\Slim\Annotations\RouteInfo instance that gives you information about the running route.

Implementing these methods in your controller (or one of its parent classes) allow you to implement hook points before/after the actions are executed.

Example with the previous class :

By opening the url http://your_site_url/home/hello/foobar, you should see "before Hello foobar ! after".

Operation cancellation

Previous hooks allow you to cancel operations if needed :

For example :

By opening the url http://your_site_url/home/hello/foobar, you should see "before Hello foobar !".


All versions of slim-annotations-router with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
slim/slim Version ^3.0@RC
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 ergy/slim-annotations-router contains the following files

Loading the files please wait ....