Download the PHP package yii2tech/filedb without Composer

On this page you can find all versions of the php package yii2tech/filedb. 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 filedb

File DB Extension for Yii 2


This extension provides ActiveRecord interface for the data declared in static files. Such solution allows declaration of static entities like groups, statuses and so on via files, which are stored under version control instead of database.

Note: although this extension allows writing of the data, it is not recommended. You should consider using regular relational database based on SQLite in case you need sophisticated local data storage.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json.

Usage

This extension works similar to regular Yii2 database access layer. First of all you should add a [[\yii2tech\filedb\Connection]] component to your application configuration:

Now you can declare actual entities and their data via files stored under '@app/data/static' path. By default regular PHP code files are used for this, but you can choose different format via [[\yii2tech\filedb\Connection::format]]. Each entity should have a file with corresponding name, like 'UserGroup', 'ItemStatus' etc. So full file names for them would be '/path/to/project/data/static/UserGroup.php', '/path/to/project/data/static/ItemStatus.php' and so on. Each file should return an array containing actual entity data, for example:

In file DB each data row should have a unique field, which identifies it - a primary key. Its name is specified by [[\yii2tech\filedb\Connection::primaryKeyName]]. You may ommit primary key at rows declaration in this case key, under which row is declared in the data array will be used as primary key value. So previous data file example can be rewritten in following way:

Querying Data

You may execute complex query on the data declared in files using [[\yii2tech\filedb\Query]] class. This class works similar to regular [[\yii\db\Query]] and uses same syntax. For example:

Using ActiveRecord

The main purpose of this extension is provide an ActiveRecord interface for the static data. It is done via [[\yii2tech\filedb\ActiveRecord]] and [[\yii2tech\filedb\ActiveQuery]] classes. Particular ActiveRecord class should extend [[\yii2tech\filedb\ActiveRecord]] and override its fileName() method, specifying source data file name. For example:

Note: by default fileName() returns own class base name (without namespace), so if you declare source data file with name equal to the class base name, you can ommit fileName() method overriding.

[[\yii2tech\filedb\ActiveRecord]] works similar to regular [[\yii\db\ActiveRecord]], allowing finding, validation and saving models. It can establish relations to other ActiveRecord classes, which are usually represents entities from relational database. For example:

So relational queries can be performed like following:


All versions of filedb with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version ~2.0.14
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 yii2tech/filedb contains the following files

Loading the files please wait ....