rindula / luminance
Luminance plugin for CakePHP
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: ^5.6|^7.0
- cakephp/cakephp: ^3.4
Requires (Dev)
- phpunit/phpunit: ^5.7|^6.0
This package is auto-updated.
Last update: 2025-04-29 01:02:39 UTC
README
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require rindula/luminance
Setup
To activate the Plugin in CakePHP, you have to add the following to the end of config/bootstrap.php
:
Plugin::load('Luminance');
In a View
To use this Helper in a view, you have two options:
- Add the Helper to one Controller only
add the following code to your controller:
public $helpers = ['Luminance'];
- Add it globally to your AppView
Add the following to the initialize method of src/View/AppView.php
:
$this->loadHelper('Luminance.Luminance');
In a Controller
Add this to the initialize function of the Controller you need the Component in, below parent::initialize()
:
$this->loadComponent('Luminance.Luminance')
Usage
Once the respective setup is done you can use it like this:
View and Controller
$color = $this->Luminance->getContrastColor($hexColor);
$color
then contains the hex color of the contrast color, which is either black (#000000) or white (#FFFFFF).