-
Notifications
You must be signed in to change notification settings - Fork 314
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
Manipulate Configuration from within REPL #361
Comments
I'm not opposed to this, but it's not as simple as just exposing the config object. If it were possible to change configuration at runtime, I would probably do it via a command ( Some don't make sense to change. Some would need to swap out service implementations as config changes (readline, forking loop, etc). Actually you couldn't swap out the forking loop for a non-forking loop at runtime, so that would go in the "doesn't make sense to change" camp. |
Something like FYI I'd quite like it if there were analogous command-line arguments as well, so that psysh instances could be started with particular configs without the need for config file editing. That's a different feature request to this one of course, but I mention it now in case you also see utility in that feature, and think there would be some cross-over on the implementation side. |
What valid PHP code do you think Honestly, this would be possible, but a non-trivial amount of work to get fully working. How do you see yourself using this? Why not just spin up another session rather than changing configuration at runtime? |
My specific use case is with Drupal and the As Drupal code is able to implement new drush commands arbitrarily, all that is needed is for a
(a) That would necessitate recreating the state of the original session before 'continuing' with the new configuration, which might require a lot of steps to do (assuming there are no complicating factors making it difficult to do at all). (b) AFAIK I would then have to create multiple psysh config files with all the different permutations of options I would want to use, in order to run an instance with a particular set? A command to change the config values at runtime would be vastly more convenient. |
But what values, specifically, do you want to change at runtime? |
At minimum I think the three I mentioned initially are all useful candidates: It was a wish to interactively change the I created a separate config file and used the Being able to interactively modify settings would not only be a nicer solution to that particular need, but I think it would also be of general utility to users. For instance one could then paste a block of instructions into the shell which included temporarily setting a config value, evaluating some PHP, and then resetting the config value. |
The Configuration object provides methods such as
setPager()
,setRequireSemicolons()
,setErrorLoggingLevel()
, etc, which it would be nice to have access to directly from the REPL (if doing so at that stage would actually take effect?)I note that
$__psysh__->config
is private (and that in any caseLeavePsyshAlonePass.php
throws an exception if you attempt to touch the$__psysh__
object), so there's seemingly no direct access to this.Is there another way to invoke those methods?
The text was updated successfully, but these errors were encountered: