-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from NeroReflex/development
Development
- Loading branch information
Showing
135 changed files
with
12,267 additions
and
19,509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
# CLI Toolkit | ||
Gishiki uses a CLI toolkit to speed up development and code generation. | ||
|
||
The executable resides under the ./vendor/bin/ directory, and is called | ||
gishiki. | ||
|
||
It accept an arbitrary number of arguments, but the first one is the action | ||
you want to perform: | ||
|
||
```sh | ||
./vendor/bin/gishiki <action> [param 1] [param2] [param3] #and so on..... | ||
``` | ||
|
||
The number of parameters following the action depends on the action you want to | ||
perform. | ||
|
||
|
||
## Application Creation | ||
To bootstrap a new application the command is fixed: | ||
|
||
```sh | ||
./vendor/bin/gishiki init | ||
``` | ||
|
||
This will create a basic and empty application that uses an sqlite3 database, | ||
has a randomly-generated RSA private key, and an empty SQLite3 database. | ||
|
||
The application can be executed immediately if ext-pdo_sqlite is installed. | ||
|
||
|
||
## Controller Creation | ||
To bootstrap a new controller the command requires controller name: | ||
|
||
```sh | ||
./vendor/bin/gishiki new-controller ControllerName | ||
``` | ||
|
||
# CLI Toolkit | ||
Gishiki uses a CLI toolkit to speed up development and code generation. | ||
|
||
The executable resides under the ./vendor/bin/ directory, and is called | ||
gishiki. | ||
|
||
It accept an arbitrary number of arguments, but the first one is the action | ||
you want to perform: | ||
|
||
```sh | ||
./vendor/bin/gishiki <action> [param 1] [param2] [param3] #and so on..... | ||
``` | ||
|
||
The number of parameters following the action depends on the action you want to | ||
perform. | ||
|
||
|
||
## Application Creation | ||
To bootstrap a new application the command is fixed: | ||
|
||
```sh | ||
./vendor/bin/gishiki init | ||
``` | ||
|
||
This will create a basic and empty application that uses an sqlite3 database, | ||
has a randomly-generated RSA private key, and an empty SQLite3 database. | ||
|
||
The application can be executed immediately if ext-pdo_sqlite is installed. | ||
|
||
|
||
## Controller Creation | ||
To bootstrap a new controller the command requires controller name: | ||
|
||
```sh | ||
./vendor/bin/gishiki new-controller ControllerName | ||
``` | ||
|
||
This will create a basic controller with a small example piece of code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
# CRUD | ||
The acronym __CRUD__ stands for Create, Read, Update and Delete: those are names | ||
of main operations you will be allowed (directly or indirectly) to perform on | ||
databases that are supporting your application. | ||
|
||
__Notice that:__ if you only need read permissions from a database such as | ||
PostgreSQL or MySQL, you do __NOT__ need to use an user with full access. | ||
|
||
## Create | ||
The creation of a new *document*/*row* either starts from a __CollectionInterface__, | ||
such as __SerializableCollection__ or a native PHP array. | ||
|
||
The function that has to be called is __create__ that also requires the name of | ||
the *table*/*collection* to be affected: | ||
|
||
```php | ||
use Gishiki\Database\DatabaseManager; | ||
|
||
$connection = DatabaseManager::retrieve('connectionName'); | ||
|
||
$idOfNewDocument = $connection->create('tbname', new SerializableCollection([ | ||
'name' => $name, | ||
'surname' => $surname, | ||
'nickname' => $nickname, | ||
'password' => $hash //it is NOT good to store plain passwords | ||
])); | ||
``` | ||
|
||
Where the name of the connection is the same name in the application [configuration](configuration.md). | ||
|
||
## Delete | ||
To delete a restricted set of *documents*/*rows* from a *table*/*collection* | ||
you have to call, on the desired database connection the __delete__ function. | ||
|
||
The delete function needs the name of the table/collection to be affected and | ||
a valid instance of SelectionCriteria: | ||
|
||
```php | ||
use Gishiki\Database\DatabaseManager; | ||
use Gishiki\Database\Runtime\SelectionCriteria; | ||
use Gishiki\Database\Runtime\FieldRelation; | ||
|
||
$connection = DatabaseManager::retrieve('connectionName'); | ||
|
||
$connection->delete('tbname', SelectionCriteria::select([ | ||
'nickname' => $nickname | ||
])->OrWhere('email', FieldRelation::EQUAL, $email) | ||
); | ||
``` | ||
|
||
You can also delete __EVERY__ *documents*/*rows* from a *table*/*collection* | ||
using the __deleteAll__ function. | ||
|
||
The delete function only needs the name of the table/collection to be affected: | ||
|
||
```php | ||
use Gishiki\Database\DatabaseManager; | ||
use Gishiki\Database\Runtime\SelectionCriteria; | ||
use Gishiki\Database\Runtime\FieldRelation; | ||
|
||
$connection = DatabaseManager::retrieve('connectionName'); | ||
|
||
$connection->deleteAll('tbname'); | ||
``` | ||
|
||
__Note that:__ calling the delete function, passing an empty SelectionCriteria | ||
object has the same effect of calling deleteAll, however deleteAll will perform | ||
# CRUD | ||
The acronym __CRUD__ stands for Create, Read, Update and Delete: those are names | ||
of main operations you will be allowed (directly or indirectly) to perform on | ||
databases that are supporting your application. | ||
|
||
__Notice that:__ if you only need read permissions from a database such as | ||
PostgreSQL or MySQL, you do __NOT__ need to use an user with full access. | ||
|
||
## Create | ||
The creation of a new *document*/*row* either starts from a __CollectionInterface__, | ||
such as __SerializableCollection__ or a native PHP array. | ||
|
||
The function that has to be called is __create__ that also requires the name of | ||
the *table*/*collection* to be affected: | ||
|
||
```php | ||
use Gishiki\Database\DatabaseManager; | ||
|
||
$connection = DatabaseManager::retrieve('connectionName'); | ||
|
||
$idOfNewDocument = $connection->create('tbname', new SerializableCollection([ | ||
'name' => $name, | ||
'surname' => $surname, | ||
'nickname' => $nickname, | ||
'password' => $hash //it is NOT good to store plain passwords | ||
])); | ||
``` | ||
|
||
Where the name of the connection is the same name in the application [configuration](configuration.md). | ||
|
||
## Delete | ||
To delete a restricted set of *documents*/*rows* from a *table*/*collection* | ||
you have to call, on the desired database connection the __delete__ function. | ||
|
||
The delete function needs the name of the table/collection to be affected and | ||
a valid instance of SelectionCriteria: | ||
|
||
```php | ||
use Gishiki\Database\DatabaseManager; | ||
use Gishiki\Database\Runtime\SelectionCriteria; | ||
use Gishiki\Database\Runtime\FieldRelation; | ||
|
||
$connection = DatabaseManager::retrieve('connectionName'); | ||
|
||
$connection->delete('tbname', SelectionCriteria::select([ | ||
'nickname' => $nickname | ||
])->OrWhere('email', FieldRelation::EQUAL, $email) | ||
); | ||
``` | ||
|
||
You can also delete __EVERY__ *documents*/*rows* from a *table*/*collection* | ||
using the __deleteAll__ function. | ||
|
||
The delete function only needs the name of the table/collection to be affected: | ||
|
||
```php | ||
use Gishiki\Database\DatabaseManager; | ||
use Gishiki\Database\Runtime\SelectionCriteria; | ||
use Gishiki\Database\Runtime\FieldRelation; | ||
|
||
$connection = DatabaseManager::retrieve('connectionName'); | ||
|
||
$connection->deleteAll('tbname'); | ||
``` | ||
|
||
__Note that:__ calling the delete function, passing an empty SelectionCriteria | ||
object has the same effect of calling deleteAll, however deleteAll will perform | ||
a little better! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
# Database | ||
|
||
Gishiki is developed to reflect the MVC pattern: this means that the data lifecycle | ||
is a foundamental characteristic within the framework! | ||
|
||
Data persistence, coherence and integrity is managed by the database manager. | ||
|
||
To connect a database manager you have to edit the active [configuration](configuration.md). | ||
|
||
There isn't a limit to the number of database connection, but each one __MUST__ | ||
have a name, and there __CANNOT__ be two connections with the same name. | ||
|
||
|
||
## Connecting Database | ||
|
||
A database connection have the following form: | ||
|
||
``` | ||
adapter://adapter_manageable_conenction_query | ||
``` | ||
|
||
where the connection query is a string that the adapter can parse. | ||
|
||
### MongoDB | ||
|
||
A MongoDB connection can be enstabilished by using the mongodb adapter bundled | ||
with Gishiki. | ||
|
||
The MongoDB adapter uses the mongodb php native extension: Composer calls it | ||
[ext-mongodb](https://pecl.php.net/package/mongodb): | ||
|
||
``` | ||
mongodb://username:password@host:port/dbname | ||
``` | ||
|
||
|
||
## Differences between databases | ||
|
||
Each database manager has different characteristics: Gishiki aims to preserve | ||
strong points of each one, but miracles are not possibles: everything comes to | ||
a price. | ||
|
||
Following are __RULES__ you __MUST__ follow when designing database tables. | ||
|
||
- The name must be the plural form of the name of object to store | ||
- The name must be written in underscore_case with no UPPER characters | ||
- The unique id field (when possible) must be called _id | ||
|
||
|
||
## Operations on Databases | ||
|
||
To understand how to interact with the database you have to read the [CRUD](CRUD.md) | ||
# Database | ||
|
||
Gishiki is developed to reflect the MVC pattern: this means that the data lifecycle | ||
is a foundamental characteristic within the framework! | ||
|
||
Data persistence, coherence and integrity is managed by the database manager. | ||
|
||
To connect a database manager you have to edit the active [configuration](configuration.md). | ||
|
||
There isn't a limit to the number of database connection, but each one __MUST__ | ||
have a name, and there __CANNOT__ be two connections with the same name. | ||
|
||
|
||
## Connecting Database | ||
|
||
A database connection have the following form: | ||
|
||
``` | ||
adapter://adapter_manageable_conenction_query | ||
``` | ||
|
||
where the connection query is a string that the adapter can parse. | ||
|
||
### MongoDB | ||
|
||
A MongoDB connection can be enstabilished by using the mongodb adapter bundled | ||
with Gishiki. | ||
|
||
The MongoDB adapter uses the mongodb php native extension: Composer calls it | ||
[ext-mongodb](https://pecl.php.net/package/mongodb): | ||
|
||
``` | ||
mongodb://username:password@host:port/dbname | ||
``` | ||
|
||
|
||
## Differences between databases | ||
|
||
Each database manager has different characteristics: Gishiki aims to preserve | ||
strong points of each one, but miracles are not possibles: everything comes to | ||
a price. | ||
|
||
Following are __RULES__ you __MUST__ follow when designing database tables. | ||
|
||
- The name must be the plural form of the name of object to store | ||
- The name must be written in underscore_case with no UPPER characters | ||
- The unique id field (when possible) must be called _id | ||
|
||
|
||
## Operations on Databases | ||
|
||
To understand how to interact with the database you have to read the [CRUD](CRUD.md) | ||
chapter of this tutorial. |
Oops, something went wrong.