Skip to content

Conversation

@dantleech
Copy link
Contributor

Replaces existing commands with embedded PHPCR Shell.

Depends on: phpcr/phpcr-shell#40

For example

$ php app/console doctrine:phpcr:shell node:list / # commands with arguments can be entered without quotes
$ php app/console doctrine:phpcr:shell "ls -L2" # commands with options must be quoted
$ php app/console doctrine:phpcr:shell node-type:list
$ php app/console doctrine:phpcr:shell "SELECT * FROM [nt:unstructured]" # queries must be quoted

Or launch a shell session

$php app/console doctrine:phpcr:shell

Copy link
Member

Choose a reason for hiding this comment

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

you need to handle the exit code of the embedded application, to reutnr it as the exit code of the command

@stof
Copy link
Member

stof commented Jun 5, 2014

removing the existing commands is a BC break. I'm not sure such cleanup justifies a bump to 2.0 now. you may keep the old commands around (deprecating them instead of removing them)

@dantleech
Copy link
Contributor Author

@stof yeah the PR in its current state would be a major version change, we could also conditionally support the phpcr-shell only if it is installed.

@stof
Copy link
Member

stof commented Jun 5, 2014

@dantleech my suggestion is to keep the existing command and to add the new phpcr shell command => no BC break but a new feature => next minor version.

@stof
Copy link
Member

stof commented Jun 5, 2014

and the composer.json needs to be updated to require the PHPCR shell if you use it

@dbu
Copy link
Member

dbu commented Jun 11, 2014

i agree with stof: lets keep the old commands for now but deprecate them and start requiring the shell for the 1.2 version. the commands will be unmaintained but can stay for a while, but surely wont get any new features.

it would be really nice if we can disable parsing the arguments, or as a workaround have the phpcr command expect any parameters and forward them, if that is possible.

@stof
Copy link
Member

stof commented Jun 11, 2014

I don't think that's possible

@dantleech
Copy link
Contributor Author

Its possible if we can change the InputInterface class. (this is what I do in PHPCR shell to allow phpcr:query:select FROM [nt:foobar] blah blah blah). But I can only do that because I use my own Application class.

@dantleech
Copy link
Contributor Author

I have mitigated the quoting problem somewhat by making the argument an array, concatenating the values with space and then passing this to the nested command. If options are needed then the entire command still needs to be quoted however.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Argument is now an array

@dantleech
Copy link
Contributor Author

Reverted the removal of the legacy commands, updated help and added suggest to composer. If the phpcr-shell package is not installed, the command will throw an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Argument is now an array

@dbu
Copy link
Member

dbu commented Jun 14, 2014

looks good! can you squash the commits please? and update the symfony-cmf-docs (dev branch) with some documentation and a link to the shell?

btw, if i don't specify a command for the shell, do i get into the interactive shell with this command?

Copy link
Member

Choose a reason for hiding this comment

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

... SELECT SQL2 queries ...

@dantleech
Copy link
Contributor Author

Re. launching the shell, thats something I should add, but not sure how - spec

@dantleech
Copy link
Contributor Author

Ifying nothing lists all the commands, and adding a --shell option might be the way forward.

Btw. This also beeds a a PR merge on the shell.

@dbu dbu changed the title [RFC] Embedded PHPCR Shell [WCM] Embedded PHPCR Shell Jun 15, 2014
@dbu
Copy link
Member

dbu commented Jun 15, 2014

+1 for a --shell option. or maybe --interactive / -i ?

i changed the heading to WCM to remind us we wait for the shell PR to be merged.

@stof
Copy link
Member

stof commented Jun 16, 2014

--shell is already used by Symfony. And --interactive could be confusing with --no-interaction used by Symfony

@dbu
Copy link
Member

dbu commented Jun 16, 2014

gnarc. what if we say without arguments you go into the interactive shell and you need to run list to get a list of commands? otherwise, --cli ?

@dantleech
Copy link
Contributor Author

I think without arguments for the shell is OK - its probably the preferred way to execute commands unless you are scripting.

@dantleech
Copy link
Contributor Author

ok updated.

  • Shell is now launched as the default action ./app/console phpcr
    • When launched like this it will create a configuration directory in the users home folder. Does that matter?
  • The "deprecated" commands will be unavailable when phpcr-shell is present.
  • The phpcr command will be present all the time however, to advertise its existence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this is copy/pasted in each command, we can't use inheritance and we can't use traits due to BC.

Copy link
Member

Choose a reason for hiding this comment

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

i am -1 on this. not due to copy-paste but because it in effect means a BC break for the user. he can't use the command he was used to anymore. i think we should just update the description to append the deprecated info, but otherwise leave them in until we do a phpcr-odm 2.0

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @dbu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.. I reasoned that the user explicitly adds PHPCR-Shell to their dependencies, and only then do the commands disappear. So its an option. Is that still a BC break?

Christophe Coevoet [email protected] wrote:

@@ -94,4 +94,12 @@ protected function execute(InputInterface $input,
OutputInterface $output)

     return parent::execute($input, $output);
 }
  • /**
  • \* Only enable this command if PHPCR Shell is not installed.
    
  • */
    
  • public function isEnabled()
  • {
  •    return !DoctrineCommandHelper::isPhpcrShellInstalled();
    

I agree with @dbu


Reply to this email directly or view it on GitHub:
https://github.com/doctrine/DoctrinePHPCRBundle/pull/151/files#r13833585

Sent from my Android device with K-9 Mail. Please excuse my brevity.

Copy link
Member

Choose a reason for hiding this comment

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

yes. If you have a deploy script using the existing command, you might still want to add PHPCR-Shell in your project to get the new features without breaking your deployment for instance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah just ran into that very problem :)

@dantleech
Copy link
Contributor Author

This PR should also wait until PHPCR-Shell has some issues fixed - e.g. the table formatting seems broken in embedded mode, and also in my test project i am using Symfony 2.5 and phpcr-shell there is a BC break (also in the TableHelper)

@dbu
Copy link
Member

dbu commented Jun 16, 2014

cool with the default shell. about creating a file: what is the point of that? history of commands? global configuration? maybe it would make more sense to create that file in the project root, or even the app/cache/ , depending on what exactly it does.

@dantleech
Copy link
Contributor Author

I will try and get this ready for the 1.2 release.

@dbu the configuration folder currently stores two types of configuration: aliases (e.g. ls: node:list, cp: node:copy, use: workspace:use, explain: node-type:show, etc.) and connection profiles.

Connection profiles will not be created in the embedded mode, the alias file is always created however, its global configuration. (and can be reinitialized / reloaded with shell:config:reload and shell:config:init).

Personally I don't see any reason to disable this, but still feels wierd - one option might be to read the file if it is there but never create it.

@dbu
Copy link
Member

dbu commented Aug 7, 2014

i would expect the aliases to be read from symfony configuration in embedded mode. additionally reading the config file if it happens to be there seems ok to me. that way a user can share his alias between projects, or have his preferred personal aliases. precedence in case of name conflicts is a bit tricky, not sure what makes more sense.
but i would avoid creating the folder in embedded mode.

btw, this needs a rebase.

@dantleech
Copy link
Contributor Author

Reading aliases from the SF configuration might be interesting, e.g. exportcms: session:export myexport.xml /cms/foobar/blocks for instance. I would say then that.

  1. Read the global configuration if it exists, if not use the default (but do not write to the FS).
  2. Merge any aliases defined in the Bundle

Will need some refactoring on the Shell PR, but sounds good.

@dbu
Copy link
Member

dbu commented Aug 7, 2014

:y:

@dantleech
Copy link
Contributor Author

ok. I have updated and rebased this PR and the corresponding PHPCR-Shell PR has been updated also.

Regarding config creation, in shell mode a config file will never be created automatically, but if the configuration is there it will be used. (the user can still manually create the config with shell:config:init). Otherwise the default dist configuration will be loaded.

I decided against adding configuration for project specific shell configuration at this point.

So, for me this is good.

@dantleech
Copy link
Contributor Author

Also I changed the command from $ app/console phpcr to app/console phpcr:shell as I don't think people expect it to be at the top level.

Copy link
Member

Choose a reason for hiding this comment

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

this is now phpcr:shell, no?

Copy link
Member

Choose a reason for hiding this comment

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

use %command.full_name% in the help text instead of app/console phpcr:shell. Symfony does the replacement automatically (there is also ``%command.name%for just thephpcr:shell` part). this way, you don't need to change the help when the command name changes (or when the user renames the `app/console` file to something else)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done as @stof said, and changed the name to doctrine:phpcr:shell -- which I think is the most correct.

- Added `doctrine:phpcr:shell` command to launch either single commands
  or start a shell session based on the default or given doctrine
  session.
@dantleech
Copy link
Contributor Author

Updated and squashed and I have merged the related PHPCR-Shell PR.

@dbu dbu changed the title [WCM] Embedded PHPCR Shell Embedded PHPCR Shell Aug 15, 2014
@dbu
Copy link
Member

dbu commented Aug 15, 2014

+1 to merge. @lsmith77 happy too?

we should add a note to the symfony-cmf-docs somewhere. btw, you could also check if you find a place in phpcr-odm-documentation to point to the shell, as its useful in standalone phpcr-odm usage as well.

lsmith77 added a commit that referenced this pull request Aug 15, 2014
@lsmith77 lsmith77 merged commit e1a559c into doctrine:master Aug 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants