Download the PHP package edulazaro/laratox without Composer

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

Laratox

Content moderation for Laravel, powered by ToxicFilter.

Every check returns one of three decisions (allow, review, block), the categories that fired (spam, scams, harassment, personal data… fifteen in all) and the reason in words.

Installation

Requires PHP 8.2+ and Laravel 12 or 13.

Create a key in your ToxicFilter account (the free plan is enough) and add it to .env:

A tf_test_ key does the same work and is never charged. Check it with:

Checking content

Say what it is, then check():

Options chain before check():

Also ->actor(), ->withoutAi(), ->rules([...]), ->redact() and ->option($key, $value) for anything else.

If your ToxicFilter organization moderates several sites, give each app its project once in .env (TOXICFILTER_PROJECT=forum): every check and every ToxicFilter::batch() is filed there, with its own activity, review queue and webhooks. ->project() overrides it for one call.

Every kind of content:

The verdict is the PHP SDK's: allowed(), needsReview(), blocked(), reason() (the first one), reasons() (all of them), scores(), flagged(), id(), project()… The rest of the API is there too: ToxicFilter::batch(), records(), resolve(), feedback(), usage(), ping(), and ToxicFilter::client() gives you the SDK client itself.

When the API cannot answer

check() throws the SDK's exceptions. Catch the ones you want to handle:

Exception When
AuthenticationError The key is wrong
QuotaExhausted Not enough credits for this call
InvalidRequest A field was rejected: $e->fields()
RateLimited Too many calls, after the retries
ServerError The service is down or unreachable, after the retries

All of them extend ToxicFilter\Exception\ApiError. The validation rule below catches them for you.

In a form

The rule chains the same options as ToxicFilter::text(). A block fails the field; a review passes, and ->orReview() fails it too. Put the rule last, after bail, since it is a network call.

The message carries ToxicFilter's reason: "The body could not be accepted: contains a phone number." Reasons are written in English, so by default (rule.show_reason = auto) they are only shown when your app's locale is English; other languages get the message without one.

To act on the decision afterwards, keep the rule:

With a wildcard ('tags.*' => [$rule]), ask for each field: $rule->verdict('tags.0').

If the API cannot answer, laratox.rule.on_error decides: allow (default) lets the field through and logs a warning, refuse fails it.

Testing

The fake replaces only the network: the SDK's client and verdicts are the real ones. Like the API, it refuses more than ten locales with an InvalidRequest.

Configuration

Key Env Default
key TOXICFILTER_KEY
project TOXICFILTER_PROJECT your organization's default project
url TOXICFILTER_URL https://toxicfilter.com
timeout TOXICFILTER_TIMEOUT 10
connect_timeout TOXICFILTER_CONNECT_TIMEOUT 5
retries TOXICFILTER_RETRIES 2
rule.on_error TOXICFILTER_ON_ERROR allow
rule.show_reason auto (true, false, or only when the locale is English)

Calls go through Laravel's HTTP client, so Http::fake() and your logging see them. A 429 or 5xx is retried with the same idempotency key, so it is judged and billed once; a 402 is never retried.

Sponsors

Laratox is supported by the following sponsors. Thank you for keeping it growing:

Kenodo     AndorraDev

Author

Created by Edu Lazaro

License

Laratox is open-sourced software licensed under the MIT license.


All versions of laratox with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^12.61.1|^13.12
edulazaro/toxicfilter-sdk Version ^1.6
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 edulazaro/laratox contains the following files

Loading the files please wait ...