Git Product home page Git Product logo

yii2-shell's Introduction

Interactive Shell Extension for Yii 2


This extension provides an interactive shell for Yii framework 2.0 based on psysh.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads

Installation

The preferred way to install this extension is through composer.

Either run

composer require yiisoft/yii2-shell

or add

"yiisoft/yii2-shell": "~2.0.0"

to the require section of your composer.json.

Usage

After installation, you will be able to run the interactive shell via command line:

# Change path to your application's root directory
cd path/to/myapp

# Start the interactive shell
./yii shell

You can access the application object using Yii::$app. Additionally you have access to all your and your dependencies' classes.

See psysh's website for a list of available features.

Configuration

You can configure the PsySH shell by setting options via the shellConfig variable in the controller, i.e. add this to your console application configuration:

'controllerMap' => [
    'shell' => [
        'shellConfig' => [
            'updateCheck' => 'weekly',
            'verbosity' => \Psy\Configuration::VERBOSITY_VERBOSE,
        ],
    ],
],

See https://github.com/bobthecow/psysh/wiki/Config-options for a list of PsySH configurable options.

Note: updateCheck is explictly set to never by yii2-shell. All other PsySH options use default values.

Screenshot

The following screenshot shows a usage example:

Usage example of Yii2 shell

yii2-shell's People

Contributors

arhell avatar bizley avatar cebe avatar flaviovs avatar javiereguiluz avatar kyle-mccarthy avatar machour avatar pana1990 avatar ricpelo avatar samdark avatar silverfire avatar tobiase avatar wa1kb0y 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-shell's Issues

Incompatibility with yii2-apidoc?

Hello,
I tried to install yii2-shell but bumped into the following Composer conflict:

  • yii2-shell requires psy/psysh which requires nikic/php-parser: "^1.2.1|~2.0".
  • I have yii2-apidoc which requires nikic/php-parser: "0.9.*. Bump.

I don't know nikic/php-parser details, but is there a workaround for this?
Is it concievable to update yii2-apidoc's requirement to something compatible with yii2-shell's?
Thanks.
Pierre

`psysh ^0.7` in composer.json made psalm can not install

What steps will reproduce the problem?

  • composer install yiisoft/yii2-shell
  • composer install vimeo/psalm

the dependency chain is:

  • psalm -> nikic/php-parser
  • yii2-sell -> psysh -> php-parser

What's expected?

If yii2-shell is compatiable with psysh ^0.8, please update the composer.json.

What do you get instead?

dependency unsatisfied

  Problem 1
    - Installation request for vimeo/psalm ^0.3.24 -> satisfiable by vimeo/psalm[0.3.24].
    - Conclusion: remove nikic/php-parser v2.1.0
    - Conclusion: don't install nikic/php-parser v2.1.0
    - vimeo/psalm 0.3.24 requires nikic/php-parser ^3.0.4 -> satisfiable by nikic/php-parser[3.x-dev, v3.0.4].
    - Can only install one of: nikic/php-parser[3.x-dev, v2.1.0].
    - Can only install one of: nikic/php-parser[v3.0.4, v2.1.0].
    - Installation request for nikic/php-parser (locked at v2.1.0) -> satisfiable by nikic/php-parser[v2.1.0].

Additional info

Q A
Yii2-shell vesion dev-master 9843b89
PHP version 7.1.2
Operating system archlinux

Composer can't found this package

[InvalidArgumentException]
Could not find package yiisoft/yii2-shell at any version for your minimum-stab
ility (stable). Check the package spelling or your minimum-stability

P.S: composer & fxp/composer-asset-plugin were updated to latest version

Upgrade to PsySH ~0.10.3

Currently, yii2-shell depends on "psy/psysh": "~0.9.3"
This version of psysh requires abandoned packages and warnings are shown on installation.
The newer version seems to work fine. I tested it with opening the shell and accessing Yii::$app.

Cannot install: InvalidArgumentException: Could not find package yiisoft/yii2-shell at any version for your minimum-stability

What steps will reproduce the problem?

$ composer require --prefer-dist yiisoft/yii2-shell


  [InvalidArgumentException]
  Could not find package yiisoft/yii2-shell at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability


require [--dev] [--prefer-source] [--prefer-dist] [--no-plugins] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...


Chloe@xps ~/workspace/bestsales
$ yii | head -2

This is Yii version 2.0.8.
$ php -v
PHP 5.6.23 (cli) (built: Jul  4 2016 21:14:04)

What's expected?

To be installed.

What do you get instead?

An error.

Additional info

Q A
Yii vesion 2.0.8
PHP version 5.6
Operating system Windows 8.1, Cygwin

Add symfony/var-dumper as a requirement?

What steps will reproduce the problem?

In this class: https://github.com/yiisoft/yii2-shell/blob/master/YiiCaster.php you import a Symfony class: use Symfony\Component\VarDumper\Caster\Caster; but you don't require symfony/var-dumper in the composer.json of this project: https://github.com/yiisoft/yii2-shell/blob/master/composer.json

This works by chance and pure luck. Some package is installing the package you need (symfony/var-dumper) so this works without you actually requiring that package.

What's expected?

symfony/var-dumper should be added to the require section of the composer.json file.

What do you get instead?

Additional info

Q A
Yii vesion Any
PHP version Any
Operating system Any

Add branch to support Yii 2.1

This is a very cool tool for testing code and it would be great to have it available in Yii 2.1 (basically to upgrade composer.json)
Thanks

Release yii2-shell:2.0.2

I need to upgrade to psysh:0.9.x due to dependency on nikic/php-parser:4.0. There has been an issue #19 that was resolved 8 months ago and scheduled for yii2-shell:2.0.2 which was never released. Is there a reason why we can't have this bugfix out?

Cannot use eval(\Psy\sh());

What steps will reproduce the problem?

  • Try to set a break point in the program via eval(\Psy\sh());
  • Exception occurs: 2017-01-24 13:17:45 [::1][1][afff064e0bfaaed9df2df2262caa80db][error][yii\base\ErrorException:2] yii\base\ErrorException: mkdir(): Permission denied in /{{ project path }}/vendor/psy/psysh/src/Psy/Configuration.php:384

What's expected?

Ability to use eval(\Psy\sh()); to use the breakpoint functionality.

What do you get instead?

Exception occurs.

2017-01-24 13:17:45 [::1][1][afff064e0bfaaed9df2df2262caa80db][error][yii\base\ErrorException:2] yii\base\ErrorException: mkdir(): Permission denied in {{ project path }}/vendor/psy/psysh/src/Psy/Configuration.php:384
Stack trace:
#0 {{ project path }}/vendor/psy/psysh/src/Psy/Configuration.php(521): Psy\Configuration->getHistoryFile()
#1 {{ project path }}/vendor/psy/psysh/src/Psy/Shell.php(78): Psy\Configuration->getReadline()
#2 {{ project path }}/vendor/psy/psysh/src/Psy/Shell.php(139): Psy\Shell->__construct()
#3 {{ project path }}/models/Place.php(160) : eval()'d code(1): Psy\Shell::debug()
#4 {{ project path }}/models/Place.php(160): app\models\Place->unknown()
#5 {{ project path }}/vendor/yii2tech/ar-softdelete/SoftDeleteBehavior.php(219): app\models\Place->afterSoftDelete()
#6 {{ project path }}/vendor/yii2tech/ar-softdelete/SoftDeleteBehavior.php(186): yii2tech\ar\softdelete\SoftDeleteBehavior->afterSoftDelete()
#7 {{ project path }}/vendor/yii2tech/ar-softdelete/SoftDeleteBehavior.php(162): yii2tech\ar\softdelete\SoftDeleteBehavior->softDeleteInternal()
#8 {{ project path }}/vendor/yiisoft/yii2/base/Component.php(287): yii2tech\ar\softdelete\SoftDeleteBehavior->softDelete()
#9 {{ project path }}/vendor/yiisoft/yii2/base/Component.php(287): ::call_user_func_array:{{{ project path }}/vendor/yiisoft/yii2/base/Component.php:287}()
#10 {{ project path }}/controllers/ProfileController.php(519): yii\base\Component->__call()
#11 {{ project path }}/controllers/ProfileController.php(519): yii\base\Component->softDelete()
#12 {{ project path }}/vendor/yiisoft/yii2/base/InlineAction.php(57): app\controllers\ProfileController->actionDelete()
#13 {{ project path }}/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{{{ project path }}/vendor/yiisoft/yii2/base/InlineAction.php:57}()
#14 {{ project path }}/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams()
#15 {{ project path }}/vendor/yiisoft/yii2/base/Module.php(522): yii\base\Controller->runAction()
#16 {{ project path }}/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction()
#17 {{ project path }}/vendor/yiisoft/yii2/base/Application.php(379): yii\web\Application->handleRequest()
#18 {{ project path }}/web/index.php(8): yii\base\Application->run()
#19 {main}

Additional info

I've been trying to resolve the issue myself, but I am unfamiliar with PsySH and have just been trying to test it out. So far I have noticed that public static function getCurrentConfigDir() on ConfigPaths.php:67 will return '//.config/psysh` rather than the path to the project.

Q A
Yii vesion 2.0.11
PHP version PHP 7.1.0
Operating system OSX/macOs 10.12

Disable update check

What steps will reproduce the problem?

Run yii shell

What's expected?

The command executing without making any network connections other than the one requested by shell commands.

What do you get instead?

The command "phones home" to check for updates.

image

Additional info

Although staying up-to-date is desirable, for privacy, security, and/or compliance reasons some environments must allow only authorized and audited libraries to call external hosts.

A psysh updateCheck option does exist to disable the check (see https://github.com/bobthecow/psysh/wiki/Config-options), but it is enabled by default and I could not find any mechanism in yii2-shell to turn that off.

My suggestion is to provide a corresponding updateCheck options to the shell component that would be passed directly to psysh, so Yii2 applications could control the check.

IMHO this options should be "never" by default, but I'd be fine if the default behaviour is kept if an option to control it is available.

Q A
Yii version 2.0.47
PHP version 7.4
Operating system Linux Debian Bullseye

Update version

psysh lauch 0.8.0 realse.

Can i create pr to update psy version?

update irc link

What steps will reproduce the problem?

What's expected?

What do you get instead?

Additional info

Q A
Yii vesion
PHP version
Operating system

Reconsider VarDumper component as package requirement

Since VarDumper is a dev package and it now becomes a normal requirement. Therefore it's not really used as far I have scanned the code. This also break projects which already using a newer version of the VarDumper component as dev package.

Also see;
#15

Create release

What steps will reproduce the problem?

Require the package.

What's expected?

Get some of the latest fixes.

What do you get instead?

Older version, since there was no release since 2016.

#15 (comment)

Feature Request: add Events to yii\db\Connection

Hey,

is it possible to do something like this from laravel 5.3+?:

https://laravel.com/docs/5.3/database#listening-for-query-events

        DB::listen(function ($query) {
            var_dump( $query->sql);
            var_dump( $query->bindings);
            var_dump( $query->time);
        });

which would (pseudo code) look something like this in yii2:

$db = Yii::$app->db

$db->on(yii\db\Connection::EVENT_SQL_EXECUTED, function($query) { var_dump ($query); } );

Is something like this already possible? I am asking here because in a REPL this feature will most probably useful.

Thanks !

Upgrade to PsySH ~0.9.3

Currently, yii2-shell depends on "psy/psysh": "~0.8.1":

"psy/psysh": "~0.8.1",

However, latest psysh version is 0.9.3.

Is there any problem to bump psysh dependency to "~0.9.3"?

Additional info

Q A
Yii vesion 2.0.15.1
PHP version 7.1
Operating system Ubuntu 16.04.4 LTS

update github folder link

What steps will reproduce the problem?

http=>https

What's expected?

What do you get instead?

Additional info

Q A
Yii vesion
PHP version
Operating system

update root folder link

What steps will reproduce the problem?

What's expected?

What do you get instead?

Additional info

Q A
Yii vesion
PHP version
Operating system

Does not fully support PHP 7.4

Doc and show commands do not fully support php 7.4

kép

Additional info

| Yii vesion: 2.0.30 |
| PHP version: 7.4 |
| Operating system: macOs Mojave(10.14.6) |

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.