Download the PHP package safeaccess/inline without Composer

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

safeaccess-inline logo

Safe Access Inline — PHP

PHP library for safe nested data access with security validation on by default — JSON, YAML, XML, INI, ENV, NDJSON, arrays and objects. Includes a full PathQuery engine with filters, wildcards, slices, and projections. Zero production dependencies.

Packagist PHP 8.2+ PHPStan max Tested with Pest Infection MSI


The problem

Reading nested data from external sources requires more than null-safe access. You also need to defend against XXE in XML, anchor bombs in YAML, PHP magic method injection, stream wrapper abuse, superglobal access, and payload size attacks. Without a tool for this, that validation is boilerplate you write manually for every format and every endpoint.

Without this library (XML from an external API):

With this library:

Installation

Requirements: PHP 8.2+, extensions: json, simplexml, libxml

Optional: ext-yaml for improved YAML parsing performance (a built-in minimal parser is used by default).

Quick start

Security

All public entry points validate input by default. Every key passes through SecurityGuard and SecurityParser before being accessible.

What gets blocked

Category Examples Reason
PHP magic methods __construct, __destruct, __wakeup, __sleep, __toString, ... Prevent PHP magic behavior via data keys
Prototype pollution __proto__, constructor, prototype Prevent prototype pollution attacks
PHP superglobals GLOBALS, _GET, _POST, _COOKIE, _SERVER, _ENV, ... Prevent superglobal variable access
Stream wrapper URIs php://input, phar://..., data://..., file://... Prevent stream wrapper injection

Format-specific protections

Format Protection
XML Rejects <!DOCTYPE — prevents XXE (XML External Entity) attacks
YAML Blocks unsafe tags, anchors (&), aliases (*), and merge keys (<<)
All Forbidden key validation on every parsed key

Structural limits

Limit Default Description
maxPayloadBytes 10 MB Maximum raw string input size
maxKeys 10,000 Maximum total key count
maxDepth 512 Maximum structural nesting depth
maxResolveDepth 100 Maximum recursion for path resolution
maxCountRecursiveDepth 100 Maximum recursion when counting keys

Custom forbidden keys

Disabling validation for trusted input

Warning: Disabling strict mode skips all validation. Only use with application-controlled input.

For vulnerability reports, see SECURITY.md.

Dot notation syntax

Basic syntax

Syntax Example Description
key.key user.name Nested key access
key.0.key users.0.name Numeric key (array index)
key\.with\.dots config\.db\.host Escaped dots in key names
$ or $.path $.user.name Optional root prefix (stripped)

Advanced PathQuery

Syntax Example Description
[0] users[0] Bracket index access
* or [*] users.* Wildcard — expand all children
..key ..name Recursive descent — find key at any depth
..['a','b'] ..['name','age'] Multi-key recursive descent
[0,1,2] users[0,1,2] Multi-index selection
['a','b'] ['name','age'] Multi-key selection
[0:5] items[0:5] Slice — indices 0 through 4
[::2] items[::2] Slice with step
[::-1] items[::-1] Reverse slice
[?expr] users[?age>18] Filter predicate expression
.{fields} .{name, age} Projection — select fields
.{alias: src} .{fullName: name} Aliased projection

Filter expressions

Supported formats

JSON
YAML
XML
INI
ENV (dotenv)
NDJSON Each line is parsed as an independent JSON object and indexed from `0` by its position in the input. Blank lines and trailing newlines are skipped. Security validation is applied to each line individually.
Array / Object
Any (custom format via integration)
Dynamic (by TypeFormat enum)

Reading & writing

Configure

Builder pattern

Builder methods

Method Description
withSecurityGuard($guard) Custom forbidden-key rules and depth limits
withSecurityParser($parser) Custom payload size and structural limits
withPathCache($cache) Path segment cache for repeated lookups
withParserIntegration($integration) Custom format parser for fromAny()
withStrictMode(false) Disable security validation (trusted input only)

Error handling

All exceptions extend AccessorException:

Exception hierarchy

Exception Extends When
AccessorException RuntimeException Root — catch-all
SecurityException AccessorException Forbidden key, payload, structural limits
InvalidFormatException AccessorException Malformed JSON, XML, INI, NDJSON
YamlParseException InvalidFormatException Unsafe or malformed YAML
PathNotFoundException AccessorException getOrFail() on missing path
ReadonlyViolationException AccessorException Write on readonly accessor
UnsupportedTypeException AccessorException Unknown accessor class in make()
ParserException AccessorException Internal parser errors

Advanced usage

Strict mode

Warning: Disabling strict mode skips all validation. Only use with application-controlled input.

Path cache

Custom format integration

API reference

Inline facade

Static factory methods

Method Input Returns
fromArray($data) array<array-key, mixed> ArrayAccessor
fromObject($data) object ObjectAccessor
fromJson($data) JSON string JsonAccessor
fromXml($data) XML string or SimpleXMLElement XmlAccessor
fromYaml($data) YAML string YamlAccessor
fromIni($data) INI string IniAccessor
fromEnv($data) dotenv string EnvAccessor
fromNdjson($data) NDJSON string NdjsonAccessor
fromAny($data, $integration?) mixed AnyAccessor
from($typeFormat, $data) TypeFormat enum AccessorsInterface
make($class, $data) class-string AbstractAccessor

Accessor read methods

Method Returns
get($path, $default?) Value at path, or default
getOrFail($path) Value or throws PathNotFoundException
getAt($segments, $default?) Value at key segments
has($path) bool
hasAt($segments) bool
getMany($paths) array<string, mixed>
all() array<string, mixed>
count($path?) int
keys($path?) list<string>
getRaw() mixed

Accessor write methods (immutable)

Method Description
set($path, $value) Set at path
setAt($segments, $value) Set at key segments
remove($path) Remove at path
removeAt($segments) Remove at key segments
merge($path, $value) Deep-merge at path
mergeAll($value) Deep-merge at root

Modifier methods

Method Description
readonly($flag?) Block all writes
strict($flag?) Toggle security validation

TypeFormat enum

Array · Object · Json · Xml · Yaml · Ini · Env · Ndjson · Any

Contributing

See CONTRIBUTING.md for development setup, commit conventions, and pull request guidelines.

License

MIT © Felipe Sauer


All versions of inline with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
ext-simplexml Version *
ext-libxml 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 safeaccess/inline contains the following files

Loading the files please wait ...