protoqol / quark
A stand-alone - light-weight - no-nonsense - flat-file, database called Quark.
Requires
- php: ^7.2.5
- ext-dom: *
- ext-json: *
- halaxa/json-machine: ^0.7.0
- nesbot/carbon: ^2.49
- symfony/console: ^5.3
- symfony/filesystem: ^5.3
- vlucas/phpdotenv: ^4.0
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-04-12 20:21:03 UTC
README
There is no release for Quark as of yet, the current version is the highly unstable v0.0.0-alpha.
If you are in need of a quick, easy-to-use, sub-atomic database, Quark is for you!
TL;DR.
Quark is an easy-to-use flat-file database, meaning, a database that exists entirely inside a single file. In Quark's case, it uses a minified JSON file for optimal performance and speed. Quark includes a simple yet powerful Query Builder for all your querying needs.
Installation & Quick start
1. Install using the command below.
$ composer require protoqol/quark
2. Initialise the Quark executable using the command below.
$ ./vendor/protoqol/quark/bin/quark install
This will create a file called quark
in your root directory, with this you no longer have to reference the entire path
to use Quark. You can just use ./quark
.
Note: using
./
simply indicates that this script needs to be executed according to its contents, meaning, you can also usephp quark
to execute it as a php script.
3. Initialise quark directory structure.
This will generate the needed directory structure for Quark to function.
$ ./quark init
4. Create a migration.
This will generate a migration file which is used to define a table.
$ ./quark create {TableName}
Migrations can be found in de {root}/quark/migrations directory.
5. Run migrations.
Running this command will migrate all pending migrations to the database.
$ ./quark migrate
6. Using the data.
To use the table data, create a class (use singular pascal-cased version of table name as class name) which
extends Protoqol\Quark\Database\QModel
.
If you want to use a different class name you can overwrite the
public $table
property in your class with the correct table name.
This class will give you a few methods to interact with your data such as:
/** * Returns all available data from table. * Define what columns you need with the $columns parameter. Example: ['id', 'name'], this only returns 'id' & 'name' columns. * * @param array $columns string[] Defaults to all columns. * * @return \Protoqol\Quark\Database\QCollection */ public function all(array $columns = ['*']): \Protoqol\Quark\Database\QCollection /** * Returns first entry from table. * Define what columns you need with the $columns parameter. Example: ['id', 'name'], this only returns 'id' & 'name' columns. * * @param array $columns string[] Defaults to all columns. * * @return \Protoqol\Quark\Database\QCollection */ public function first(array $columns = ['*']): \Protoqol\Quark\Database\QCollection /** * Returns last entry from table. * Define what columns you need with the $columns parameter. Example: ['id', 'name'], this only returns 'id' & 'name' columns. * * @param array $columns string[] Defaults to all columns. * * @return \Protoqol\Quark\Database\QCollection */ public function last(array $columns = ['*']): \Protoqol\Quark\Database\QCollection /** * Creates a new record in your table. Define values in $attributes parameter. * Example: self::create(['name' => 'Cool Name', 'is_active' => true]) * * @param array $attributes * * @return \Protoqol\Quark\Database\QModel */ public function create(array $attributes): \Protoqol\Quark\Database\QModel
These methods can provide a very basic database interaction but are very limited, while Quark is being developed more features will be implemented.
6. Enjoy.
For the complete documentation refer to: {$LINK_HERE}
Issues, bugs and feature requests can be reported here!
Quark in depth
What is Quark?
Note: Quark is not meant to replace any other database but is meant as a developer tool.
Why is Quark a thing?
Where is Quark?
How secure is Quark?
Contributors
License
Quark is licensed under the MIT License. Please see License File for more information.