Download the PHP package lanin/laravel-extend-seeder without Composer

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

Laravel-Extend-Seeder

Travis

Extend Laravel seeder and populate your DB with CSV data.

Installation

PHP 5.4+ or HHVM 3.3+, Composer and Laravel 5.0+ are required.

To get the latest version of Laravel-Extend-Seeder, simply add the following line to the require block of your composer.json file.

You'll then need to run composer install or composer update to download it and have the autoloader updated.

Once it was installed you don't have to register any ServiceProvider, Facade or publish any configs.

All you have to do is to extend your base Seeder class with \Lanin\ExtendSeeder\Seeder and you are good to go!

Preparing

Every time you try to seed lots of data, you have to unguard your models. Now you don't have to do it. They will be unguarded automatically in the boot method, that fires right on the start. Also it will disable query log, that extremely slows data import.

Environment protection

If you are afraid to corrupt your production database with seeding it with test data, even if artisan asks you if you want to do it, you can specify protected $environment variable in your seeder. Boot method will check if current environment doesn't match the set one and throw an exception, so you can be sure you don't break your production data.

Seeding

After you extended your base seeder, you will receive two additional methods

seedModel($model)

The best place for this method is the run method of your main DatabaseSeeder.

By default you have to fire call method that will resolve a specified seeder as {$tableName}TableSeeder and launch it, and there resolve your models and do all the stuff.

This method will do it for you. It will find related seeder by model's table and pass your model to it.

Hint: This method returns resolved seeder object, so you can chain your seed methods.

Example:

seedWithCsv($csvFile = '', $model = null)

This method seeds your database with data from the related csv files.

By default, it tries to find them in your /database/seeds/csv directory.

Files have to be names as {$databaseName}_{$tableName}.csv, but you can always overwrite this behaviour.

Note! If you are using the same seeds to seed mysql and sqlite databases (ie. while testing), you have to define your database name manually, or Seeder will try to find csv files like database.sqlite_your_table.csv. You can do it via \Lanin\ExtendSeeder\Seeder::setDatabaseName('database_name'); method.

If you are calling this method via table seeder, that was called via seedModel, it already knows everything about your model and can resolve related csv file iteslf.

Example:

Full example you can find in the tests/CsvSeederTest.php

Hacks

You can leave TableSeeders empty and chain csv import via basic seeder.

You don't even have to create TableSeeders and seed right in your basic seeder.

If you want to have your csv files to be set in another location you can use static method setCsvPath($csvPath), where you can specify relative from your base_path path.

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.


All versions of laravel-extend-seeder with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
illuminate/support Version ^5.4
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 lanin/laravel-extend-seeder contains the following files

Loading the files please wait ....