๐Ÿ“ฆ Rindula / cake-luminance

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching
๐Ÿ“ฅ Clone https://github.com/Rindula/cake-luminance.git
HTTPS git clone https://github.com/Rindula/cake-luminance.git
SSH git clone git@github.com:Rindula/cake-luminance.git
CLI gh repo clone Rindula/cake-luminance
Sven Nolting Sven Nolting Add PHP Version requirement b523261 3 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ src
๐Ÿ“ tests
๐Ÿ“ webroot
๐Ÿ“„ .gitignore
๐Ÿ“„ CHANGELOG.md
๐Ÿ“„ composer.json
๐Ÿ“„ phpunit.xml.dist
๐Ÿ“„ README.md
๐Ÿ“„ README.md

Luminance plugin for CakePHP

Release

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).