lapaz/plain-php

Support for plain PHP script file

0.1.1 2018-02-16 03:31 UTC

This package is auto-updated.

Last update: 2024-12-05 19:23:40 UTC


README

Build Status

Plain PHP script file runner that safer than extract() and require way.

Quick Start

To load these config-file.php script:

<?php
/* @var $this SomeObject */

return [
    // your config
    'some-element' => $parameter,
    'another-element' => $anotherParameter,
    'element-by-method-call' => $this->getConfigElement(),
];

Use ScriptRunner below instead of raw require statement.

$config = ScriptRunner::which()->requires('path/to/config-file.php')->with([
    'parameter' => '...',
    'anotherParameter' => '...',
])->binding($someObject)->run();

Features

  • Closed and safer evaluation than raw require or include
  • Binding any object as $this variable in target file
  • Immutable and branchable variable bound context