Download the PHP package dev-lucid/container without Composer

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

Container

A set of container classes that implement the forthcoming Psr-11 container interface (by extension, the current container interop interface). Some of these classes are very simple (the ServerContainer simply uses $_SERVER to store/retrieve data with no other changes from the base container class), but some are significantly more complicated (InjectorFactoryContainer does magic!). Here's a diagram of the 7 classes and a really brief description of how they relate/differ:

diagram of classes

Reasons for developing/using these classes:

I originally wrote these classes to provide a common API for accesing session variables and request variables that could be configured to point to mock data for unit testing. Eventually it turned into a more general purpose collection of classes that could form the basis for a framework using either a service locator pattern or dependency injection pattern; or a mix of the two.

Basic Stuff

Setting/getting data out of a container

There are 2 functions for setting data in your container:

There are 8 functions for getting data out of a container:

Here's a couple simple examples:

DateTime formats

When trying to convert a value to a DateTime object, by default Container will call \DateTime::createFromFormat and try 3 different formats in order: \DateTime::ISO8601, \DateTime::W3C, 'U'. If any of those attempts does not fail, the result is returned. You can set which formats are tried by calling ->setDateTimeFormats(...$newFormats). Note that this replaces which formats are tested, it is NOT additive.

Booleans, how RequestContainer differs

By default, calling ->bool will return true if and only if the value in the index is === true. So, '1' will return false, 'true' will return false, etc. Only a real boolean true will return true. This is by design. The RequestContainer class changes this behavior by adding a number of additional possible true and false matches. This is to account for the fact that many times when you're trying to get a boolean value specifically from a request, that request has been generated by a form submission, and the boolean in question was probably rendered as a checkbox. Checkboxes don't send their checked state as a boolean true/false. Instead, their value is simply present or not present in $_REQUEST. By using RequestContainer, you can likely get the right value out of your container when submitted a form with a checkbox.

By default, the following values in a RequestContainer will result in calls to ->bool returning true:

By default, the following values in a RequestContainer will result in calls to ->bool returning false:

These values can be replaced using two methods:

Note that these functions entirely replace the possible values, it is not additive.

Using __call()

Both Container and PrefixDecorator allow you to use __call to access indexes, but only for getting, not setting. For example:

CookieContainer settings

Locking data

You can lock indexes to prevent accidental overwriting by using the ->lock($id) and ->unlock($id) methods. For example:

Note: basically nothing prevents an index from being unlocked, so if you're really worried about malicious activity, locking the index is not going to stop some other code from changing values. This is really just there to prevent you from accidentally overwriting something.

Exception Classes

A number of catchable exception classes are used:

Advanced Stuff

Things I might add in the future:


All versions of container with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
container-interop/container-interop Version ^1.1
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 dev-lucid/container contains the following files

Loading the files please wait ....