Download the PHP package kamranahmedse/laravel-censor without Composer
On this page you can find all versions of the php package kamranahmedse/laravel-censor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kamranahmedse/laravel-censor
More information about kamranahmedse/laravel-censor
Files in kamranahmedse/laravel-censor
Package laravel-censor
Short Description A middleware to censor certain words from your pages
License MIT
Informations about the package laravel-censor
Laravel Censor
Let's you easily redact or replace the occurences of
words
,sentences
or%wildcards%
A laravel middleware that will automatically censor the words that you will specify. All you have to do is specify the things, that you want to redact or replace, in a configuration file and these words will automatically be redacted/replaced from the views on whose route you will specify the middleware.
Installation
Perform the following operations in order to use this middleware
- Run
composer require kamranahmedse/laravel-censor
in your terminal -
Add Service Provider Open
config/app.php
and addKamranAhmed\LaravelCensor\LaravelCensorServiceProvider::class
to the end ofproviders
array: -
Register the Middleware After that open the file
app/Http/Kernel.php
and add the followingto the end of
$routeMiddleware
array - Publish Configuration Open terminal and run
How to use
- After following the above steps, there will be a
censor.php
file inside theconfig
directory. The file has two arrays, namelyreplace
andredact
. -
You have to specify the words that you want to replace in the
replace
array with words or wildcards set to the keys of array and replacements as values i.e. -
For any words that you want to
redact
or completely remove, you have to specify them in theredact
arrayThe words specified in
redact
array will turn into asterisks. For exampleidiot
will be turned into 5 asterisks (*****). -
Now for any route from which you want these words to be redacted or replaced, place the middleware
censor
over it and it will automatically redact/replace those words from all of the page. For example, below is how you can specify it over the route e.g.Or specify it over the route group so that it may handle all the routes in that group e.g.
How to Contribute
- Feel free to add some new functionality, improve some existing functionality etc and open up a pull request explaining what you did.
- Report any issues in the issues section
- Also you can reach me directly at [email protected] with any feedback