Download the PHP package collective-thinking/laravel-seed without Composer

On this page you can find all versions of the php package collective-thinking/laravel-seed. 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-seed

laravel-seed

Run your seeds like you run your migrations.

Packagist License Packagist Version Maintainability Test Coverage

laravel-seed-showcase-2

Summary

About

I created this package because I am working with tables that are pre-filled with data (like a Gender table, a Product type table, and so on).

I found a series of package, laravel-seeder, which seemed to have been forked a lot of times, but either the packages would not install properly, or the forks were really outdated.

I decided to take a fresh start and create this package from scratch, with having in mind to be as close as the official migration experience.

In this approach, each seeders is a class, like a migration: it defines both "up" and "down" methods, so you can run and rollback your seeds. Like migrations, the order of the files is determined by a timestamp at the creation time.

My use case for this package is to populate my apps in production, in order to automatize this process, without having to deal with running each seed class individually, and manually.

Prerequisites

Installation

In your root project folder, run this command:

For older Laravel versions, you will need to register the service provider in the key "Providers" of the config/app.php file like following:

Usage

Create a new seeder

Like mentioned in the about section, seeders are class-based. They define a up and down method, and are the only way to use the command lines to seed your database.

Using the artisan command

To create a new seeder, use this Artisan command line:

This will create a new seeder class at database/seeders/2020_07_24_094613_insert_post_categories.php. If you open the file, this is how it looks:

Specifying an Eloquent model

In general seeders will populate a table modelized by one of your Eloquent model.

To specify through which Eloquent model your seeder will fill data, you can specify the --model argument like following:

The content of your seeder will be filled with the usual boilerplate code you would have written:

Checking the status of your seeds

If you need to have a report of which seeds have been ran or not yet, you can use the following Artisan command:

This will prompt a table, with each lines specifying the status of the seeder.

Running seeders

When your seeders is ready, you can use this command to run any seeders that have not been ran yet.

This will also prompt a table summarizing which seeders have been successfuly run.

Rollbacking seeds

Rollbacking seeds can be useful to test again that everything goes right. There is two way to rollback seeds.

Rollbacking everything

If you are sure you need to remove every seeds, you can use the following command:

This will take every seeds in reverse order, and run their down() method.

Rollbacking the last batch

When you run php artisan seed, it associate a "batch" number to the seeds that have been run at this time.

Let's imagine you are creating this blog post web app. You need to fill some post categories, so you run php artisan seed one time.

This package will associate the batch number "1" to this first seed batch.

Then, you need to modelize author genders, and author positions (junior or senior). So you create both the Gender and Position models, the seeders, and run a second time php artisan seed.

This will then associate the batch number "2" for these two additionals seeds.

At this point, this is what we have stored so far:

So when you run php artisan seed:rollback, this will rollback both insert_positions and insert_genders in a row, since they are in the same batch.

Then, if you run again php artisan seed:rollback, this will rollback the insert_post_categories seed alone.


All versions of laravel-seed with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0
laravel/framework Version 8.*|9.*|10.*
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 collective-thinking/laravel-seed contains the following files

Loading the files please wait ....