2017 © Pedro Peláez
 

library strong-parameters

Rails like Strong parameters for php

image

koine/strong-parameters

Rails like Strong parameters for php

  • Monday, December 5, 2016
  • by mjacobus
  • Repository
  • 1 Watchers
  • 6 Stars
  • 383 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 21 % Grown

The README.md

Koine Strong Parameters

Rails-like strong parameters for php, (*1)

Work in progress, (*2)

Code information:, (*3)

Build Status Coverage Status Code Climate Scrutinizer Code Quality, (*4)

Package information:, (*5)

Latest Stable Version Total Downloads Latest Unstable Version License Dependency Status, (*6)

Usage

use Koine\Parameters;

$params = new Parameters(array(
    'user' => array(
        'name'  => 'Foo',
        'email' => 'Foo@bar.com',
        'admin' => true
     )
));

// throws exception
$userParams = $params->requireParam('user')->permit(array(
    'name',
    'email',
));

// filters value
Parameters::$throwsException = false;

$userParams = $params->requireParam('user')->permit(array(
    'name',
    'email',
))->toArray(); // array('name' => 'Foo', 'email' => 'Foo@bar.com')


// nested params

$params = new Params(array(
    'book' => array(
        'title'   => 'Some Title',
        'edition' => '3',
        'authors' => array(
            array(
                'name'     => 'Jon',
                'birthday' => '1960-01-02',
            ),
            array(
                'name'     => 'Daniel',
                'birthday' => '1960-01-02',
            ),
        )
    ),
    'foo' => 'bar',
    'bar' => 'foo'
));

$params->permit(array(
    'book' => array(
        'authors' => array('name'),
        'title'
    ),
    'foo'
))->toArray();

/**
    array(
        'book' => array(
            'title'   => 'Some Title',
            'authors' => array(
                array('name' => 'Jon'),
                array('name' => 'Daniel'),
            )
        ),
        'foo' => 'bar'
  )
*/


// array params

$params = new Params(array(
    'tags' => array('php', 'ruby')
));

$params->permit(array('tags' => array()))->toArray();
// array( 'tags' => array('php', 'ruby'))

// array params with invalid data

$params = new Params(array(
    'tags' => 'invalid'
));

$params->permit(array('tags' => array()))->toArray(); // array()


// do something with the values

Installing

Via Composer

Append the lib to your requirements key in your composer.json., (*7)

{
    // composer.json
    // [..]
    require: {
        // append this line to your requirements
        "koine/strong-parameters": "~0.9.3"
    }
}

Alternative install

Issues/Features proposals

Here is the issue tracker., (*8)

Contributing

Please refer to the contribuiting guide., (*9)

License

MIT, (*10)

Authors

The Versions

05/12 2016

dev-master

9999999-dev

Rails like Strong parameters for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

26/09 2014

0.9.3

0.9.3.0

Rails like Strong parameters for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

26/09 2014

0.9.2

0.9.2.0

Rails like Strong parameters for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

24/09 2014

0.9.1

0.9.1.0

Rails like Strong parameters for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

23/09 2014

0.9.0

0.9.0.0

Rails like Strong parameters for php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus