Download the PHP package alvin0/database-json-laravel without Composer

On this page you can find all versions of the php package alvin0/database-json-laravel. 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 database-json-laravel

Database Json Laravel - php flat file database based on JSON files Library to use JSON files like a database. Functionality inspired by Eloquent

Requirements

Installation

You can install the package via composer

composer require alvin0/database-json-laravel

Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

'providers' => [
    // ...
    DatabaseJson\DataBaseJsonServiceProvider::class,
];

You should publish the config/databasejson.php config file .

Structure of table files

table_name.data.json - table file with data table_name.config.json - table file with configuration

Basic Usage

I. Create Model and Migration with command line

1. Model

Create model :
php artisan databasejson:model User -m
Optional :
 -m  : Generate a migrate for the given model.
 -f : Create the class even if the model already exists
Code generate

2. Migration

2.1 Create a migration table
php artisan databasejson:migration user --table=users 
Code generate
Optional

The --table option may also be used to indicate the name of the table. the --update option will create migrate with method update table

2.2 Update migrate table

The update only supports adding or removing columns in the table

If you want to delete the table, use this method in the function up() :

DatabaseJson::remove('table_name');
example create migrate type update
php artisan databasejson:migration user --table="users" --update
Code generate
2.3 Run Migrate
php artisan databasejson:migrate
Optional

--fresh : remove all table and up --path : Specify a path

II. Basic Usage

1. Model Conventions

By default, model expects created_at and updated_at columns to exist on your tables. If you do not wish to have these columns automatically managed by Model, set the $timestamps property on your model to false:

2. Inserting & Updating & Delete Models

2.1 Insert

To create a new record in the database, create a new model instance, set attributes on the model, then call the save or use static function create method:

Example

2.2 Update

To create a new record in the database, create a new model instance, set attributes on the model, then call the save or use static function create method:

Example

2.3 Delete

Remove data with constraints

Remove all data in table

3. Retrieving Models

all() -> This is a static function used to retrieve all objects in the model.
find($id) -> This is a static function used to retrieve an object by id in the model.

Adding Additional Constraints

You may add constraints to queries, and then use the get() or paginate($perpage) method to retrieve the results

where() - filter records ( Standard operators =, !=, >, <, >=, <=, like )
orWhere() - other type of filtering results.
orderBy() - sort rows by key in order, can order by more than one field (just chain it).
groupBy() - group rows by field.

Example :

4 Relations

4.1 setup relationship

There are 2 relationships when applied : belongsTo and hasMany

local_key default is id

4.2 Retrieve relationship

5 creating the accessor

5.1Defining An Accessor

To define an accessor, create a getFooAttribute method on your model where Foo is the "studly" cased name of the column you wish to access. In this example, we'll define an accessor for the first_name attribute. The accessor will automatically be called by Eloquent when attempting to retrieve the value of the first_name attribute:

As you can see, the original value of the column is passed to the accessor, allowing you to manipulate and return the value. To access the value of the accessor, you may access the first_name attribute on a model instance:

5.2 Appending Values

After creating the accessor, add the attribute name to the appends property on the model. Note that attribute names are typically referenced in "snake case", even though the accessor is defined using "camel case":

Description

More informations you can find in PHPDoc, I think it's documented very well.

This is a development project from the Lazer-Database project :link https://github.com/Greg0/Lazer-Database


All versions of database-json-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.0
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 alvin0/database-json-laravel contains the following files

Loading the files please wait ....