From 534ab8e66e4fc1701ad89838d8e85ac46704b32a Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Sat, 29 Nov 2014 19:03:09 +0100 Subject: [PATCH] update doc --- doc/concept/api_versioning.rst | 8 ++++++-- doc/concept/table.rst | 15 +++++++++++++-- doc/design/command.rst | 26 +++++++++++++++++++++++--- doc/design/controller.rst | 13 +++++++++++++ 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/doc/concept/api_versioning.rst b/doc/concept/api_versioning.rst index 0048df33..be22f668 100644 --- a/doc/concept/api_versioning.rst +++ b/doc/concept/api_versioning.rst @@ -26,10 +26,12 @@ Url versioning The most easiest solution to versioning is to simply provide multiple routes to an API i.e. +.. code-block:: none + GET /api/v1/news Acme\News\Lion\Api GET /api/v2/news Acme\News\Zebra\Api -While this is easy to implement it hast the disadvantage that you have multiple +While this is easy to implement it has the disadvantage that you have multiple presentations for the same resource. I.e. /api/v1/news and /api/v2/news represent the same resource but in different formats @@ -39,6 +41,8 @@ Accept-Header versioning PSX comes with support to handle API versioning throught the Accept header field. That means you must specify an explicit version in the Accept header i.e. +.. code-block:: none + Accept: application/vnd.foobar.v2+json In the following a short example howto add versioning to an schema API @@ -60,7 +64,7 @@ In the following a short example howto add versioning to an schema API { public function getSchemaDocumentation() { - $documentation = new Documentation\Version(); + $documentation = new Documentation\Version(); $responseSchema = $this->schemaManager->getSchema('Foo\Blog\Schema\SuccessMessage'); $view = new View(View::STATUS_DEPRECATED); diff --git a/doc/concept/table.rst b/doc/concept/table.rst index 05d5fff9..807727e6 100644 --- a/doc/concept/table.rst +++ b/doc/concept/table.rst @@ -7,7 +7,7 @@ Abstract The PSX table classes offern an alternative to an ORM. Each table class represents an sql table. The table class contains the table name and all -available columns. It is also the place where you put all complex business +available columns. It is also the place where you can put all complex business queries like in an repository. To get an first impression here an example: .. code-block:: php @@ -77,7 +77,7 @@ fictional method which returns the best comments { // ... - public function getBestComments($userId) + public function getBestCommentsByUser($userId) { $sql = ' SELECT id, title, @@ -94,3 +94,14 @@ fictional method which returns the best comments )); } } + +Generation +---------- + +It is possible to generate such table classes from an sql table. Therefor you +can use the following command + +.. code:: + + $ ./vendor/bin/psx generate:table Acme\Table\Comment psx_handler_comment + diff --git a/doc/design/command.rst b/doc/design/command.rst index 3fdaccbe..522c6993 100644 --- a/doc/design/command.rst +++ b/doc/design/command.rst @@ -78,9 +78,29 @@ required parameter is missing an exception gets thrown. $this->executor->run(new Map('Foo\Bar\Command', array('bar' => 'foo'))); -It is also possible to invoke the command through the console +It is also possible to invoke the command through the console. Therefor you have +to pass the parameters as arguments -.. code-block:: none +.. code:: - vendor\bin\psx Foo\Bar\Command -bar foo + $ ./vendor/bin/psx command Foo\Bar\Command bar:foo + +You could also pipe the parameters as JSON string through stdin with the "-s" +switch + +.. code:: + + $ echo {"bar": "foo"} | ./vendor/bin/psx command -s Foo\Bar\Command + +Generation +---------- + +It is possible to generate an command template. You can use the following +command which takes as first argument the class name and as second a comma +seperated list with service names. These services are automatically included in +the command + +.. code:: + + $ ./vendor/bin/psx generate:command Acme\Command connection,http diff --git a/doc/design/controller.rst b/doc/design/controller.rst index 5057298b..456aded0 100644 --- a/doc/design/controller.rst +++ b/doc/design/controller.rst @@ -60,3 +60,16 @@ Usage )); } } + +Generation +---------- + +It is possible to generate an controller template. You can use the following +command which takes as first argument the class name and as second a comma +seperated list with service names. These services are automatically included in +the controller + +.. code:: + + $ ./vendor/bin/psx generate:controller Acme\Controller connection,http +