Skip to content

Commit

Permalink
Update readme and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Dec 28, 2015
1 parent 41f4a34 commit 4c7c389
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 116 deletions.
62 changes: 11 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

# Crud View

Automated admin backend based on your Crud configuration.

This project is in early stage of development, do not use it production unless you want to get down and dirty on the code :)
Automated admin backend based on your [Crud](https://github.com/friendsofcake/crud) configuration.

# Installation

Expand All @@ -20,58 +18,20 @@ composer require friendsofcake/crud-vew:dev-master

## Documentation

You can find the WIP detailed usage documentation [here](http://crud-view.readthedocs.org/en/latest/).

### Quick Start

1) Install the plugin using `composer require --prefer-dist friendsofcake/crud-view:dev-master`.

2) Add ``Plugin::load('Crud');``, ``Plugin::load('CrudView');`` & ``Plugin::load('BootstrapUI');`` to your ``app/config/bootstrap.php``

3) Configure [Crud](http://crud.readthedocs.org/en/latest/quick-start.html) as per your needs.
You can find detailed usage documentation [here](http://crud-view.readthedocs.org/en/latest/).

4) Change ``AppController::$viewClass`` to ``CrudView\View\CrudView``
# Bugs

5) Load the ``CrudView.View``, ``Crud.RelatedModels`` and ``Crud.Redirect`` listeners.
If you happen to stumble upon a bug, please feel free to create a pull request with a fix
(optionally with a test), and a description of the bug and how it was resolved.

6) Hopefully going to ``/<your controller with crud enabled/`` should just work.
You can also create an issue with a description to raise awareness of the bug.

### Example controller
# Features

```php
<?php
namespace App\Controller;
If you have a good idea for a Crud feature, please join us on IRC and let's discuss it. Pull
requests are always more than welcome.

use Cake\Controller\Controller;
use Crud\Controller;
use Crud\Controller\ControllerTrait;
# Support / Questions

class AppController extends Controller
{
use ControllerTrait;

public function initialize()
{
parent::initialize();

$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');

$this->viewClass = 'CrudView\View\CrudView';
$this->loadComponent('Crud.Crud', [
'actions' => [
'Crud.Index',
'Crud.Add',
'Crud.Edit',
'Crud.View',
'Crud.Delete',
],
'listeners' => [
'CrudView.View',
'Crud.RelatedModels',
'Crud.Redirect',
],
]);
}
}
```
You can join us on IRC in the #FriendsOfCake freenode channel for any support or questions.
1 change: 1 addition & 0 deletions docs/contents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ Contents

index
installation
quick-start
basic-usage
customizing-templates
65 changes: 0 additions & 65 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,68 +36,3 @@ Execute the following lines from your application folder:
bin/cake plugin load CrudView
bin/cake plugin load BootstrapUI
bin/cake plugin load Search
Configuring the AppController
-----------------------------

I you haven't configured the CRUD plugin already add the following line to your
``src/Controller/AppController.php`` file

.. code-block:: php
<?php
namespace App\Controller;
class AppController extends \Cake\Controller\Controller
{
use \Crud\Controller\ControllerTrait;
public function initialize()
{
$this->viewClass = 'CrudView\View\CrudView';
$this->loadComponent('Crud.Crud', [
'actions' => [
'Crud.Index',
'Crud.View',
'Crud.Add',
'Crud.Edit',
'Crud.Delete',
'Crud.Lookup',
],
'listeners' => [
'CrudView.View',
'Crud.Redirect',
'Crud.RelatedModels',
'CrudView.Search',
]
]);
}
}
If you are familair with the CRUD plugin already, you will immediately understand
that Crud view is simply a listener for the events generated by the plugin. If
this is new to you, don't worry, it will be explained in the following sections.

Using It In Your Controllers
----------------------------

Any controller inheriting from ``AppController`` will automatically implement
the specified actions loaded int the ``CRUD`` component configuration.
Therefore, you can just leave your controller code empty!

.. code-block:: php
<?php
namespace App\Controller;
class CategoriesController extends AppController
{
// No code here, but we have all actions available to use!
}
View the Results
----------------

You can now access your categories list by pointing your browser to
``http://example.com/categories``. Browse around your new Admin interface for
each of the controllers you have in your application.
82 changes: 82 additions & 0 deletions docs/quick-start.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Quick Start
-----------

You are busy, and you just want to ``get things done™``, so let's get going.

After :doc:`installation<installation>`, you are ready to CRUD-ify your app.

App Controller
~~~~~~~~~~~~~~

First, configure the `Crud <http://crud.readthedocs.org/en/latest/quick-start.html>`_ plugin.

Configuring the AppController
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you haven't configured the CRUD plugin already, add the following lines to your
``src/Controller/AppController.php`` file

.. code-block:: php
<?php
namespace App\Controller;
class AppController extends \Cake\Controller\Controller
{
use \Crud\Controller\ControllerTrait;
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->viewClass = 'CrudView\View\CrudView';
$this->loadComponent('Crud.Crud', [
'actions' => [
'Crud.Index',
'Crud.View',
'Crud.Add',
'Crud.Edit',
'Crud.Delete',
'Crud.Lookup',
],
'listeners' => [
// New listeners that need to be added:
'CrudView.View',
'Crud.Redirect',
'Crud.RelatedModels',
'CrudView.Search',
]
]);
}
}
If you are familair with the CRUD plugin already, you will immediately understand
that Crud view is simply a listener for the events generated by the plugin. If
this is new to you, don't worry, it will be explained in the following sections.

Using It In Your Controllers
----------------------------

Any controller inheriting from ``AppController`` will automatically implement
the specified actions loaded int the ``CRUD`` component configuration.
Therefore, you can just leave your controller code empty!

.. code-block:: php
<?php
namespace App\Controller;
class CategoriesController extends AppController
{
// No code here, but we have all actions available to use!
}
View the Results
----------------

You can now access your categories list by pointing your browser to
``http://example.com/categories``. Browse around your new Admin interface for
each of the controllers you have in your application.

0 comments on commit 4c7c389

Please sign in to comment.