Download the PHP package snscripts/getset without Composer

On this page you can find all versions of the php package snscripts/getset. 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 getset

GetSet

Author Latest Version Software License Build Status

Introduction

GetSet is a PSR-2 compliant trait to be used for adding magic getters / setters to objects.

Requirements

Composer

GetSet requires the following:

And the following if you wish to run in dev mode and run tests.

Installation

Composer

Simplest installation is via composer.

composer require snscripts/getset 1.*

or adding to your projects composer.json file.

{
    "require": {
        "snscripts/getset": "1.*"
    }
}

Setup

To initiate GetSet simply use the trait within your class

class MyClass
{
    use \Snscripts\GetSet\GetSet;

    ...
}

Usage

Once setup, simply set or get any variables on the object you need.

$MyClass->foo_bar = 'barfoo';

echo $MyClass->foo_bar; // barfoo

This will set the variable into a $data array added to your object via the GetSet trait.

Variable Transformers

You can create custom get / set transformers to change a variables data as it gets added to or retrieved from the $data variable. These should be in the format setXAttr and getXAttr where X is a CamelCased version of the variable you are setting or getting from the object.

In the example above, basic getter / setter methods for foo_bar could look like:

public function setFooBarAttr($value)
{
    $this->data['foo_bar'] = strtoupper($value);
}

public function getFooBarAttr()
{
    return strtolower($this->data['foo_bar']);
}

Mass data assignment

If you need to assign a full array of data to your object and wish for the variables to be passed through any custom setters there is the setAllData method.

$MyClass->setAllData([
    'foo_bar' => 'barfoo'
]);

Data Export

If you need to export all the data set within your object you can use 1 of 2 methods.

toArray

$MyClass->toArray();

This will simply return all data set onto the object as an array.

toJson

$MyClass->toJson();

This will return all the data set onto the object as a Json object. This first uses the toArray method to retrieve an array before returning the data through json_encode.

Changelog

You can view the changelog HERE

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.


All versions of getset with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.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 snscripts/getset contains the following files

Loading the files please wait ....