Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Psysh REPL for dev usage #6667

Merged
merged 2 commits into from Aug 16, 2020

Conversation

dongilbert
Copy link
Member

@dongilbert dongilbert commented Oct 2, 2018

Please be sure you are submitting this against the staging branch.

Q A
Bug fix? N
New feature? Y
Automated tests included? N
Related user documentation PR URL N
Related developer documentation PR URL N/A
Issues addressed (#s or URLs) N/A
BC breaks? N/A
Deprecations? N/A

Description:

This PR adds the Psysh Bundle for Symfony2 to our require-dev block in composer.json.

It allows devs access to the $container, $kernel, and $self (which is the Psy\Shell instance itself) from the command line. This lets devs test using their services from the container, as well as improve general debugging capabilities of the app.

You can start the repl after applying the PR and running composer install.

Please test on PHP 5.6 & 7.1

Some usages examples (after starting the repl):

# Update a mautic user's password
$model = $container->get('mautic.lead.model.lead');
$user = $model->getEntity(1); // pick an appropriate user ID
$encoder = $container->get('security.encoder_factory');
$user->setPassword($encoder->encodePassword('NEW_PASSWORD', $user->getSalt()));
$em = $container->get('doctrine')->getEntityManager();
$em->persist($user);
$em->flush();

# Test a method from your service
$myService = $container->get('mautic.my.service.key');
$myService->myMethodToTest();

Bonus PHP Docs

Follow instructions here: https://github.com/bobthecow/psysh/wiki/PHP-manual to get docs for built in PHP functions and classes via doc function_name

dgilbert ~/Sites/mautic (feature.dev-repl) $ app/console psysh -e dev
Psy Shell v0.9.8 (PHP 7.1.20 — cli) by Justin Hileman
>>> doc array_map
function array_map($callback, $arrays)

Description:
  Applies the callback to the elements of the given arrays
  
  array_map() returns an array containing all the elements of $array1 after applying the $callback
  function to each one. The number of parameters that the $callback function accepts should match
  the number of arrays passed to the array_map()

Param:
  callable  $callback  Callback function to run for each element in each array.
  array     $array1    An array to run through the $callback function.
  array     $...       Variable list of array arguments to run through the $callback function.

Return:
  array  Returns an array containing all the elements of $array1 after applying the $callback
         function to each one.

See Also:
   * array_filter()
   * array_reduce()
   * array_walk()
   * information about the callback type

>>> 

@dongilbert dongilbert added T1 Low difficulty to fix (issue) or test (PR) feature A new feature for inclusion in minor or major releases ready-to-test PR's that are ready to test labels Oct 2, 2018
@dongilbert
Copy link
Member Author

Fixed merge conflict.

@digitall-it
Copy link

I would like to thank you @dongilbert for the work you are doing.

@dongilbert
Copy link
Member Author

Updated to fix merge conflict with composer.lock again. @alanhartless

@npracht npracht added this to the 2.16.0 milestone Nov 19, 2018
@heathdutton heathdutton added this to Code Review (2 required) in Mautic 2 Dec 6, 2018
@heathdutton heathdutton removed this from Code Review (2 required) in Mautic 2 Dec 6, 2018
@dongilbert
Copy link
Member Author

Rebased on current staging to address composer.lock conflict

alanhartless
alanhartless previously approved these changes Mar 14, 2019
Copy link
Contributor

@alanhartless alanhartless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just saved my bacon and worked beautifully.

@dongilbert
Copy link
Member Author

Rebased to staging

@npracht npracht modified the milestone: 2.16.0 Jan 23, 2020
@npracht npracht added Triage M2/M3 and removed ready-to-test PR's that are ready to test labels Apr 6, 2020
@npracht
Copy link
Member

npracht commented Apr 6, 2020

Hi there!
It has been decided to not create any extra Mautic 2 minor versions (which means no more features in M2) knowing that Mautic 3 is coming very soon.

We now want to integrate your contribution in the Mautic 3 roadmap as 3.1.0 candidate.

How to do?

  1. Check if your feature or enhancement is still missing and relevant in Mautic 3
  2. If Yes: rebase your PR against the 3.x branch
  3. If No: please consider closing your PR if you are absolutely sure that the feature has made it into Mautic 3 already

Please report results by commenting on your PR to make us administration easier.


You can more information on how to do all of that on this blog post "Getting you PR ready for Mautic 3".

@RCheesley
Copy link
Sponsor Member

@dongilbert looks like this needs updating if it is still relevant - can you take a look?

@RCheesley RCheesley added has-conflicts Pull requests that cannot be merged until conflicts have been resolved pending-feedback PR's and issues that are awaiting feedback from the author labels Jul 21, 2020
@dongilbert
Copy link
Member Author

@RCheesley This has been updated to be compatible with Mautic 3. It was approved long ago for Mautic 2. @alanhartless If you could give your stamp again we could hopefully get this merged soon.

@RCheesley RCheesley removed the has-conflicts Pull requests that cannot be merged until conflicts have been resolved label Aug 13, 2020
@RCheesley
Copy link
Sponsor Member

@dongilbert wonderful, thanks for getting that sorted!

@RCheesley RCheesley added this to the 3.1.0 milestone Aug 13, 2020
@codecov
Copy link

codecov bot commented Aug 13, 2020

Codecov Report

Merging #6667 into staging will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             staging    #6667   +/-   ##
==========================================
  Coverage      29.54%   29.54%           
  Complexity     33237    33237           
==========================================
  Files           1936     1936           
  Lines         115138   115138           
==========================================
  Hits           34021    34021           
  Misses         81117    81117           

@RCheesley RCheesley added code-review-needed PR's that require a code review before merging ready-to-test PR's that are ready to test and removed pending-feedback PR's and issues that are awaiting feedback from the author triage-mautic-3 labels Aug 13, 2020
Copy link
Member

@dennisameling dennisameling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works - as this is a small change that doesn't affect Mautic's functionality directly, I'll go ahead and merge this one. Thanks @dongilbert for the PR and your patience!

@dennisameling dennisameling added ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged and removed ready-to-test PR's that are ready to test labels Aug 15, 2020
@dennisameling dennisameling merged commit 203b805 into mautic:staging Aug 16, 2020
@dennisameling
Copy link
Member

dennisameling commented Aug 16, 2020

cc @mautic/education-team FYI I just created two issues to add this new functionality to the docs: mautic/mautic-community-handbook#19 mautic/developer-documentation#163

@mautibot
Copy link

This pull request has been mentioned on Mautic Community Forums. There might be relevant details there:

https://forum.mautic.org/t/mautic-3-1-new-beginnings/15787/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-review-needed PR's that require a code review before merging feature A new feature for inclusion in minor or major releases ready-to-commit PR's with 2 successful tests, 1 approval, automated tests and docs and is ready to be merged T1 Low difficulty to fix (issue) or test (PR)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants