定制 adlawson/veval 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adlawson/veval

Composer 安装命令:

composer require adlawson/veval

包简介

Virtual eval

README 文档

README

Virtual Eval

Master branch build status Published version PHP ~5.4 MIT Licensed

Veval is an implementation of eval that uses a virtual file system to store code for evaluation and then require it back out. It should work on PHP installations that don't support or have disabled native eval.

It can be installed in whichever way you prefer, but I recommend Composer.

{
    "require": {
        "adlawson/veval": "*"
    }
}

Documentation

The Veval API is exposed as a collection of Veval\ namespaced functions, though you may prefer to use Veval:: to take advantage of autoloading and namespace aliasing (PHP < 5.6).

<?php

// Evaluate some code
Veval\execute(<<<'EOF'
class Foo {
    public $name;
    public function __construct($name) {$this->name = $name;}
}
EOF
);

// Use your newly evaulated code
$foo = new Foo('bar');
$foo->name; // bar

Debugging

Storing all of the "files" in memory is all fine if your evaluated code is workng as you expect, but sometimes it's useful to read the generated code to debug any problems. There are a few different debugging functions available to suit your needs.

<?php

// Debug all evaluated strings
Veval\debug(function ($name, $content) {
    // Debug some things here
});

// Iterate over all evaulated strings
foreach (Veval\iterator() as $name => $content) {
    // Debug some things here
}

// Dump all to path
Veval\dump(sys_get_temp_dir(), 'veval-%s.php');

Warning

Eval Warning

Using **Veval**, just like eval, is considered dangerous to use if you're evaluating user input. Always be careful not to do this as it can open up quite a large hole in the security of your system.

Contributing

Contributions are accepted via Pull Request, but passing unit tests must be included before it will be considered for merge.

$ curl -O https://raw.githubusercontent.com/adlawson/vagrantfiles/master/php/Vagrantfile
$ vagrant up
$ vagrant ssh
...

$ cd /srv
$ composer install
$ vendor/bin/phpunit

License

The content of this library is released under the MIT License by Andrew Lawson.
You can find a copy of this license in LICENSE or at http://opensource.org/licenses/mit.

统计信息

  • 总下载量: 149
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-07