Download the PHP package pollora/ajax without Composer

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

Pollora Ajax: WordPress AJAX handlers with a fluent API and secure defaults

Latest version Total downloads Tests

A dependency-free PHP API for WordPress admin-ajax.php handlers. One listen() call registers the wp_ajax_* and wp_ajax_nopriv_* hooks for you, and handlers are restricted to logged-in users unless you opt in, so a public endpoint is always a deliberate choice rather than a copy-pasted nopriv line.

Part of Pollora, the Laravel framework for WordPress. In a Pollora project it is already installed: use the #[Ajax] attribute or the Pollora\Support\Facades\Ajax facade instead.

Installation

Requires PHP 8.2+ and WordPress (the adapter calls add_action()).

Quick start

What you get

With the Pollora framework

Inside Pollora, declare handlers with the #[Ajax] attribute; they are discovered automatically:

Protect an action with a nonce

An AJAX request carries the visitor's cookies, so a page of another site can make a logged-in visitor's browser send it. A nonce, a token WordPress creates for a user and an action, is what tells the request your own page sent from one it did not.

With the Pollora framework, the #[Ajax] attribute says the same: #[Ajax('save_note', nonce: true)], nonce: 'notes_form' or nonce: false.

A refused request receives {"success": false, "data": {"code": "pollora_ajax_invalid_nonce", "message": "Invalid or expired security token."}} with a 403 status.

An action that does not choose still runs without a check in the 1.x versions, and WordPress is told (_doing_it_wrong(), visible with WP_DEBUG, skipped while an AJAX request is answered). The next major version verifies a nonce by default. To get that behaviour now, on every action that did not choose:

A nonce of a guest is tied to no user and a cached page can serve an old one: prefer a different protection for an action open to guests, and say withoutNonce() when you do.

Require a capability

A nonce proves where a request comes from, not that the user may do what it asks. Without a capability check, any logged-in user (a subscriber, for instance) who has a valid nonce can run the action. Say who may:

With the Pollora framework: #[Ajax('save_note', nonce: true, capability: 'edit_posts')].

The capability is checked with current_user_can(), after the nonce and before the callback. A user without it receives {"success": false, "data": {"code": "pollora_ajax_forbidden", "message": "You are not allowed to do this."}} with a 403 status. An action that does not call requireCapability() behaves as before.

A capability and guests do not go together: a guest is not logged in, so it has no capability. On the guest side of an action open to guests (forGuestUsers(), forAllUsers()), the request is refused with a 401 (pollora_ajax_unauthenticated) and WordPress is told (_doing_it_wrong(), visible with WP_DEBUG, skipped while an AJAX request is answered). Restrict the action to logged-in users, or drop the capability.

An action that requires a capability is still told to choose its nonce policy (requireNonce() or withoutNonce()).

Documentation

Testing

Contributing

Contributions are welcome: see the contributing guide. Report security issues privately, as described in the security policy.

License

Pollora Ajax is open-source software licensed under the RuBee group


All versions of ajax with dependencies

PHP Build Version
Package Version
Requires php Version ^8.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 pollora/ajax contains the following files

Loading the files please wait ...