Skip to content

Commit

Permalink
Merge pull request #4 from eighty8-ventures/develop
Browse files Browse the repository at this point in the history
Merge Develop
  • Loading branch information
edmundluong88 authored Jun 28, 2017
2 parents 499fb9c + a325f1c commit 3eb920a
Show file tree
Hide file tree
Showing 35 changed files with 1,405 additions and 919 deletions.
14 changes: 6 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Crap
# OS
.DS_Store
bin
coverage

# IDE
.idea
*.sublime-*

# Composer
composer.phar
composer.lock
vendor

# IDE
.idea
*.sublime-*
vendor/
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM php:7.1-alpine

# Install Composer and non-root user
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& adduser -D -u 1000 composer

USER composer

VOLUME ["/usr/local/src"]

WORKDIR /usr/local/src
62 changes: 42 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# LaravelSeeder

Seeding as it is currently done in Laravel is intended only for dev builds, but what if you're iteratively creating your database and want to constantly flush it and repopulate it during development?
Seeding as it is currently done in Laravel is intended only for dev builds, but what if you're iteratively creating your
database and want to constantly flush it and repopulate it during development?

What if you want to seed a production database with different data from what you use in development? What if you want to seed a table you've added to a database that is currently in production with new data?
What if you want to seed a production database with different data from what you use in development? What if you want to
seed a table you've added to a database that is currently in production with new data?

LaravelSeeder takes the database migration features in Laravel and extends them to database seeders, making them "migratable".
All of the functionality you have grown accustomed to with Laravel migrations have been mirrored and behave similarly for seeders.

Requirements
============

- Laravel >= 5.4
- PHP >= 7.1

Installation
============
Expand All @@ -11,33 +22,44 @@ Installation
- Add ```Eighty8\LaravelSeeder\SeederServiceProvider::class``` to your providers array in ```app/config/app.php```
- Run ```php artisan vendor:publish``` to push config files to your config folder if you want to override the name of the seeds folder or the name of the table where seeds are stored


Features
============

- Allows you to seed databases in different environments with different values.
- Allows you to "version" seeds the same way that Laravel currently handles migrations. Running ```php artisan seed``` will only run seeds that haven't already been run.
- Prompts you if your database is in production.
- Allows you to run multiple seeds of the same model/table
- Overrides Laravel's seeding commands. LaravelSeeder will fire when you run
```
php artisan db:seed
```
or
```
php artisan migrate:refresh --seed
```
- You can run a single seed file with the --file option.
```php artisan seed:run --file=seed_2015_05_27_030017_UserSeeder```
- Prompts you if your database is in production

Usage
============
When you install LaravelSeeder, various artisan commands are made available to you which use the same methodology you're used to using with Migrations.

<table>
<tr><td>seeder:run</td><td>Runs all the seeds in the "seeders" directory that haven't been run yet.</td></tr>
<tr><td>seeder:make</td><td>Makes a new seed class in the environment you specify.</td></tr>
<tr><td>seeder:rollback</td><td>Rollback doesn't undo seeding (which would be impossible with an auto-incrementing primary key). It just allows you to re-run the last batch of seeds.</td></tr>
<tr><td>seeder:reset</td><td>Resets all the seeds.</td></tr>
<tr><td>seeder:refresh</td><td>Resets and re-runs all seeds.</td></tr>
<tr><td>seeder:install</td><td>You don't have to use this... it will be run automatically when you call "seed"</td></tr>
</table>
<tr><td>seed</td><td>Runs all the seeds in the "seeders" directory that haven't been run yet.</td></tr>
<tr><td>seed:rollback</td><td>Rollback doesn't undo seeding (which would be impossible with an auto-incrementing primary key). It just allows you to re-run the last batch of seeds.</td></tr>
<tr><td>seed:reset</td><td>Resets all the seeds.</td></tr>
<tr><td>seed:refresh</td><td>Resets and re-runs all seeds.</td></tr>
<tr><td>seed:status</td><td>Gets the status of each migratable seeder.</td></tr>
<tr><td>seed:make</td><td>Makes a new seed class in the environment you specify.</td></tr>
<tr><td>seed:install</td><td>You don't have to use this... it will be run automatically when you call "seed"</td></tr>
</table>

Local Development
============
A Dockerfile with PHP 7.1 and Composer installed is bundled with the project to facilitate local development.

To build the image:
```
docker build -t laravel-seeder .
```

To install Composer dependencies:
```
docker run -v "$PWD":/usr/local/src laravel-seeder composer install
```

To run PHPUnit tests:
```
docker run -v "$PWD":/usr/local/src laravel-seeder vendor/bin/phpunit
```
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=5.4.0",
"php": ">=7.1.0",
"illuminate/support": "5.4.*",
"illuminate/console": "5.4.*",
"illuminate/database": "5.4.*",
"illuminate/filesystem": "5.4.*"
},
"require-dev": {
"phpspec/phpspec": "~2.0",
"henrikbjorn/phpspec-code-coverage": "~0.2"
"phpunit/phpunit": "^6.2"
},
"autoload": {
"psr-4": {
"Eighty8\\LaravelSeeder\\": "src/LaravelSeeder"
}
},
"config": {
"bin-dir": "bin"
"autoload-dev": {
"psr-4": {
"Eighty8\\LaravelSeeder\\Tests\\": "tests/LaravelSeeder"
}
},
"prefer-stable": true
}
2 changes: 0 additions & 2 deletions phpspec.yml

This file was deleted.

17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
50 changes: 0 additions & 50 deletions spec/LaravelSeeder/SeederRepositorySpec.php

This file was deleted.

Loading

0 comments on commit 3eb920a

Please sign in to comment.