Download the PHP package stillat/primitives without Composer

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

This library provides a simple way to convert a string of simple values to their PHP runtime equivalents.

This library will parse the following types of values:

Unknown types will return null as their value.

Installation

This library can be installed with composer:

Example Usage

To use the library, create a new instance of the Parser class and call the parseString method:

would produce the following runtime result:

This library can also parse basic method details using the parseMethod method:

would produce the following runtime result:

Invalid input will produce a null value.

Parsing Nested Methods

A more advanced alternative of parseMethod is the parseMethods method:

Detected method calls will be returned as instances of Stillat\Primitives\MethodCall. Each instance of this class will contain the original method's name, as well as the parsed (and evaluated) runtime arguments. parseMethods will not run any methods for you.

Executing Runtime Methods

Primitives provides a utility MethodRunner class that can be used to execute the results of the parseMethods on any target class:

After the above code has executed, $result would contain the value Hello, Dave.

Important notes when using MethodRunner:

Calling Native PHP Functions

The internal method runner does not support calling native PHP functions. However, we can create a class instance that can (and utilize whatever logic is appropriate for the current project to determine what is a "safe" function to call):

After the above code has executed, $methodResult would contain the value Hello, THIS IS LOWERCASE. This approach works because we are making use of PHP's __call magic method to perform method overloading. When we attempt to call a method on our class instance that does not exist, the __call method will receive the method name and arguments. If the list of safe functions contains the incoming method name, we will invoke it and return the results with the original arguments. If our safe list does not contain the function, we default to attempting to call it on our target class instance.

Context Variables

You may also supply an array of contextual data that can be used when evaluating the input string. Context variables utilize the $ syntax. The variable name in the input string will be replaced with their actual values once evaluated:

Once the previous example has executed, $result would contain a value similar to:

Nested variable paths can be utilized by using PHP's property fetcher syntax (array accessor syntax is not supported):

Like before, the $result variable would contain a value similar to the following:

License

MIT License. See LICENSE.MD


All versions of primitives with dependencies

PHP Build Version
Package Version
Requires nikic/php-parser Version ^5
illuminate/support Version *
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 stillat/primitives contains the following files

Loading the files please wait ....