Skip to content

Commit c29b458

Browse files
committed
Added configuration and interactiving secrions
1 parent 9d9bb99 commit c29b458

File tree

3 files changed

+277
-0
lines changed

3 files changed

+277
-0
lines changed

phpcr-shell/configuration.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
Configuration
2+
=============
3+
4+
Initialization and reloading
5+
----------------------------
6+
7+
The configuration files can be initialized and reloaded at any time using:
8+
9+
.. code-block:: bash
10+
11+
PHPCRSH> shell:config:init
12+
PHPCRSH> shell:config:reload
13+
14+
At time of writing the only configuration file affected by these commands is
15+
the ``aliases.yml`` file detailed below.
16+
17+
.. _phpcrsh_configuration_aliases:
18+
19+
Aliases
20+
-------
21+
22+
PHPCRSH supports aliases. Aliases are shortcuts for commands.
23+
24+
Aliases are stored in the file ``$HOME/.phpcrsh/aliases.yml``, which is created
25+
automatically when launching the PHPCR Shell.
26+
27+
Below is the distribution version of this file at time of writing:
28+
29+
.. code-block:: yaml
30+
31+
# Shell shortcuts
32+
aliases: shell:alias:list
33+
creload: shell:config:reload
34+
cinit: shell:config:init
35+
36+
# MySQL commands
37+
use: workspace:use {arg1}
38+
explain: node-type:show {arg1}
39+
40+
# Filesystem commands
41+
cd: shell:path:change {arg1}
42+
rm: node:remove {arg1}
43+
mv: node:move {arg1} {arg2}
44+
pwd: shell:path:show
45+
exit: shell:exit
46+
47+
# Node commands
48+
ls: node:list {arg1}
49+
ln: node:clone {arg1} {arg2} # symlink, as in ln -s
50+
cp: node:copy {arg1} {arg2}
51+
cat: node:property:show {arg1}
52+
touch: node:property:set {arg1} {arg2} {arg3}
53+
mkdir: node:create {arg1} {arg2}
54+
55+
# Node type commands
56+
mixins: node-type:list "^mix:"
57+
nodetypes: node-type:list {arg1}
58+
ntedit: node-type:edit {arg1}
59+
ntshow: node-type:show {arg1}
60+
61+
# Workspace commands
62+
workspaces: workspace:list
63+
64+
# Namespsce commands
65+
namespaces: workspace:namespace:list {arg1}
66+
nsset: workspace:namespace:register
67+
68+
# Editor commands
69+
vi: node:edit {arg1} {arg2}
70+
vim: node:edit {arg1} {arg2}
71+
nano: node:edit {arg1} {arg2}
72+
73+
# GNU commands
74+
man: help {arg1}
75+
76+
# Version commands
77+
checkin: version:checkin {arg1}
78+
ci: version:checkin {arg1}
79+
co: version:checkout {arg1}
80+
checkout: version:checkout {arg1}
81+
cp: version:checkpoint {arg1}
82+
checkpoint: version:checkpoint {arg1}
83+
vhist: version:history {arg1}
84+
versions: version:history {arg1}
85+
86+
# Session commands
87+
save: session:save
88+
refresh: session:refresh
89+
90+
For a full reference enter in the shell:
91+
92+
.. code-block:: bash
93+
94+
PHPCRSH> shell:alias:list

phpcr-shell/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ PHPCR-Shell
66

77
installation
88
connecting
9+
interacting
10+
configuration

phpcr-shell/interacting.rst

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
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

Comments
 (0)