Phalcon Console
Adapted by Phalcon https://github.com/darsain/laravel-console - Laravel 4 Console, (*1)
AJAX console to execute PHP code in the browser with light, the ability to save the last code execution, limited access by IP address, (*2)
Example, commissioning editor, click Execute [Ctrl + Enter], (*3)
$user = Users::findFirst(1);
echo $user->name;
Result, (*4)
vanchelo
Installation
Install the latest stable version using composer:, (*5)
composer require vanchelo/phalcon-console
Copy and paste:
- Copy the contents of a folder to any directory
- Register your autoloader namespace
Vanchelo\Console
// $loader = new Loader();
$loader->registerNamespaces([
'Vanchelo\Console' => __DIR__ . '/../library/console/src/', // The path may be different
]);
- Copy the contents of folders in your public folder accessible from public WEB
- Add Services
/**
* Register Console Service
*/
new Vanchelo\Console\ConsoleService($di);
- Add to the list of allowed IP addresses in the
src/config/config.php
/* ... */
'whitelist' => [
'127.0.0.1',
'::1'
],
/* ... */
Everything! The console must be available at http://site.com/phalcon-console, (*6)
As in the console are available all the services and service, (*7)
Your settings
To specify your settings console, you must:
- Create a configuration file in a convenient location, such as this content, (*8)
<?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
]);
- Sign-up in the container service settings console to initialize the service console
$di['console.config'] = function ()
{
// Path to correct its
$config = require '/path/to/console-config.php';
return $config;
};
new \Vanchelo\Console\ConsoleService($di);
For more precise information about the time of initializing the console and run the code, you must file index.php in your application to add to the rest of the code mark. line:, (*9)
define('PHALCONSTART', microtime(true));
It should look something like this:, (*10)
<?php
// public/index.php
define('PHALCONSTART', microtime(true));
A couple of screenshots
, (*11)