Download the PHP package underpin/route-loader without Composer

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

Underpin Route Loader

Loader That assists with adding custom routes to a WordPress website.

Installation

Using Composer

composer require underpin/route-loader

Manually

This plugin uses a built-in autoloader, so as long as it is required before Underpin, it should work as-expected.

require_once(__DIR__ . '/route-loader/bootstrap.php');

Setup

  1. Install Underpin. See Underpin Docs
  2. Register new routes as-needed.

Example

A very basic example could look something like this.

Alternatively, you can extend Route and reference the extended class directly. This would allow you to use Underpin's Template loader trait, as well as other more-advanced class-based utilities:

Middleware

Since there are many ways a route can be used, this loader simply registers the route to use, ensures any custom query params are whitelisted, and ensures that they are sorted to minimize collisions with routes. In-order to do something with your route, you need to register additional actions. To help facilitate common actions, this loader comes with middleware that can extend the behavior of routes.

Template Middleware

The Use_Template middleware allows you to render a custom template when this route is used.

Prevent Query Middleware

By default, WordPress makes a database call on every page load to load a post object in the query. Sometimes, however, this is not necessary on custom routes. However, Even if you don't specify a post, WordPress will load a default post instead. This causes an additional query and can cause other unwanted behaviors, as well.

To circumvent this, use the Prevent_Main_Query middleware, like so:

This middleware will stop the primary query from running, while leaving the global WP_Query otherwise intact.

Working With Routes

Testing for Current Route

Usually you'll need to do some kind-of dynamic logic to determine certain behaviors that only run when the current page matches your route. This loader helps facilitate that with is_current_route(), which can be used like so:

If you happen to have the Route object directly, you can access it like so:


All versions of route-loader with dependencies

PHP Build Version
Package Version
Requires underpin/underpin Version ^2.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 underpin/route-loader contains the following files

Loading the files please wait ....