vanchelo / phalcon-console
Phalcon Ajax 控制台
v1.0.2
2015-10-17 11:37 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phalcon/devtools: ~2.0
This package is not auto-updated.
Last update: 2024-09-14 12:37:49 UTC
README
由Phalcon https://github.com/darsain/laravel-console 修改 - Laravel 4 控制台
一个轻量级的AJAX控制台,可以在浏览器中执行PHP代码,可以保存最后的代码执行结果,通过IP地址限制访问
示例,启动编辑器,点击 执行 [Ctrl + Enter]
$user = Users::findFirst(1); echo $user->name;
结果
vanchelo
安装
使用composer
安装最新稳定版本
composer require vanchelo/phalcon-console
复制粘贴
- 将文件夹内容复制到任意目录
- 注册自动加载命名空间
Vanchelo\Console
// $loader = new Loader(); $loader->registerNamespaces([ 'Vanchelo\Console' => __DIR__ . '/../library/console/src/', // The path may be different ]);
- 将公共文件夹中的文件夹内容复制到可从公共WEB访问的目录
- 添加服务
/** * Register Console Service */ new Vanchelo\Console\ConsoleService($di);
- 在
src/config/config.php
中将允许的IP地址添加到列表中
/* ... */ 'whitelist' => [ '127.0.0.1', '::1' ], /* ... */
完成!控制台必须在http://site.com/phalcon-console
上可用
在控制台中可以访问所有服务和服务的
你的设置
要指定控制台设置,你必须
- 在方便的位置创建一个配置文件,例如此内容
<?php // app/config/console-config.php return new \Phalcon\Config([ // If you want to specify the class test access rights to the console 'check_access_class' => 'MyConsoleAccessCheck', // Check the permissions on the IP 'check_ip' => false, // disable scanning by IP address ]);
- 在容器服务设置控制台中注册服务以初始化服务控制台
$di['console.config'] = function () { // Path to correct its $config = require '/path/to/console-config.php'; return $config; }; new \Vanchelo\Console\ConsoleService($di);
有关初始化控制台和运行代码的更详细信息,必须在你的应用程序中的index.php
文件中添加到其余代码的标记行
define('PHALCONSTART', microtime(true));
它应该看起来像这样
<?php // public/index.php define('PHALCONSTART', microtime(true));