Permalink
Browse files

Update README.md

  • Loading branch information...
1 parent 6db6fc3 commit 6ace1129b6a80e487e886f1fce8cf2d039785da5 @marcj committed Feb 22, 2014
Showing with 87 additions and 1 deletion.
  1. +87 −1 README.md
View
@@ -11,7 +11,93 @@ Katana ORM is a fork of the glory Propel ORM but with some fundamental changes.
* [ ] Better/Easier “behavior” development (plugins)
* [ ] Entity definition through xml, yml, php, database schema, annotations
* [ ] Removed hard dependencies on SQL databases
- * [ ] With a REST Adapter
+ * [ ] With a REST API Adapter
That all with Propel’s initial **blazing fast approach** of compiling instead of doing always a
database/object introspection, means it will be incredibly fast.
+
+
+Insight
+-------
+
+All following steps can be done without having a external build-time (console command executions).
+
+### Quick-Start:
+
+```php
+# bootstrap
+Katana::setDefaultRepository('mysql', 'localhost', 'root', 'myHeavyPassword');
+Katana::setCompileDirectory('app/cache/');
+Katana::getDefaultRepository()->addObject('Author');
+
+# example
+class Author {
+ use Author\ObjectEncapsulation;
+ use Author\ActiveRecord;
+
+ /**
+ * @Field(type="string")
+ */
+ protected $name;
+}
+
+$author = new Author();
+$author->setName('Hans Zimmer');
+$author->save();
+```
+
+Nothing else to do for you.
+What we do in the background: migrate database' schema and build all necessary traits.
+
+### Reverse
+
+Working with already existing table.
+
+```php
+class Author {
+ use Author\Reverse;
+ use Author\ObjectEncapsulation;
+ use Author\ActiveRecord;
+
+ protected $repositoryContainer = 'authors';
+}
+
+$author = AuthorQuery::create()->findOneByName('Hans Zi');
+$author->setName('Hans Zimmer');
+$author->save();
+```
+
+### Centralized definition
+
+repositories.yml
+```yml
+repositories:
+ default:
+ adapter: mysql
+ host: localhost
+ user: root
+ password: myHeavyPassword
+```
+
+objects.yml
+```yml
+Namespaced\Author:
+ repository: default
+ active_record: false
+ fields:
+ name: string
+ points: integer
+```
+
+```php
+Katana::readRepositoryDefinition('path/to/repositories.yml');
+Katana::readObjectDefinition('path/to/objects.yml');
+
+$authors = Namespaced\AuthorQuery::create()->find();
+foreach ($authors as $author) {
+ $author->setPoints(0);
+}
+
+Katana::getRepository()->flush(); // writes all changes at once
+...
+```

0 comments on commit 6ace112

Please sign in to comment.