Download the PHP package pinkcrab/perique-route without Composer

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

Perique - Route

Library for registering WP Rest Routes in a more simple way.

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require GitHub contributors GitHub issues

WordPress 5.9 Test Suite [PHP7.4-8.1] WordPress 6.0 Test Suite [PHP7.4-8.1] WordPress 6.1 Test Suite [PHP7.4-8.2] WordPress 6.2 Test Suite [PHP7.4-8.2] WordPress 6.3 Test Suite [PHP7.4-8.2] WordPress 6.4 Test Suite [PHP7.4-8.2]

codecov Scrutinizer Code Quality Maintainability


Why?

Registering WP Rest Routes can either be extremely simple or a frustrating wit the argument array format. The Perique Route library allows for a simpler way to register single routes and groupes.


Setup

To install, you can use composer

You will need to include the Registration_Middleware to the App at boot. We have provided a static method that will handle the dependency injection.

One you have the Route Middleware added to the registration process, all classes which extend Route_Controller will now be processed and all routes defined will be registered.

To create a route controller, just extend Route_Controller and return an array of all routes and groups. The controllers are constructed with the DI Container, so all dependencies can be passed.

Once you have your Route_Controller setup, its just a case of passing the class to the registration array and it will be loaded along with Perique.

Routes

Each route must be defined as part of a Route Model, these can either be created by hand or using the supplied Route_Factory (which is how the Route_Controller operates.)

Route Model

A route model has 4 properties which must be defined, $method, $route, $callback & $namespace. Route and Method are passed via the constructor, but namespace must be set manually.

As per WP Api standards, all arguments in the route must be defined, this is all handled via the Arguments object and is explained in more detail below.

All properties are defined as protected and should be handled via the supplied methods

It is also possible to define an authentication callback too

Route Docs

Route_Group

Like single Route Models, the Route_Group allows for a similar process of creating related routes that share a common endpoint route and also some functionality. Also like Routes, its better to use the supplied Route_Factory, but the details here will express how to create a Route_Group manually (the core methods are used the same regardless).

This would then create a group where all routes assigned are created with the above namespace and route.

Read Group Docs

Setters

Route_Factory

As most of the time you will be creating endpoints with a fixed namespace, there is a factory that can be used to populate this for every route it creates, while giving a clean, fluent API that can be used to create routes inline as part of arrays and return values.

Both of the above endpoints will be created with the my_endpoints/v2 namespace.

Method Helpers

There are a collection of helper methods on the Route_Factory which make it really easy to add methods to the existing namespace.

It is even possible to create a group around the same route.

Route Controller

The easiest way to define routes, is to extend the Route_Controller abstract class. This can be created with a predefined protected ?string $namespace; property and a method for defining the routes/group abstract protected function define_routes( Route_Factory $factory): array

See the example above

Manual Route Creation

If you do not wish to use the Route Controller above, you will need create an instance of the Route_Manager class and add your route or groups to the manager and the execute the manager before rest_init hook is called.

When execute() is called, it will create the rest_init hooks, so there is no need to do add_action(...)

Previous Versions

Change Log


All versions of perique-route with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4.0
pinkcrab/perique-framework-core Version 2.0.*
pinkcrab/collection Version ^0.1.0
pinkcrab/wp-rest-schema Version *
pinkcrab/function-constructors Version ^0.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 pinkcrab/perique-route contains the following files

Loading the files please wait ....