Download the PHP package aplia/support without Composer
On this page you can find all versions of the php package aplia/support. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aplia/support
More information about aplia/support
Files in aplia/support
Package support
Short Description Extra support classes and functions for making it easier to work with PHP
License MIT
Homepage https://github.com/Aplia/PhpSupport
Informations about the package support
PHP helper classes and functions
This package contains extra support classes and functions for making it easier to work with PHP. It implements some features which are missing from PHP but which are commonly required, for instance array and path manipulation.
All classes are placed under the namespace Aplia\Support
, for instance:
Installation
Install with Composer:
Arr
Various functionality for working with arrays. These are mostly taken from the Laravel framework and placed in this repository to avoid extra dependencies.
Arr::get
A typical use case is to support keyword arguments to a function
by passing an array as a parameter. Arr::get
can then be used
to easily fetch a parameter if it is set or use a default value.
Path
Path manipulation such as joining multiple files/dir names into one path.
LoggerAdapter
Adapts the PSR logger interface to eZ debug, add this as a handler to
any PSR log. If the class eZDebug
exists it will pass log messages
along.
Val
Enforces a variable to a simple value, closures are called to get the real value.
VirtualProperties
Available since: 1.1
A trait which makes it easier to create classes with virtual properties.
Virtual properties are properties that doesn't exist on the object but are
bound to a function that gets called when the property name is accessed on
the object. This is all done using the PHP magic methods __get()
, __isset()
,
__set()
and __unset()
.
If the class extends a base class and that class also implements __isset()
etc.
VirtualProperties will make sure they are called as part of the checks.
If __baseProperties()
exists it will use this to add in extra properties
when __properties()
is called.
Property lookup is strict by default and will throw PropertyError
for
missing properties in __get()
, to disable strictness reimplement the
method __requireProperties()
and make it return false
.
Example of a class using all functionality, it will have the following properties:
- name - regular
- id - virtual and read-only
- version - virtual
- code - virtual and cached
TemplateAttributes
Available since: 1.1
A trait which gives the class support for eZ publish template attributes.
By using this trait the classes will allow instances to be used in eZ publish templates. The attributes will map to the existing properties or virtual properties on the class.
Works best when combined with VirtualPropertes
.
License
The helper library is open-sourced software licensed under the MIT license.