Download the PHP package x-wp/ajax-router without Composer
On this page you can find all versions of the php package x-wp/ajax-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download x-wp/ajax-router
More information about x-wp/ajax-router
Files in x-wp/ajax-router
Package ajax-router
Short Description Simplifies the use of WordPress AJAX by providing NestJS inspired Controller design.
License GPL-2.0-only
Informations about the package ajax-router
WordPress AJAX Router ![Packagist Version](https://img.shields.io/packagist/v/xwp/ajax-server) ![Packagist PHP Version](https://img.shields.io/packagist/dependency-v/xwp/ajax-server/php) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
PSR-7 / PSR-15 compatible AJAX router for WordPress.
Inspired by NestJS and Express - this library provides a simple way to handle AJAX requests in WordPress.
QuickStart
Install the library
Define a controller
Register a controller
This will expose the following endpoints:
GET /wp-ajax/my-endpoint/get-post/{id}
POST /wp-ajax/my-endpoint/modify-post/{id}
Ajax base URL is /wp-ajax
by default, and can be changed in permalink settings.
Getting Endpoint URLs
In PHP
In JavaScript
Library adds a global object xwp
attached to window
object. Both in the admin and on the frontend.
You can disable this by using xwp_ajax_vars
filter, or calling the xwp_disable_ajax_js_vars
FAQ
1. Did you just reinvent the wheel?
Yes, we did. We basically took the wheels from NestJS and Express and put it on a WordPress car.
2. Why?
Read this.
3. Can I use this in my project?
Yes, you can. But remember, this is a work in progress and we are still figuring out the best way to do things. API is subject to change.
4. Can I contribute?
Sure 💪💪💪.
If you have an idea, a suggestion, or a bug report - feel free to open an issue.
5. How does it work?
Read this.
All versions of ajax-router with dependencies
automattic/jetpack-constants Version ^2.0
oblak/wp-polyfills Version ^1.0
sunrise/http-message Version ^3
sunrise/http-router Version ^2.16
x-wp/hook-invoker Version ^1.0@alpha