|
| 1 | +Interacting |
| 2 | +=========== |
| 3 | + |
| 4 | +The PHPCRSH is designed to be a hybrid of a filesystem and RDBMS shell. You can |
| 5 | +both navigate the content hierarchy and execute queries. |
| 6 | + |
| 7 | +.. note:: |
| 8 | + |
| 9 | + PHPCRSH supports "aliases". In this chapter we will use aliases rather than the full |
| 10 | + commands, for example "ls" instead of "node:list", "rm" instead of "node:remove" etc. |
| 11 | + See the chapter on :ref:`phpcrsh_configuration_aliases` for more information. |
| 12 | + |
| 13 | +The current path |
| 14 | +---------------- |
| 15 | + |
| 16 | +You can navigate the content heriarchy using the `shell:path:change` (or `cd` for short). The |
| 17 | +`pwd` command is the alias for `shell:path:show` and displays the current working path: |
| 18 | + |
| 19 | +.. code-block:: bash |
| 20 | +
|
| 21 | + PHPCRSH > pwd |
| 22 | + / |
| 23 | + PHPCRSH > cd cms |
| 24 | + PHPCRSH > pwd |
| 25 | + /cms |
| 26 | +
|
| 27 | +Listing node contents |
| 28 | +--------------------- |
| 29 | + |
| 30 | +You can list the contents of a node with the `node:list` command (or `ls`): |
| 31 | + |
| 32 | +.. code-block:: bash |
| 33 | +
|
| 34 | + PHPCRSH > ls |
| 35 | + +-----------------+-----------------+-----------------+ |
| 36 | + | cms/ | nt:unstructured | | |
| 37 | + | jcr:primaryType | NAME | nt:unstructured | |
| 38 | + +-----------------+-----------------+-----------------+ |
| 39 | +
|
| 40 | +Which also accepts a target: |
| 41 | + |
| 42 | +.. code-block:: bash |
| 43 | +
|
| 44 | + PHPCRSH > ls cms |
| 45 | + +--------------------+-----------------+-----------------------------------+ |
| 46 | + | pages/ | nt:unstructured | | |
| 47 | + | posts/ | nt:unstructured | | |
| 48 | + | routes/ | nt:unstructured | | |
| 49 | + | jcr:primaryType | NAME | nt:unstructured | |
| 50 | + | jcr:mixinTypes | NAME | [0] phpcr:managed | |
| 51 | + | phpcr:class | STRING | Acme\BasicCmsBundle\Document\Site | |
| 52 | + | phpcr:classparents | STRING | | |
| 53 | + +--------------------+-----------------+-----------------------------------+ |
| 54 | +
|
| 55 | +And a depth: |
| 56 | + |
| 57 | +.. code-block:: bash |
| 58 | +
|
| 59 | + PHPCRSH > ls -L2 |
| 60 | + +--------------------------------------------------------------------------+-----------------+-----------------------------------+ |
| 61 | + | cms/ | nt:unstructured | | |
| 62 | + | pages/ | nt:unstructured | | |
| 63 | + | | main/ | nt:unstructured | | |
| 64 | + | | jcr:primaryType | NAME | nt:unstructured | |
| 65 | + | posts/ | nt:unstructured | | |
| 66 | + | | Consequatur quisquam recusandae asperiores accusamus nihil repellat. | nt:unstructured | | |
| 67 | + | | Velit soluta explicabo eligendi occaecati debitis et saepe eum. | nt:unstructured | | |
| 68 | + | | jcr:primaryType | NAME | nt:unstructured | |
| 69 | + | routes/ | nt:unstructured | | |
| 70 | + | page/ | nt:unstructured | | |
| 71 | + | post/ | nt:unstructured | | |
| 72 | + | jcr:primaryType | NAME | nt:unstructured | |
| 73 | + | jcr:primaryType | NAME | nt:unstructured | |
| 74 | + | jcr:mixinTypes | NAME | [0] phpcr:managed | |
| 75 | + | phpcr:class | STRING | Acme\BasicCmsBundle\Document\Site | |
| 76 | + | phpcr:classparents | STRING | | |
| 77 | + | jcr:primaryType | NAME | nt:unstructured | |
| 78 | + +--------------------------------------------------------------------------+-----------------+-----------------------------------+ |
| 79 | +
|
| 80 | +In addtion to listing the actual node content, you can also show the |
| 81 | +node properties and children which are defined in the schema with the ``-t`` option |
| 82 | +(**t** for template). The second of the following two examples illustrates this option: |
| 83 | + |
| 84 | +.. code-block:: bash |
| 85 | +
|
| 86 | + PHPCRSH> ls |
| 87 | + +--------------------+-------------------------+------------------------------------------------+ |
| 88 | + | home | slinpTest:article | Home | |
| 89 | + | jcr:primaryType | NAME | slinpTest:article | |
| 90 | + | title | STRING | Slinp Web Content Framework | |
| 91 | + +--------------------+-------------------------+------------------------------------------------+ |
| 92 | + PHPCRSH> ls -T |
| 93 | + +--------------------+-------------------------+------------------------------------------------+ |
| 94 | + | home | slinpTest:article | Home | |
| 95 | + | @* | nt:base | | |
| 96 | + | jcr:primaryType | NAME | slinpTest:article | |
| 97 | + | title | STRING | Slinp Web Content Framework | |
| 98 | + | @tags | STRING | | |
| 99 | + +--------------------+-------------------------+------------------------------------------------+ |
| 100 | +
|
| 101 | +In the above examples you see first the "current" contents of the node, in the second we use the |
| 102 | +``-t`` option to list "template" items, i.e. items which are defined in the node schema but which |
| 103 | +are as yet unrealized. Template items are indicated with the ``@`` symbol. The ``*`` indicates zero or |
| 104 | +many. |
| 105 | + |
| 106 | +Editing nodes |
| 107 | +------------- |
| 108 | + |
| 109 | +You can edit nodes simply using your systems default editor (as defined by the ``$EDITOR`` environment |
| 110 | +variable). |
| 111 | + |
| 112 | + |
| 113 | +.. code-block:: bash |
| 114 | +
|
| 115 | + PHPCRSH> node:edit cms |
| 116 | +
|
| 117 | +The above will open an editor, e.g. VIM, with a YAML file similar to the following: |
| 118 | + |
| 119 | +.. code-block:: yaml |
| 120 | +
|
| 121 | + 'jcr:primaryType': |
| 122 | + type: Name |
| 123 | + value: 'slinpTest:article' |
| 124 | + title: |
| 125 | + type: String |
| 126 | + value: Home |
| 127 | + tags: |
| 128 | + type: String |
| 129 | + value: [automobiles, trains, planes] |
| 130 | +
|
| 131 | +You can edit the node properties, then save and quit the editor, the node will then be |
| 132 | +updated in the session. |
| 133 | + |
| 134 | +Saving and refreshing the session |
| 135 | +--------------------------------- |
| 136 | + |
| 137 | +Changes made to nodes in the session are not persisted immediately (with the exception |
| 138 | +of ``node:copy`` which is a workspace command). |
| 139 | + |
| 140 | +To persist changes to the repository you must call ``session:save`` (or ``save``). |
| 141 | + |
| 142 | +You can also refresh (or reset) the session by calling ``session:refresh`` (or ``refresh``). |
| 143 | + |
| 144 | +Queries |
| 145 | +------- |
| 146 | + |
| 147 | +PHPCRSH supports the powerfull JCR-SQL2 query language: |
| 148 | + |
| 149 | +.. code-block:: bash |
| 150 | +
|
| 151 | + PHPCRSH > SELECT title FROM slinpTest:article |
| 152 | + +--------------------------------------------+-----------------------------+ |
| 153 | + | Path | slinpTest:article.title | |
| 154 | + +--------------------------------------------+-----------------------------+ |
| 155 | + | /slinp/web/root | Slinp Web Content Framework | |
| 156 | + | /slinp/web/root/home | Home | |
| 157 | + | /slinp/web/root/articles/Faster-than-light | Faster than light | |
| 158 | + +--------------------------------------------+-----------------------------+ |
| 159 | + 3 rows in set (0.01 sec) |
| 160 | + PHPCRSH > SELECT title FROM slinpTest:article WHERE title="Home" |
| 161 | + +----------------------+-------------------------+ |
| 162 | + | Path | slinpTest:article.title | |
| 163 | + +----------------------+-------------------------+ |
| 164 | + | /slinp/web/root/home | Home | |
| 165 | + +----------------------+-------------------------+ |
| 166 | + 1 rows in set (0.04 sec) |
| 167 | +
|
| 168 | +For more information on JCR-SQL2 refer to the articles on the |
| 169 | +`official PHPCR website <http://phpcr.github.io/documentation/>`_. |
| 170 | + |
| 171 | +In addition to SELECT PHPCR Shell supports non-standard UPDATE and DELETE queries: |
| 172 | + |
| 173 | +.. code-block:: bash |
| 174 | +
|
| 175 | + PHPCRSH > DELETE FROM [slinpTest:article] WHERE title="Home" |
| 176 | + 1 row(s) affected in 0.01s |
| 177 | +
|
| 178 | +.. code-block:: bash |
| 179 | +
|
| 180 | + PHPCRSH > UPDATE [slinpTest:article] SET title="Away" WHERE title="Home" |
| 181 | + 1 row(s) affected in 0.01s |
0 commit comments