Skip to content

Created PHPCR-Shell documentation #12

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

Merged
merged 3 commits into from
Aug 18, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ Welcome to PHPCR's documentation!
Contents:

.. toctree::
:maxdepth: 2
:maxdepth: 1

book/index


phpcr-shell/index

Indices and tables
==================
Expand Down
132 changes: 132 additions & 0 deletions phpcr-shell/connecting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
Connecting
==========

Manually
--------

.. note::

The following sections detail how to create a connection, you should
however only do this once and create a profile. With a profile you
can reuse connection settings, see :ref:`phpcrsh_profile`.

Jackrabbit
~~~~~~~~~~

The following should work with the default

.. code-block:: bash

$ phpcrsh --transport=jackrabbit

Parameters:

- **repo-url**: URL for server, default ``http://localhost:8080/server``

Doctrine-Dbal
~~~~~~~~~~~~~

General connections
"""""""""""""""""""

The following is the minimal required to connect to a MySQL database:

.. code-block:: bash

$ phpcrsh --transport=doctrine-dbal --db-name="mydb"

Parameters:

- **db-name**: Name of database to connect to
- **db-user**: Username for database, default ``root``
- **db-password**: Password for datanase, default empty
- **db-host**: Host for database, default ``localhost``
- **db-path**: Path to sqlite database

Connect to Sqlite database
""""""""""""""""""""""""""

.. code-block:: bash

$ phpcrsh --transport=doctrine-dbal --db-path=/path/to/app.sqlite

More settings
~~~~~~~~~~~~~

For a full list of settings run:

.. code-block:: bash

$ phpcrsh --help

.. _phpcrsh_profile:

Profiles
--------

You can create or use a profile using a single option, `--profile` or `-p` for short.

For example:

.. code-block:: bash

$ phpcrsh -pmyapp --transport=doctrine-dbal --db-path=/path/to/app.sqlite

Will *create* a profile called ``myapp``. Profiles are stored as YAML files in
``$HOME:./.phpcrsh/profiles/<profilename>``. And can be manually edited.

To select a profile launch PHPCRSH without any arguments

.. code-block:: bash

$ phpcrsh
No connection parameters, given. Select an existing profile:

(0) dtlweb
(1) ezcmf
(2) jackrabbit
(3) ratest
(4) slinp_test
(5) slinptest
(6) sulucmf

Enter profile number: []

To explicitly use a profile use the `-p` option again:

.. code-block:: bash

$ phpcrsh --profile ratest
# or
$ phpcrsh -pratest

.. note::

A profile is only created if the ``transport`` option is set.

Connect to an embedded PHPCR shell
----------------------------------

This is the easiest way to connect if you have are developing a Symfony 2 application

See :ref:`phpcrsh-installation-embedded-application`.

You can then connect simply using:

.. code-block:: bash

$ php app/console phpcr:shell

And you can execute specific commands:

.. code-block:: bash

$ php app/console phpcr:shell node:list /cms

Queries or commands with options must be escapted due to limitations with the Symfony
console component:

.. code-block:: bash

$ php app/console phpcr:shell "SELECT * FROM [nt:unstructured]"
$ php app/console phpcr:shell "node:list -L2"
8 changes: 8 additions & 0 deletions phpcr-shell/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PHPCR-Shell
===========

.. toctree::
:maxdepth: 2

installation
connecting
69 changes: 69 additions & 0 deletions phpcr-shell/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Installation
============

You can install PHPCR Shell either as an embedded application or as a PHAR, or
you can built it your self (for instance if you want the latest version).

.. _phpcrsh-connecting-installation-as-phar:

Install as a PHAR
-----------------

The latest release can be downloaded from the `Github releases page
<https://github.com/doctrine/DoctrinePHPCRBundle/>`_.

After downloading it it is recommended to install it in a path accessible
by the system, for example:

.. code-block:: bash

$ sudo mv phpcrsh.sh /usr/local/bin/phpcrsh
$ sudo chmod a+x /usr/local/bin/phpcrsh

You can now run PHPCRSH from anywhere:

.. code-block:: bash

$ phpcrsh --help

.. _phpcrsh-installation-embedded-application:

Install as an embedded application
----------------------------------

If you are using a Symfony2 application and the `DoctrinePHPCRBundle <https://github.com/doctrine/DoctrinePHPCRBundle/>`_
then you can easily integrate the 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.

maybe we should say: "DoctrinePHPCRBundle version 1.2 or newer"


Simply add the shell to your ``composer.json`` file

.. code-block:: javascript

{
...
require: {
...
"phpcr-shell": "<lastest version here>"
}
...
}

And you can connect directly:

.. code-block:: bash

$ php app/console phpcr:shell

Build it from source
--------------------

PHPSH uses the box PHAR building tool, install it `here <http://box-project.org>`_.

Build the PHAR:

.. code-block:: bash

$ cd phpcr-shell
$ box build

This will produce the file ``phpcr.phar``, see :ref:`phpcrsh-connecting-installation-as-phar` for
further instructions.