Download the PHP package userfrosting/support without Composer
On this page you can find all versions of the php package userfrosting/support. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download userfrosting/support
More information about userfrosting/support
Files in userfrosting/support
Package support
Short Description Support classes for UserFrosting and UF modules
License MIT
Homepage https://github.com/userfrosting/support
Informations about the package support
Support module for UserFrosting 4
Branch | Build | Coverage | Style |
---|---|---|---|
master | |||
develop |
This module contains support classes for UserFrosting and related modules.
Exception
userfrosting/support
provides a number of custom exception types used by the main UserFrosting project:
- RuntimeException
- FileNotFoundException
- JsonException
- HttpException
- BadRequestException
- ForbiddenException
- NotFoundException
HttpException
A large portion of UserFrosting's exception types inherit from the HttpException
class.
The HttpException
class acts like a typical exception, but it maintains two additional parameters internally: a list of messages (UserMessage
) that the exception handler may display to the client, and a status code that should be returned with the response. As a simple example, consider the BadRequestException
:
It defines a default message, 'Bad data!'
, that a registered exception handler can display on an error page or push to the alert stream. It also sets a default HTTP status code to return with the error response.
The default message can be overridden when the exception is thrown in your code:
Repository
userfrosting/support
provides a generic Repository
class that extends Laravel's base Repository, and on which various other UserFrosting components depend. For example, UserFrosting's config
, translator
, and Fortress schema
all store their data in a UserFrosting Repository
or child class.
The Repository
class provides the following methods:
has(string $key)
Determine if the given configuration value exists.
get(string $key, mixed $default = null)
Get the specified configuration value.
set(array|string $key, mixed $value = null)
Set a given configuration value.
prepend(string $key, mixed $value)
Prepend a value onto an array configuration value.
push(string $key, mixed $value)
Push a value onto an array configuration value.
all()
Get all of the configuration items for the application.
mergeItems(string $key = null, mixed $items)
Merge a value or array of values into the repository using array_replace_recursive
at the chosen key. If the $key
is null, it will merge into the entire repository.
Loaders
Loader classes allow you to load repository data from multiple sources and merge them into a common data structure. The abstract class FileRepositoryLoader
manages an ordered list of file paths. When the load
method is called on a concrete implementation of FileRepositoryLoader
, it will use the implementation of parseFile
to read the contents of each file and merge them together, returning an array of the merged contents. The load
method uses the array_replace_recursive
function to perform this merge.
As an example, consider the YamlFileLoader
implementation that loads two schema files:
To load and merge these two schema files into a Respository:
Path Builders
The abstract PathBuilder
class uses an instance of the UniformResourceLocator
to build a customized list of paths that can be passed into a Loader
class.
For example, the StreamPathBuilder
class takes a UniformResourceLocator
and a stream path that has been registered with the locator, and returns a list of matching paths when you call the buildPaths
method:
You can define other PathBuilder
classes to customize the way this list of paths is constructed. Simply implement the buildPaths
method, returning an array of generated paths in the order in which they should be loaded by a Loader
class.
DotenvEditor
The DotenvEditor
class provides an implementation of JackieDo Laravel-Dotenv-Editor package for UserFrosting. This can be used to read and write the .env configuration file (or files with same structure and syntax).
For complete usage of DotenvEditor
class, see .
Style Guide
Testing
All versions of support with dependencies
jackiedo/dotenv-editor Version ~1.0.7
php Version >=7.1
userfrosting/uniformresourcelocator Version ~4.2.1 | ~4.3.0 | ~4.4.0 | ~4.5.0
symfony/yaml Version >=2.1