Download the PHP package istianxin/laravel-sensitive without Composer

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

laravel-sensitive

敏感词检查及过滤扩展包

特点

系统要求

安装

通过 composer 安装

初始

Laravel

Laravel 使用包自动发现,所以不需要手动添加服务提供器

如果你没有使用自动发现,就必须手动添加服务提供器到 config/app.php 的 providers 数组中:

如果你想使用 facade,添加如下代码到 config/app.php 的 aliases 数组中:

添加配置

Laravel

在项目目录下,使用如下命令发布配置:

之后可以在 .env 中设置 SENSITIVE_CACHEtrue 来开启缓存功能

其他框架

可在实例化 Sydante\LaravelSensitive\Sensitive 时自行传入配置

更新缓存

在使用缓存时,如果修改了敏感词配置 wordsfile 或者修改了 file 配置的文件的内容时,需要通过如下命令更新缓存:

如果缓存了配置,需先更新配置缓存:php artisan config:cache

也可清理缓存,缓存被清理后,在下次被使用时会根据配置自动重建缓存

使用

示例代码

可用方法包括:

在其他框架中使用

不使用缓存

在不使用缓存时,可以直接在其他框架中直接使用 Sydante\LaravelSensitive\Sensitive

使用缓存

如果需要使用缓存功能,请自行编写实现了 Sydante\LaravelSensitive\SensitiveCacheInterface 接口的缓存类,在初始化 implements SensitiveCacheInterface 时传入类名到 cache_class 键中:

为什么要写这个包

在写这个包之前,我使用的是 yankewei/laravel-sensitive,在此感谢此包提供的敏感词处理思路。不过在实际使用中,压测发现此包 IO 占用太高,且函数调用频繁:

函数 调用次数 执行耗时 CPU时间 内存占用 内存巅峰
mb_substr 21099 13.9ms 28μs 660.0KB 161.4KB
str_replace 5858 4.2ms 10μs 213.9KB 136.0KB
mb_strlen 5771 3.4ms 2μs 1.1KB 112Bit
Yankewei\LaravelSensitive\Sensitive::getGeneretor 5771 0μs 56.4ms 0Bit 0Bit
feof 5770 0μs 9.4ms 0Bit 0Bit
fgets 5769 0μs 9.9ms 0Bit 0Bit

遂打算自己重写,将生成的敏感词库集合缓存起来,优化掉读敏感词文件和生成敏感词集合的部分,一次生成,即可重复使用。

Tips

可使用如下方式,来使干扰因子支持使用 SENSITIVE_DISTURBS 配置

如果缓存了配置,调整了 SENSITIVE_DISTURBS 后需要更新配置缓存:php artisan config:cache


All versions of laravel-sensitive with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
ext-mbstring Version *
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 istianxin/laravel-sensitive contains the following files

Loading the files please wait ....