Skip to content
Conceal data in an array or collection
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Up minimum Laravel requirement to 5.7 Jan 27, 2020
config Added config to conceal certain keys by default Jan 27, 2020
tests Added facade Jan 29, 2020
.gitignore Initial commit Jan 25, 2020 Added facade Jan 29, 2020
composer.json Added facade Jan 29, 2020
phpunit.xml.dist Initial commit Jan 25, 2020

Laravel Conceal

Author Build Packagist Version Software License

This package allows you to conceal sensitive data in arrays and collections. This is particularly useful when writing possibly sensitive data to log files.

Once installed you can do things like this:

$data = [
    'username' => 'wouter',
    'api_key' => 'secret'

$hide = ['api_key'];

$output = conceal($data, $hide);

// Outputs: ['username' => 'wouter', 'api_key' => '********']


  • PHP >= 7.1
  • Laravel 5.7+ | 6


Install the package via composer:

composer require kielabokkie/laravel-conceal

Package configuration

This package has minimal configuration. All you can do at the moment is set the keys that are concealed by default. If you want to add your own defaults you can do that by publishing the config file by running the following command:

php artisan vendor:publish --provider="Kielabokkie\LaravelConceal\ConcealServiceProvider"

These are the contents of the file that will be published at config/conceal.php:

return [
     * Array of keys that will be concealed automatically.
    'defaults' => [


Use the default configuration to conceal the password:

$data = [
    'username' => 'wouter',
    'password' => 'secret'

$output = conceal($data);

// Outputs: ['username' => 'wouter', 'password' => '********']

Set keys on the fly:

$data = [
    'api_key' => 'secret'

$hide = ['api_key'];

$output = conceal($data, $hide);

// Outputs: ['api_key' => '********']


The examples above use the conceal() helper function. If Facades are more your thing you can use that instead:

use Kielabokkie\LaravelConceal\Facades\Concealer;

$data = [
    'password' => 'secret'

$output = Concealer::conceal($data);

// Outputs: ['password' => '********']
You can’t perform that action at this time.