Git Product home page Git Product logo

yii2-console-runner-extension's Introduction

Console Runner

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

An extension for running console commands on background in Yii framework.

Installation

Add the following to require section of your composer.json:

"vova07/yii2-console-runner-extension": "*"

Then do composer install.

Usage

Imported class:
use vova07\console\ConsoleRunner;
$cr = new ConsoleRunner(['file' => '@my/path/to/yii']);
$cr->run('controller/action param1 param2 ...');
Application component:
// config.php
...
components [
    'consoleRunner' => [
        'class' => 'vova07\console\ConsoleRunner',
        'file' => '@my/path/to/yii' // or an absolute path to console file
    ]
]
...

// some-file.php
Yii::$app->consoleRunner->run('controller/action param1 param2 ...');

Running Tests

$ phpunit

yii2-console-runner-extension's People

Contributors

manky avatar mickgeek avatar nepster-web avatar vova07 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-console-runner-extension's Issues

problem runing in web server

Hello Vasile
Excellent extension.
I have a small problem ...
it works perfectly in my localhost development environment (PHP 7.0.28-0 ubuntu 0.16.04.1) but when I upload it to the web server (linux PHP 5.6.35) it does not work.

Any suggestions?
Maybe some PHP option or extension.
Thank you very much.

Background process does not work

I have:

  • yii2 advanced
  • ubuntu 14.04

I placed this in the common\main.php:

'consoleRunner' => [
    'class' => 'vova07\console\ConsoleRunner',
    'file' => '@app/yii'
]

Inside of the SiteController I have created action called actionTest which is the following: (based on this issue)

public function actionTest() {
    $connection = \Yii::$app->db;
    $connection->createCommand()->dropTable('TestTable');
    $connection->createCommand()->createTable('TestTable', ['column1' => 'string', 'column2' => 'integer']);

    return 0;
}

and I am calling console runner from actionIndex like this:

Yii::$app->consoleRunner->run('site/test');

This problem happens in front-end and back-end side of the application, meaning that I cannot run background processes on either side.

And problem is that site/test does not want to execute on the background. I did this example just to test the class, however in real I need this class to send ~1000 emails.

Any clues what can be the cause of the issue?


Btw, according to this:

Yii::$app->consoleRunner->run('site/test');

I can pass params (eg. Yii::$app->consoleRunner->run('site/index param1 param2')) to the actions. However in the documentation it does not say how to get them inside from the action which is being called as a background.

PHP-FMP Issue with PHP_BINARY

When using php-fpm, PHP_BINARY returns php-fpm binary not php binary

For example:
php-fpm: PHP_BINARY = /usr/sbin/php-fpm
php: PHP_BINARY = /usr/bin/php

I do believe is better to use old solution

$cmd = PHP_BINDIR . '/php ' . Yii::getAlias($this->file) . ' ' . $cmd;

instead of a new one

$cmd = PHP_BINARY . ' ' . Yii::getAlias($this->file) . ' ' . $cmd;

Consult for pass arguments.

Dear, the extension is very good, I am being able to use it. I just have a question, how can I send an array as a parameter, or what is better a file that I have collected from a form with UploadedFile. I hope you can answer me with an idea because reading the official documentation of yii2 I can not find the solution. Greetings!

Allow common route declaration

It would be nice if the command is not just a string. Rather it should be like it is with Url::to() where you pass an array with the route and parameters.

console command not invoking!

Here is how i am trying to invoke the console command
Invoking function in siteController.php

use vova07\console\ConsoleRunner;
public function actionIndex()
    {
        $cr = new ConsoleRunner(['file' => '@app/controllers/SiteController']);
        $cr->run('site/display');
        return $this->render('index');
    }

console action is also in siteController.php

public function actionDisplay(){
//some code
}

but after running index action it is not invoking the display action

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.