Download the PHP package flatbase/flatbase without Composer

On this page you can find all versions of the php package flatbase/flatbase. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package flatbase

Flatbase

Flatbase is a flat file database written in PHP which aims to be:

Example Usage

Installation

composer require flatbase/flatbase

Usage

Reading

Fetch all the records from a collection:

Reading only data matching a certain criteria:

We support all the comparison operators you'd expect:

You can chain as many where() conditions as you like:

Limit the returned records:

Sort the records:

Just get a count of records:

Deleting

Delete all records in a collection:

Or just some records:

Inserting

Updating

Update all records in a collection:

Or just some records:

SQL Cheat Sheet

SQL Statement Flatbase Query
SELECT * FROM posts $flatbase->read()->in('posts')->get();
SELECT * FROM posts LIMIT 0,1 $flatbase->read()->in('posts')->first();
SELECT * FROM posts WHERE id = 5 $flatbase->read()->in('posts')->where('id', '==', 5)->get();
SELECT * FROM posts WHERE views > 500 $flatbase->read()->in('posts')->where('views', '>', 500)->get();
SELECT * FROM posts WHERE views > 50 AND id = 5 $flatbase->read()->in('posts')->where('views', '>', 50)->where('id', '==', '5')->get();
UPDATE posts SET title = 'Foo' WHERE content = 'bar' $flatbase->update()->in('posts')->set(['title' => 'var'])->where('content', '==', 'bar')->execute();
DELETE FROM posts WHERE id = 2 $flatbase->delete()->in('posts')->where('id', '==', 2)->execute();
INSERT INTO posts SET title='Foo', content='Bar' $flatbase->insert()->in('posts')->set(['title' => 'Foo', 'content' => 'Bar')->execute();

Command Line Interface

Flatbase includes a command line interface flatbase for quick manipulation of data outside of your application.

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):

Alternatively, simply include the --path option when issuing commands. Eg:

Demo

Usage

For more info on the CLI, use one of the help commands

Why use a flat file database?

What are some of the advantages of a flat file database?

It's really easy to get started

Just add flatbase/flatbase to your composer.json and you're rolling. No need for any other services running.

It's schema-less

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.

Store plain old PHP objects

Data is stored in a native PHP serialized array using PHPSerializer. This means that you can store plain old PHP objects straight to the database:

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

Adam Nicholson - [email protected]

Contributing

Contributions are welcome, and they can be made via GitHub issues or pull requests.

License

Flatbase is licensed under the MIT License - see the LICENSE.txt file for details


All versions of flatbase with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
php-serializer/php-serializer Version 0.1.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package flatbase/flatbase contains the following files

Loading the files please wait ....