Download the PHP package kilahm/attribute-router without Composer

On this page you can find all versions of the php package kilahm/attribute-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 attribute-router

attribute-router

Build Status HHVM Status

A router for Hacklang that uses user defined attributes to define routing for single page applications.

Installation

Update your composer.json file to include the following line in your required block.

Use

Define attributes

To associate a method with an HTTP path, you may associate an attribute with the method.

The attribute route must have at least one parameter, but may have two. If two parameters are present, the first must be an http verb (get, post, put, or delete) and the second is a regular expression to test the path with. If the first parameter is not in the set listed above, then the path will be routed to this method for any verb.

If there is only one parameter present, the singular parameter is treated as the regular expression and the verb defaults to any.

Note that the route compiler will surround your pattern with a beginning of string anchor and an end of string anchor. So if your pattern is /path/a, the path /path/ab will not be routed to that method.

All routed methods must be public, static, and accept exactly two parameters. The first is defined by you, but all routed methods must have the same type signature. The second is a vector of strings which is the set of matches returned from preg_match on the regular expression you defined in the attribute. The first parameter is is expected to be some sort of IOC container to allow the method to begin instantiating services needed.

Compile

After defining all of the routes you like through attributes, you must run the compile script

You may specify multiple base paths to search and multiple paths to ignore. All searched paths will be searched recursively.

Call vendor/bin/scanroutes --help for a list of all options.

Routes.php and AutoRoutes.php

After the route compile script is run, two files should be in your project directory (or install target directory if you used --install-to). The AutoRoutes.php file is a collection of proxy methods for your route handlers.

The Routes.php file exists so you may add routes without annotating them with attributes. Follow the pattern given in the file to add routes by hand.

If scanroutes is run again, it will not overwrite the Routes.php file. This means that if you already created such a file before running the compiler, the router class will likely not work.

Instantiation

Your application bootstrap file should instantiate your IOC/DI container, then pass it to an instance of AutoRoutes. You must then pass the instance of AutoRoutes to Router. This must be done because the Router class is unaware of the class of the container. Only the generated Routes and AutoRoutes classes know what the class of the container is.

Alternatively you could create a factory that does the instantiation and injection for you (which is the reason you have an IOC/DI container in the first place).

Matching

To actually have the routing magic happen, simply call the match method on your Router object.

To see the full list of supported HTTP verbs, see enums to take full advantage of this feature.

Examples

The above route will be called for any http verb and the $matches vector will be populated with the results from preg_match on the pattern.

The above route will be called only for HTTP DELETE calls. Note that the $matches vector contains a single entry which is the fully matched route.


All versions of attribute-router with dependencies

PHP Build Version
Package Version
Requires hhvm Version >=3.5
hackpack/hack-class-scanner Version 1.*
kilahm/hack-clio Version 1.1.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 kilahm/attribute-router contains the following files

Loading the files please wait ....