Replace Boris with PsySH #1543

Merged
merged 1 commit into from Aug 12, 2015

Conversation

Projects
None yet
4 participants
@damiankloip
Contributor

damiankloip commented Aug 8, 2015

This is still a WIP, but thought I would post for now anyway.

In a nutshell, PsySH is much better, in every way. A couple of things off the top of my head now:

  • Function, variable, and namespace autocompletion - MASSIVE!
  • Ability to add custom commands in the shell itself
  • Better support for exceptions/ability to get previous exceptions
  • View user space code
  • View docblocks
  • Many more things.....
@dawehner

This comment has been minimized.

Show comment
Hide comment
@dawehner

dawehner Aug 8, 2015

Contributor

RTBM

WOW

dump -a $user;
Drupal\user\Entity\User {#597
#values: [
"uid" => [
"x-default" => "1"
]
"uuid" => [
"x-default" => "ff9a6c6b-5369-4745-844e-78739e324c78"
]
"langcode" => [
"x-default" => "en"
]
"preferred_langcode" => [
"x-default" => "en"
]
"preferred_admin_langcode" => [
"x-default" => null
]
"name" => [
"x-default" => "admin"
]
"pass" => [
"x-default" => "$S$EB.fLntAm0jko5yC1z/R1PivT8D3mS5tOOEd/3k3kWBbmjl.Lec8"
]
"mail" => [
"x-default" => "admin@example.com"
]
"timezone" => [
"x-default" => "Europe/Berlin"
]
"status" => [
"x-default" => "1"
]
"created" => [
"x-default" => "1438961420"
]
"changed" => [
"x-default" => "1438961445"
]
"access" => [
"x-default" => "1439037961"
]
"login" => [
"x-default" => "1438961536"
]
"init" => [
"x-default" => "admin@example.com"
]
"default_langcode" => [
"x-default" => "1"
]
"roles" => [
"x-default" => [
[
"target_id" => "administrator"
]
]
]

and WOW^2

ls -la $user;

Class Constants:
ANONYMOUS_ROLE "anonymous"
AUTHENTICATED_ROLE "authenticated"
TRANSLATION_CREATED 2
TRANSLATION_EXISTING 1
TRANSLATION_REMOVED 0

Class Properties:
$_serviceIds []
$activeLangcode "x-default"
$anonymousUser null
$cacheContexts []
$cacheMaxAge -1
$cacheTags []
$defaultLangcode "en"
$defaultLangcodeKey "default_langcode"
$enforceIsNew null
$entityKeys [ …3]
$entityTypeId "user"
$fieldDefinitions null
$fields []
$isDefaultRevision true
$langcodeKey "langcode"
$languages null
$newRevision false
$translatableEntityKeys [ …2]
$translationInitialize false
$translations [ …1]
$typedData null
$validated false
$validationRequired false
$values [ …17]

Class Methods:

Contributor

dawehner commented Aug 8, 2015

RTBM

WOW

dump -a $user;
Drupal\user\Entity\User {#597
#values: [
"uid" => [
"x-default" => "1"
]
"uuid" => [
"x-default" => "ff9a6c6b-5369-4745-844e-78739e324c78"
]
"langcode" => [
"x-default" => "en"
]
"preferred_langcode" => [
"x-default" => "en"
]
"preferred_admin_langcode" => [
"x-default" => null
]
"name" => [
"x-default" => "admin"
]
"pass" => [
"x-default" => "$S$EB.fLntAm0jko5yC1z/R1PivT8D3mS5tOOEd/3k3kWBbmjl.Lec8"
]
"mail" => [
"x-default" => "admin@example.com"
]
"timezone" => [
"x-default" => "Europe/Berlin"
]
"status" => [
"x-default" => "1"
]
"created" => [
"x-default" => "1438961420"
]
"changed" => [
"x-default" => "1438961445"
]
"access" => [
"x-default" => "1439037961"
]
"login" => [
"x-default" => "1438961536"
]
"init" => [
"x-default" => "admin@example.com"
]
"default_langcode" => [
"x-default" => "1"
]
"roles" => [
"x-default" => [
[
"target_id" => "administrator"
]
]
]

and WOW^2

ls -la $user;

Class Constants:
ANONYMOUS_ROLE "anonymous"
AUTHENTICATED_ROLE "authenticated"
TRANSLATION_CREATED 2
TRANSLATION_EXISTING 1
TRANSLATION_REMOVED 0

Class Properties:
$_serviceIds []
$activeLangcode "x-default"
$anonymousUser null
$cacheContexts []
$cacheMaxAge -1
$cacheTags []
$defaultLangcode "en"
$defaultLangcodeKey "default_langcode"
$enforceIsNew null
$entityKeys [ …3]
$entityTypeId "user"
$fieldDefinitions null
$fields []
$isDefaultRevision true
$langcodeKey "langcode"
$languages null
$newRevision false
$translatableEntityKeys [ …2]
$translationInitialize false
$translations [ …1]
$typedData null
$validated false
$validationRequired false
$values [ …17]

Class Methods:

@damiankloip

This comment has been minimized.

Show comment
Hide comment
@damiankloip

damiankloip Aug 8, 2015

Contributor

That's basically the examples I was going to put in here to show it off :) And yeah, not too shabby..

Contributor

damiankloip commented Aug 8, 2015

That's basically the examples I was going to put in here to show it off :) And yeah, not too shabby..

@damiankloip

This comment has been minimized.

Show comment
Hide comment
@damiankloip

damiankloip Aug 8, 2015

Contributor

Also notice that it pages the output. Regular dump (default eval) just tells you the FQCN etc..

Contributor

damiankloip commented Aug 8, 2015

Also notice that it pages the output. Regular dump (default eval) just tells you the FQCN etc..

@damiankloip

This comment has been minimized.

Show comment
Hide comment
@damiankloip

damiankloip Aug 8, 2015

Contributor

1____forks_drush_drush_____sites_d8_core__php_

Contributor

damiankloip commented Aug 8, 2015

1____forks_drush_drush_____sites_d8_core__php_

@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Aug 8, 2015

Member

Looks great. The exit command gives a fatal (see below). Any way to avoid that?

`

exit
Exit: Goodbye.
PHP Fatal error: The container was serialized. in /Users/moshe.weitzman/htd/d8/core/lib/Drupal/Core/DependencyInjection/Container.php on line 33
PHP Stack trace:
PHP 1. {main}() /Users/moshe.weitzman/c/h/drush/drush.php:0
PHP 2. drush_main() /Users/moshe.weitzman/c/h/drush/drush.php:11
PHP 3. Drush\Boot\BaseBoot->bootstrap_and_dispatch() /Users/moshe.weitzman/c/h/drush/drush.php:70
PHP 4. drush_dispatch() /Users/moshe.weitzman/c/h/drush/lib/Drush/Boot/BaseBoot.php:62
PHP 5. call_user_func_array:{/Users/moshe.weitzman/c/h/drush/includes/command.inc:178}() /Users/moshe.weitzman/c/h/drush/includes/command.inc:178
PHP 6. drush_command() /Users/moshe.weitzman/c/h/drush/includes/command.inc:178
PHP 7. _drush_invoke_hooks() /Users/moshe.weitzman/c/h/drush/includes/command.inc:210
PHP 8. call_user_func_array:{/Users/moshe.weitzman/c/h/drush/includes/command.inc:359}() /Users/moshe.weitzman/c/h/drush/includes/command.inc:359
PHP 9. drush_cli_core_cli() /Users/moshe.weitzman/c/h/drush/includes/command.inc:359
PHP 10. Psy\Shell->run() /Users/moshe.weitzman/c/h/drush/commands/core/cli.drush.inc:30
PHP 11. Symfony\Component\Console\Application->run() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/Shell.php:282
PHP 12. Psy\Shell->doRun() /Users/moshe.weitzman/c/h/drush/vendor/symfony/console/Application.php:126
PHP 13. Psy\ExecutionLoop\ForkingLoop->run() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/Shell.php:313
PHP 14. Psy\ExecutionLoop\ForkingLoop->serializeReturn() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/ExecutionLoop/ForkingLoop.php:82
PHP 15. serialize() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/ExecutionLoop/ForkingLoop.php:159
PHP 16. Drupal\Core\DependencyInjection\Container->__sleep() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/ExecutionLoop/ForkingLoop.php:159
PHP 17. trigger_error() /Users/moshe.weitzman/htd/d8/core/lib/Drupal/Core/DependencyInjection/Container.php:33
`

Member

weitzman commented Aug 8, 2015

Looks great. The exit command gives a fatal (see below). Any way to avoid that?

`

exit
Exit: Goodbye.
PHP Fatal error: The container was serialized. in /Users/moshe.weitzman/htd/d8/core/lib/Drupal/Core/DependencyInjection/Container.php on line 33
PHP Stack trace:
PHP 1. {main}() /Users/moshe.weitzman/c/h/drush/drush.php:0
PHP 2. drush_main() /Users/moshe.weitzman/c/h/drush/drush.php:11
PHP 3. Drush\Boot\BaseBoot->bootstrap_and_dispatch() /Users/moshe.weitzman/c/h/drush/drush.php:70
PHP 4. drush_dispatch() /Users/moshe.weitzman/c/h/drush/lib/Drush/Boot/BaseBoot.php:62
PHP 5. call_user_func_array:{/Users/moshe.weitzman/c/h/drush/includes/command.inc:178}() /Users/moshe.weitzman/c/h/drush/includes/command.inc:178
PHP 6. drush_command() /Users/moshe.weitzman/c/h/drush/includes/command.inc:178
PHP 7. _drush_invoke_hooks() /Users/moshe.weitzman/c/h/drush/includes/command.inc:210
PHP 8. call_user_func_array:{/Users/moshe.weitzman/c/h/drush/includes/command.inc:359}() /Users/moshe.weitzman/c/h/drush/includes/command.inc:359
PHP 9. drush_cli_core_cli() /Users/moshe.weitzman/c/h/drush/includes/command.inc:359
PHP 10. Psy\Shell->run() /Users/moshe.weitzman/c/h/drush/commands/core/cli.drush.inc:30
PHP 11. Symfony\Component\Console\Application->run() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/Shell.php:282
PHP 12. Psy\Shell->doRun() /Users/moshe.weitzman/c/h/drush/vendor/symfony/console/Application.php:126
PHP 13. Psy\ExecutionLoop\ForkingLoop->run() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/Shell.php:313
PHP 14. Psy\ExecutionLoop\ForkingLoop->serializeReturn() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/ExecutionLoop/ForkingLoop.php:82
PHP 15. serialize() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/ExecutionLoop/ForkingLoop.php:159
PHP 16. Drupal\Core\DependencyInjection\Container->__sleep() /Users/moshe.weitzman/c/h/drush/vendor/psy/psysh/src/Psy/ExecutionLoop/ForkingLoop.php:159
PHP 17. trigger_error() /Users/moshe.weitzman/htd/d8/core/lib/Drupal/Core/DependencyInjection/Container.php:33
`

@jibran

This comment has been minimized.

Show comment
Hide comment
@jibran

jibran Aug 9, 2015

Can we backport this to 6.x?

jibran commented Aug 9, 2015

Can we backport this to 6.x?

@damiankloip

This comment has been minimized.

Show comment
Hide comment
@damiankloip

damiankloip Aug 10, 2015

Contributor

@weitzman Yes, I noticed this too and was looking at this earlier. At first I thought this was an issue with PsySH, and we could fix it by adding our own Loop implementations. But IMO the real issue is that \Drupal\Core\DependencyInjection\Container::__sleep is calling trigger_error, otherwise it would be caught by PsySH and we would have no problem. https://www.drupal.org/node/2190643 added the trigger_error instead. Looks like DX reasons, and probably the exception being caught, and not having an indicative backtrace.

@jibran how about we get a working/merged version here first? :)

Contributor

damiankloip commented Aug 10, 2015

@weitzman Yes, I noticed this too and was looking at this earlier. At first I thought this was an issue with PsySH, and we could fix it by adding our own Loop implementations. But IMO the real issue is that \Drupal\Core\DependencyInjection\Container::__sleep is calling trigger_error, otherwise it would be caught by PsySH and we would have no problem. https://www.drupal.org/node/2190643 added the trigger_error instead. Looks like DX reasons, and probably the exception being caught, and not having an indicative backtrace.

@jibran how about we get a working/merged version here first? :)

weitzman added a commit that referenced this pull request Aug 12, 2015

Merge pull request #1543 from damiankloip/psysh
Replace Boris with PsySH as backend for php command.

See http://psysh.org/ for usage details.

@weitzman weitzman merged commit db71292 into drush-ops:master Aug 12, 2015

2 checks passed

Scrutinizer No new issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jibran

This comment has been minimized.

Show comment
Hide comment
@jibran

jibran Aug 12, 2015

@damiankloip it's merged. Can we move to 6.x now?

jibran commented Aug 12, 2015

@damiankloip it's merged. Can we move to 6.x now?

@damiankloip

This comment has been minimized.

Show comment
Hide comment
@damiankloip

damiankloip Aug 12, 2015

Contributor

Sure. Just open a new PR :) This is open source.

Contributor

damiankloip commented Aug 12, 2015

Sure. Just open a new PR :) This is open source.

@damiankloip

This comment has been minimized.

Show comment
Hide comment
@damiankloip

damiankloip Aug 12, 2015

Contributor

Also, why not 7.x?

Contributor

damiankloip commented Aug 12, 2015

Also, why not 7.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment