Download the PHP package bgeneto/ci4-sanitize without Composer

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

ci4-sanitize

Latest Stable Version Total Downloads License

ci4-sanitize is a PHP library for CodeIgniter 4 that provides data sanitization functionality. It allows you to easily sanitize user input and other data using a set of predefined rules or custom rules. This helps prevent security vulnerabilities like cross-site scripting (XSS) and SQL injection.

Quick Start

  1. Install with Composer: composer require bgeneto/ci4-sanitize

  2. Publish the config file: php spark sanitize:publish

  3. Set up your model:

Installation

Composer + Packagist

Composer + GitHub repo:

Just setup a repository like this in your project's composer.json file:

Composer + Local repo:

Now edit your composer.json file and add a new path repository:

Publish the configuration file after installing:

Configuration

The package comes with a configuration file (app/Config/Sanitization.php) where you can define default sanitization rules for your models.

You can also add custom (new) rules to this config file:

Usage

Sanitizer Class

You can use the Sanitizer class directly to sanitize

You can also add rules dynamically:

You can also apply rules at the time of sanitization, which will override any previously defined rules:

Sanitizer Class Static Usage

The Sanitizer class provides several static methods for convenient sanitization:

Registering and Using Custom Rules:

Applying Built-in Rules:

Sanitizable Trait

The SanitizableTrait is designed for use with CodeIgniter 4 models. It automatically applies sanitization rules before inserting or updating data.

The trait will use the rules defined in the Sanitization config file for the UserModel. You can also add rules dynamically:

You can retrieve the currently applied sanitization rules using getSanitizationRules():

You can also sanitize arbitrary data directly using the trait:

Allowed Callbacks:

The SanitizableTrait allows you to specify which model events should trigger sanitization. You can set these using the setSanitizationCallbacks() method. The allowed callbacks are:

Built-in Rules

The following built-in rules are available:

Custom Rules

Custom rules can be used both globally (with Sanitizer::registerRule()) and within models that use the SanitizableTrait. The examples shown in the "Sanitizer Class Static Usage" section demonstrate how to define and use custom rules.

License

This package is open-sourced software licensed under the MIT license.


All versions of ci4-sanitize with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.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 bgeneto/ci4-sanitize contains the following files

Loading the files please wait ....