lapaz / plain-php
Support for plain PHP script file
0.1.1
2018-02-16 03:31 UTC
Requires
- php: ^5.6||^7.0
Requires (Dev)
- phpunit/phpunit: ^5.7.20||^6.0
This package is auto-updated.
Last update: 2024-12-05 19:23:40 UTC
README
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
orinclude
- Binding any object as
$this
variable in target file - Immutable and branchable variable bound context