2017 © Pedro Peláez
 

cakephp-plugin cakephp-ip-behavior

IpBehavior plugin for CakePHP

image

thefredfox/cakephp-ip-behavior

IpBehavior plugin for CakePHP

  • Monday, March 14, 2016
  • by TheFRedFox
  • Repository
  • 1 Watchers
  • 1 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 11 % Grown

The README.md

IpBehavior plugin for CakePHP

Description

An Ip Behavior for the Database Framework of CakePHP, which fills a specified field of an entity with the current client ip taken from the current request., (*1)

This plugin should work lovely with the IpType plugin., (*2)

Installation

You can install this plugin into your CakePHP application using composer., (*3)

The recommended way to install composer packages is:, (*4)

``` php composer require thefredfox/cakephp-ip-behavior, (*5)


After that you have to load the plugin in your application's bootstrap file and map the type for the database as follows: ``` php Plugin::load('IpBehavior', ['bootstrap' => true]);

In the Table class itself you have to add this behavior:, (*6)

``` php // in your Entity Table class (eg. UsersTable), (*7)

public function initialize(array $config) { //... $this->addBehavior('IpBehavior.Ip'); //... }, (*8)


The default is, that the behavior will use the field named 'ip', but you can change the configurations like this: ``` php // in your Entity Table class (eg. UsersTable) public function initialize(array $config) { //... $this->addBehavior('IpBehavior.Ip', ['fields' => ['other_ip_field']); //... }

and if you want that the ip should always be stored:, (*9)

``` php // in your Entity Table class (eg. UsersTable), (*10)

public function initialize(array $config) { //... $this->addBehavior('IpBehavior.Ip', ['fields' => ['ip' => 'always']); // respectively $this->addBehavior('IpBehavior.Ip', ['fields' => ['other_ip_field' => 'always']); //... }, (*11)


In that way you can store the creators and the modifiers ip: ``` php // in your Entity Table class (eg. UsersTable) public function initialize(array $config) { //... $this->addBehavior('IpBehavior.Ip', ['fields' => ['ip', 'other_ip_field' => 'always']); //... }

The 'new' configuration is default and you don't need to explicitly set it., (*12)

The Versions

14/03 2016

dev-master

9999999-dev http://github.com/thefredfox/cakephp-ip-behavior

IpBehavior plugin for CakePHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar TheFRedFox

database php cakephp behavior ip