Beruflich Dokumente
Kultur Dokumente
- Lightweight
## Example Usage
```php
<?php
$flatbase->insert()->in('users')
->execute();
$flatbase->read()->in('users')
->first();
```
## Installation
## Usage
### Reading
```php
$flatbase->read()->in('users')->get(); // Flatbase\Collection
```
```php
```
- `=`
- `!=`
- `==`
- `!==`
- `<`
- `>`
```php
$flatbase->read()
->in('users')
->get();
```
```php
```
```php
```php
$flatbase->read()->in('users')->count();
```
### Deleting
```php
$flatbase->delete()->in('users')->execute();
```
```php
```
### Inserting
```php
$flatbase->insert()->in('users')->set([
])->execute();
```
### Updating
```php
```
```php
$flatbase->update()
->in('users')
->execute();
```
`SELECT * FROM posts WHERE views > 500` | `$flatbase->read()->in('posts')->where('views', '>', 500)-
>get();`
Flatbase includes a command line interface `flatbase` for quick manipulation of data outside of your
application.
```bash
```
### Installation
To use the CLI, you must define the path to your storage directory. This can either be done with a
`flatbase.json` file in the directory you call flatbase from (usually your application root):
```json
{
"path": "some/path/to/storage"
```
Alternatively, simply include the `--path` option when issuing commands. Eg:
```bash
```
### Demo
### Usage
```bash
```
For more info on the CLI, use one of the `help` commands
```bash
```
Just add `flatbase/flatbase` to your `composer.json` and you're rolling. No need for any other
services running.
You don't have to worry about defining a schema, writing migration scripts, or any of that other
boring stuff. Just instantiate `Flatbase` and start giving it data. This is particularly useful when
developing/prototyping new features.
```php
$flatbase->insert()->in('users')->set([
'id' => 1,
])->execute();
var_dump($record['added']); // DateTime
```
It also means that you can, at any point, easily unserialize() your data without having to go through
Flatbase if you wish.
> Note: Although serializing is possible, be careful when using this in production. Remember that if
you serialize an object, and then, later on, delete or move the class it was an instance of, you won't
be able to un-serialize it. Storing scalar data is always a safer alternative.
#### It isn't actually that slow
Ok, that's a bit of a baiting title. Some operations are remarkably quick considering this is a flat file
database. On a mediocre Ubuntu desktop development environment, it can process around 50,000
"inserts" in 1 second. No, that is still nowhere near a database like MySQL or Mongo, but it's a hell of
a lot more than most people need.
Reading data out is certainly a lot slower, and although there are lots of places we can optimise,
ultimately you'd need to accept this is never going to be a high-performance solution for
persistence.
## Author
## Contributing