Download the PHP package sukohi/broom without Composer

On this page you can find all versions of the php package sukohi/broom. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package broom

Broom

A PHP package mainly developed for Laravel to manage option values using Trait.
(This packages is maintained under L54)

Demo

Installation

Execute composer command.

composer require sukohi/broom:3.*

Preparation

Simple Way

In your model, set BroomTrait and add a method named "options" which return values you want.

<?php

namespace App;

use Sukohi\Broom\BroomTrait;

class Color {

    use BroomTrait;

    public static function options() {

        return [
            '1' => 'Red',
            '2' => 'Blue',
            '3' => 'Green'
        ];

    }

Or you can simply prepare by setting $option property like so if your model extends Illuminate\Database\Eloquent\Model.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Sukohi\Broom\BroomTrait;

class Color extends Model {

    use BroomTrait;

    protected $option = ['id' => 'name']; // or 'name';

Now you also can call the next methods.

Usage

Options

$colors = \App\Color::options();
print_r($colors);

/* Output

    Array
    (
        [1] => Red
        [2] => Blue
        [3] => Green
    )

*/

Note: You will get Collection when you set $option.

Value

echo \App\Color::optionValue(2);   // Blue

or You can set default value.

echo \App\Color::optionValue(5, 'Default');   // Default

Key

echo \App\Color::optionKey('Green');      // 3

Values

$values = \App\Color::optionValues();
print_r($values);

/* Output

    Array
    (
        [0] => Red
        [1] => Blue
        [2] => Green
    )

*/

You also can filter the values by setting ids.

$values = \App\Color::optionValues([2, 3]);
print_r($values);

/* Output

    Array
    (
        [0] => Blue
        [1] => Green
    )

*/

Keys

$keys = \App\Color::optionKeys();
print_r($keys);

/* Output

    Array
    (
        [0] => 1
        [1] => 2
        [2] => 3
    )

*/

Random

echo \App\Color::optionRandom();     // Blue

$options = \App\Color::optionRandom(2);  // If you set a numeric argument, you can get array values.
print_r($options);

/* Output

    Array
    (
        [0] => Blue
        [1] => Green
    )

*/

Key Random

echo \App\Color::optionKeyRandom();  // 2

$options = \App\Color::optionKeyRandom(2);
print_r($options);

/* Output

Array
(
    [0] => 1
    [1] => 3
)

*/

Has Key

$key = 3;

if(\App\Color::optionHasKey($key)) {

    echo 'Has key!';

}

Has Value

$value = 'Red';

if(\App\Color::optionHasValue($value)) {

    echo 'Has value!';

}

With Default Title

$options = \App\Color::optionsWithTitle('Pick one');

/* Output

Array
(
    [] => Pick one
    [1] => Red
    [2] => Blue
    [3] => Green
)

*/

$options = \App\Color::optionsWithTitle('Pick one', '-99');

/* Output

Array
(
    [-99] => Pick one
    [1] => Red
    [2] => Blue
    [3] => Green
)

*/

optionIs

$key = '1';

if(\App\Item::optionIs('Item - 1', $key)) {

    echo 'True!';

}

optionsList

$list = \App\Item::optionsList();   // Default: $id_key => 'id', $value_key => 'text'

// or 

$id_key = 'id';
$value_key = 'text';
$list = \App\Item::optionsList($id_key, $value_key);

/*

Array
(
    [0] => Array
        (
            [id] => 1
            [text] => Red
        )

    [1] => Array
        (
            [id] => 2
            [text] => Blue
        )

    [2] => Array
        (
            [id] => 3
            [text] => Green
        )
)

*/

Cache

$option_cache allows you to use cache for quick access.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Sukohi\Broom\BroomTrait;

class Color extends Model {

    use BroomTrait;

    protected $option_cache = true;

then use forgetCache() for deleting cache;

Customized Method Name

You also can use customized method name like "redOptions".;

use Sukohi\Broom\BroomTrait;

class Color {

    use BroomTrait;

    public static function redOptions() {

        return [
            '1' => 'cherry',
            '2' => 'rose',
            '3' => 'crimson'
        ];

    }

Now you can call redOptionValue(), redOptionValues(), redOptionKey(), redOptionKeys(), redOptionRandom(), redOptionKeyRandom(), redOptionHasKey(), redOptionHasValue() and redOptionsWithTitle().

License

This package is licensed under the MIT License.

Copyright 2015 Sukohi Kuhoh


All versions of broom with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ~5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sukohi/broom contains the following files

Loading the files please wait ....