Download the PHP package meebio/php-eval-console without Composer
On this page you can find all versions of the php package meebio/php-eval-console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-eval-console
PHP Eval Console
In-browser, standalone console that executes your PHP code and returns the produced output. This package is based on package darsain/laravel-console.
Table of contents
- Installation
- Configuration
- Evaluators
- Authorizers
- Queries callback
- Laravel support
Installation
Get package through composer:
Copy vendor/meebio/php-eval-console/assets
to assets
in project root directory.
Create index.php
in project root directory with following content:
Open index.php page in browser.
Configuration
Key | Type | Description | Default |
---|---|---|---|
assets_dir | string | Relative path to assets directory. | 'assets' |
views_path | string | Absolute path to views directory. Modify only if you want to use custom views. | '<...>/Views' |
console_view_path | string | Absolute path to main view. Modify only if you want to use custom views. | '<...>/Views/console.php' |
execute_url | string|null | URL to application execute route. If null set it is guessed. | null |
evaluator | EvaluatorInterface |
Instance of EvaluatorInterface implementation that will be used for running code. | EvalEvaluator |
authorizer | null|AuthorizerInterface |
Instance of AuthorizerInterface implementation that will be used for running code. This option also accepts null or array of authorizers. | IpAuthorizer |
queries_callback | null|closure | Callback that will return database queries to display after running code. | null |
post_execute_callback | null|closure | Post execute callback. Can be used to perform some actions after code evaluation, but before returning result. | null |
Evaluators
EvalEvaluator
Basic evaluator that uses eval
command. This is entirely not secure.
PhpSandboxEvaluator
More advanced php evaluator that make use of fieryprophet/php-sandbox
package. This sandbox class utilizes PHP-Parser to prevent sandboxed code from
running unsafe code. If configured properly this evaluator could probably allow application to be exposed to public
users. To use this evaluator require fieryprophet/php-sandbox
package in composer.
Authorizers
IpAuthorizer
This authorizer ensures that only access from provided ips is possible. Authorizer constructor takes to arguments first is array of allowed ips (null if this check should be disabled) and second is array of disallowed ips (null if this check should be disabled).
Queries callback
Closure that will provide array of queries after code evaluation. Returned data should be in following format:
Laravel support
You should install the package through Composer:
You must add service provider to app config:
You can publish package assets through artisan command:
or just copy directory vendor/meebio/php-eval-console/assets
to public/vendor/php-eval-console
.
Last thing that should be done is to make sure CSRF Protection is not blocking console post requests. To do that in Laravel 5.1 you should add console URI to be excluded in VerifyCsrfToken class. So it looks something like this:
For lower versions of Laravel, that can be done as well, but some manual method overriding is needed.
When everything is done you should see Console at /console
uri.
TODO
- Improve errors handling.