Download the PHP package alpipego/awp-router without Composer

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

Custom Routing for WordPress

Inspired by Themosis Routing which in turns uses Laravel's Routing this WP Router abstraction adds support for adding custom routes and callbacks on WordPress' routes while using WordPress functions (add_rewrite_rule, add_rewrite_tag) and without the need of adding third-party routers.

Developed in collaboration with @tatundkraft.

Installation

Install this package via composer:

Initialise the dispatcher:

The dispatcher takes a CustomRouterInterface, a TemplateRouterInterface, and a AjaxRouterInterface as optional arguments, if none are provided, the default Routers are initialised.

Custom Routes

The previous example adds a custom route my-custom-route that only responds to GET (and HEAD) request, and passes back a WP_Query object to your callback.

Methods

At the moment the methods GET, POST, and HEAD are implemented; custom routes can be added via the following methods:

and match which takes possible methods as a first parameter:

Variables

Variables can be either matched and thus be used as query_vars or be non-matching and only act as a way of validating the route.

Variables are added in the following form {VARNAME:REGEX} and you can leave out either VARNAME or the REGEX.

In the following example form_id and input_name are passed back as query_vars in the $query object. The last regex simply matches any three characters, e.g. abc but not abcd (and does not add a query var):

Notes:

Rewrite Tags

Already registered query vars (either built-in public vars or registered through plugins et al.) can be used in the route, and are registered with leading and trailing %, i.e. {%QUERYVAR%:REGEX}:

This will match the built-in page_id query var and add a custom field_id query variable to WP_Query.

Notes:

Redirects

The RouterInterface has a method to add redirects:

This route will redirect https://YOURSITE.com/twitter/alpipego to https://twitter.com/alpipego

Of course, redirects can also have regular expressions and rewrite tags in the route.

Notes:

The callback will receive the current WP_Query object as the first parameter, and the following return types can be handled:

Template Routing

Conditionals

The condition method takes a callable that returns a boolean value as its first argument and a callback to be executed right before rendering the template if the condition is true as its second argument. Both callbacks receive the current WP_Query to act on, the callable also receives the full path to the template file. See the section on callbacks on how they are handled.

Post Type Templates

Register post type templates without the constraints the WordPress implementation has. The template method takes a template file path as the first argument—relative to the current (child) theme, the template name (for the wp-admin sidebar select box) as the second, the post types for which this template should be available as the third and a callback as the final argument. See the section on callbacks on how they are handled. In addition to the current WP_Query object, the callback function receives the full path to the template as the second argument:

Ajax Routing

AJAX requests can be either GET or POST requests (or both), and apply to logged-in users only or all users. You can define custom routes for AJAX requests in the following format:

Notes:


All versions of awp-router with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
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 alpipego/awp-router contains the following files

Loading the files please wait ....