Download the PHP package timokoerber/laravel-json-seeder without Composer

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

Laravel JSON Seeder

Laravel JSON Seeder

Create and use JSON files to seed your database in your Laravel applications.

This package works both ways!

Installation

Require this package with composer. It is recommended to only require the package for development.

Next you need to publish the config file and register the required commands with ...

This will create the file config/jsonseeder.php where you can find the configurations.

Next add the JsonSeederServiceProvider to the providers array in config/app.php ...

Creating JSON seeds from database

Laravel JSON Seeder - Creating JSON seeds from database

Of course you can create the JSON files manually. But if you already have a good development database, you can easily export it into JSON seeds.

You can create seeds for every table in your database by calling ...

This will create one JSON file for watch table in your database (i.e. table users -> users.json, table posts -> posts.json, etc.).

If you only want to create a seed of one specific table (i.e. users), call ...

Existing files won't be overwritten by default. If you call the command again, a sub-directory will be created and the JSON seeds will be stored there. If you want to overwrite the existing seeds, use the overwrite option like ...

or just use the command ...

Seeding

Laravel JSON Seeder - Seeding

Go to your databas/seeds/DatabaseSeeder.php and add the JsonSeeder inside the run() method like this ...

You can now call the JSON Seeder with the usual Artisan command ...

Settings & Configurations

Directory

By default your seeds will be written into or read from the directory /database/json. If you want a different directory, you can add the environment variable JSON_SEEDS_DIRECTORY in your .env file ...

Ignoring tables

Some tables in your database might not require any seeds. If you want to ignore these tables, you can put them into the setting ignore-tables in the /config.jsonseeder.php

If a table in your database is empty, the LaravelJsonSeeder will create a JSON file with an empty array by default. This might be useful if you want your seeds to truncate this table. If you don't want this, you can change the setting ignore-empty-tables in config/jsonseeder.php, so no JSON seed will be created.

Important!!! Do not forget to clear the cache after editing the config file: php artisan cache:clear

Environments

The environment variable JSON_SEEDS_DIRECTORY might be useful if you are using seeds in Unit Tests and want to use different seeds for this.

Development

Testing

Errors & Warnings

jsonseeder-errors

Error Type Solution
Table does not exist! Error The name of the JSON file does not match any table. Check the filename or create the table.
JSON syntax is invalid! Error The JSON text inside the file seems to be invalid. Check if the JSON format is correct.
Exception occured! Check logfile! Error There seems to be a problem with the Database. Check your system and your default logfile.
JSON file is empty! Error The JSON file is completely empty, which makes it useless. If it should truncate the table, provide an empty array []. Otherwise delelte it.
JSON file has no rows! Warning The JSON file contains only an empty array []. This results in a truncated table and might not be intended.
Missing fields! Warning At least one row in the JSON file is missing a field, that is present in the database table. Check for typos or provide it in the JSON file.
Unknown fields! Warning At least one row in the JSON file has a field that does not exist in the database. Check for typos or make sure to add it to the database table.

License

Copyright © Timo Körber

Laravel JSON Seeder is open-sourced software licensed under the MIT license.


All versions of laravel-json-seeder with dependencies

PHP Build Version
Package Version
No informations.
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 timokoerber/laravel-json-seeder contains the following files

Loading the files please wait ....