Skip to content

Commit

Permalink
Merge pull request #3 from teepluss/master
Browse files Browse the repository at this point in the history
Translate to English
  • Loading branch information
Brezhnev Ivan committed Oct 10, 2015
2 parents f1761bd + f9d6bdb commit 4035417
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 39 deletions.
69 changes: 38 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
Phalcon Console
===============
Адаптированная под Phalcon https://github.com/darsain/laravel-console - Laravel 4 Console
Adapted by Phalcon https://github.com/darsain/laravel-console - Laravel 4 Console

AJAX Консоль для выполнения PHP кода в браузере с подсветкой, возможностью сохранения последнего выполненного кода, ограничением доступа по IP адресу
AJAX console to execute PHP code in the browser with light, the ability to save the last code execution, limited access by IP address

Пример, вводим в окно редактора, нажимаем **Execute** `[Ctrl+Enter]`
Example, commissioning editor, click **Execute** `[Ctrl + Enter]`
```php
$user = Users::findFirst(1);

echo $user->name;
```
Результат
Result
```php
vanchelo
```

##Установка
###Через `composer`:
Добавить в файл `composer.json` в секцию `require`:
##Setting
###Via `composer`:
Add to file `composer.json` section `repositories` and `require`:
```
"vanchelo/phalcon-console": "dev-master"
```
```json
{
"require": {
"vanchelo/phalcon-console": "dev-master"
}
"repositories": [
{
"type": "vcs",
"url": "https://github.com/teepluss/phalcon-console"
}
],
"require": {
"vanchelo/phalcon-console": "dev-master"
}
}
```
В терминале выполнить команду `composer update`
In the terminal, run the command `composer update`


###Копи-паст:
* Скопировать содержимое папки в любой каталог
* Зарегистрировать в вашем автозагрузчике namespace Vanchelo\Console
###Copy and paste:
* Copy the contents of a folder to any directory
* Register your autoloader namespace Vanchelo\Console
```php
// $loader = new Loader();

$loader->registerNamespaces(array(
/* ... */
'Vanchelo\Console' => __DIR__ . '/../library/console/src/', // Путь может быть другим
'Vanchelo\Console' => __DIR__ . '/../library/console/src/', // The path may be different
));
```

* Скопировать содержимое папки public в вашу public папку доступную из WEB
* Добавить в сервисы
* Copy the contents of folders in your public folder accessible from public WEB
* Add Services

```php
/**
Expand All @@ -53,7 +60,7 @@ $loader->registerNamespaces(array(
new Vanchelo\Console\ConsoleService($di);
```

* Добавить список разрешенных IP адресов в src/config/config.php
* Add to the list of allowed IP addresses in the src/config/config.php

```php
/* ... */
Expand All @@ -64,29 +71,29 @@ new Vanchelo\Console\ConsoleService($di);
/* ... */
```

Всё! Консоль должна быть доступна по адресу http://site.com/phalcon-console
Everything! The console must be available at http://site.com/phalcon-console

Так же в консоле доступны все сервисы и службы
As in the console are available all the services and service

## Свои настройки
Для указания своих настроек консоли необходимо:
- Создать файл с настройками в удобном месте, например такого содержания
## Your settings
To specify your settings console, you must:
- Create a configuration file in a convenient location, such as this content
```php
<?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',

// Проверка прав доступа по IP
'check_ip' => false, // Отключаем проверку по IP адресу
// 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
```php
$di['console.config'] = function ()
{
// Пути исправить на свои
// Path to correct its
$config = require '/path/to/console-config.php';

return $config;
Expand All @@ -95,18 +102,18 @@ $di['console.config'] = function ()
new \Vanchelo\Console\ConsoleService($di);
```

Для более точного информирования о времени инициализации консоли и исполнения кода, необходимо в файле `index.php` вашего приложения добавить перед остальным кодом, след. строку:
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:

```php
define('PHALCONSTART', microtime(true));
```
Должно получится примерно так:
It should look something like this:
```php
<?php
// public/index.php
define('PHALCONSTART', microtime(true));
```

Пара скриншотов
A couple of screenshots
![Console Before Execute](http://i58.fastpic.ru/big/2013/1221/9d/fddb76f0f45ab5b665144e8dc7cd6f9d.jpg "Консоль до выполнеиня")
![Console After Execute](http://i58.fastpic.ru/big/2013/1221/19/a60efe026438b9a17b0ff8e73470ec19.jpg "Консоль после выполнеиня")
4 changes: 3 additions & 1 deletion src/AccessCheck.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php namespace Vanchelo\Console;

use Phalcon\DiInterface;

class AccessCheck implements AccessInterface, \Phalcon\DI\InjectionAwareInterface
{
protected $di;
Expand All @@ -19,7 +21,7 @@ public function getDI()
*
* @param \Phalcon\DiInterface $di
*/
public function setDI($di)
public function setDI(DiInterface $di)
{
$this->di = $di;
}
Expand Down
6 changes: 3 additions & 3 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
return new \Phalcon\Config([
'viewsDir' => __DIR__ . '/../views/',

// Класс проверки прав доступа
// If you want to specify the class test access rights to the console
'check_access_class' => 'Vanchelo\Console\AccessCheck',

// Проверка прав доступа по IP
'check_ip' => true,
// Check the permissions on the IP
'check_ip' => false,

/*
|--------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions src/views/partials/templates.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

<script type="text/html" id="template_controls_intro">
<li class="stretch">
<strong><code>{{=(navigator.appVersion.indexOf("Mac")!=-1 ? 'Cmd' : 'Ctrl') }}+Enter</code></strong>: выполнить
<span class="divider"></span> <strong><code>Esc</code></strong>: сбрость
<span class="divider"></span> <strong><code>Tab</code></strong>: фокус
<strong><code>{{=(navigator.appVersion.indexOf("Mac")!=-1 ? 'Cmd' : 'Ctrl') }}+Enter</code></strong>: execute
<span class="divider"></span> <strong><code>Esc</code></strong>: reset view
<span class="divider"></span> <strong><code>Tab</code></strong>: refocus editor
</li>
<li class="remember"><span class="button {{=(checked ? 'checked' : '') }}">запомнить код</span></li>
<li class="remember"><span class="button {{=(checked ? 'checked' : '') }}">remember code</span></li>
</script>

<script type="text/html" id="template_ended_unexpectedly">
Expand Down

0 comments on commit 4035417

Please sign in to comment.