Download the PHP package cancio-labs/php-bag without Composer

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

PHP Bag

PHP

cancio-labs/php-bag is a small, array-backed data bag for PHP. It provides typed accessors, dot-notation lookup for nested arrays, collection-style operations, and JSON and date helpers behind a simple fluent API.

Requirements

Installation

Install the package with Composer:

Quick start

Working with values

Create a bag from an array, replace its contents with set(), or add individual values with add(). merge() appends values from arrays or other bags. Mutating methods return the bag instance, allowing fluent calls.

Use getAll(), getKeys(), getValues(), or toArray() to read the bag contents. The bag also implements Countable and IteratorAggregate.

Getters and defaults

Every getter accepts a key and, where applicable, a default value returned when the key is missing or its value is null.

Method Result
get() Value without conversion
getString() String value
getInt() Integer value
getFloat() Float value
getBool() Boolean value
getArray() Array value
getBag() Nested value as a new Bag
getAlpha() Value containing only alphabetic characters
getAlphaNum() Value containing only alphanumeric characters
getDigits() Value containing only digits
getDateTime() DateTimeInterface from an instance or formatted string
getJson() Decoded JSON value
getEnum() Case from a backed enum

getDateTime() uses Y-m-d H:i:s by default; supply a format as its second argument when needed. getJson() throws JsonException for invalid JSON, and getEnum() throws EnumNotFoundException unless the supplied class identifies a backed enum.

Dot notation

Getters, has(), isSet(), and remove() support dot notation for nested arrays. An exact key always takes precedence over a dotted path.

Call toDotNotation() to flatten nested arrays in place:

When a flattened path conflicts with a literal dotted leaf key, the literal key takes precedence regardless of its insertion order.

Collection operations

filter() and map() return a new bag. every() and some() return a boolean. Each callback receives the key followed by the value.

Testing

Run the test suite with:

Generate an HTML coverage report with:

License

This project is licensed under the GNU General Public License v3.0 or later.


All versions of php-bag with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
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 cancio-labs/php-bag contains the following files

Loading the files please wait ...