Initial commit, superhelio:reload

This commit is contained in:
Ismo Vuorinen
2017-02-07 17:17:35 +02:00
commit c0044479e6
7 changed files with 244 additions and 0 deletions

5
CHANGELOG.md Normal file
View File

@@ -0,0 +1,5 @@
# Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

80
README.md Normal file
View File

@@ -0,0 +1,80 @@
# Laravel Commands by [SuperHelio](link-author)
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
[![Quality Score][ico-code-quality]][link-code-quality]
[![Total Downloads][ico-downloads]][link-downloads]
This is a collection of Laravel Artisan commands created to help everyone
in their development work. We try to keep these as useful as possible.
## Install
### Step 1: Install Through Composer
``` bash
$ composer require superhelio/commands --dev
```
### Step 2: Add the Service Provider
You'll only want to use these generators for local development, so you don't want to update the production `providers` array in `config/app.php`. Instead, add the provider in `app/Providers/AppServiceProvider.php`, like so:
```php
public function register()
{
if ($this->app->environment() == 'local') {
$this->app->register('SuperHelio\Commands\ServiceProvider');
}
}
```
## Usage
- *superhelio:reload*
- Reset database, migrate and seed
- `php artisan superhelio:reload`
## Change log
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
``` bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security
If you discover any security related issues, please contact [SuperHelio](link-author).
## Credits
- [SuperHelio][link-author]
- [All Contributors][link-contributors]
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/superhelio/commands.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/superhelio/commands/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/superhelio/commands.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/superhelio/commands.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/superhelio/commands.svg?style=flat-square
[link-packagist]: https://packagist.org/packages/superhelio/commands
[link-travis]: https://travis-ci.org/superhelio/commands
[link-scrutinizer]: https://scrutinizer-ci.com/g/superhelio/commands/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/superhelio/commands
[link-downloads]: https://packagist.org/packages/superhelio/commands
[link-author]: https://github.com/superhelio
[link-contributors]: ../../contributors

44
composer.json Normal file
View File

@@ -0,0 +1,44 @@
{
"name": "superhelio/commands",
"description": "Laravel Commands",
"keywords": [
"laravel",
"superhelio",
"commands"
],
"homepage": "https://github.com/superhelio/commands",
"license": "MIT",
"authors": [
{
"name": "SuperHelio",
"email": "hello@superhelio.com",
"homepage": "https://superhelio.com",
"role": "Developer"
}
],
"require": {
"php" : ">=5.5.0",
"illuminate/support": "~5.2"
},
"require-dev": {
"phpunit/phpunit" : "4.*"
},
"autoload": {
"psr-4": {
"Superhelio\\Commands\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Superhelio\\Commands\\Test\\": "tests"
}
},
"scripts": {
"test": "phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
}
}

60
src/Commands/Reload.php Normal file
View File

@@ -0,0 +1,60 @@
<?php
namespace Superhelio\Commands\Commands;
use Illuminate\Console\Command;
class Reload extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'superhelio:reload';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete database tables, migrate and run seeds';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if ($this->confirm('Rollback all your database tables, recreate them and seed?')) {
$this->call(
'migrate:reset',
[
'--no-interaction' => true,
'--env' => 'development',
'--verbose' => 3
]
);
$this->call(
'migrate',
[
'--seed' => true,
'--no-interaction' => true,
'--env' => 'development',
'--verbose' => 3
]
);
}
}
}

13
src/Facade.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
namespace Superhelio\Commands;
class Facade extends \Illuminate\Support\Facades\Facade
{
/**
* {@inheritDoc}
*/
protected static function getFacadeAccessor()
{
return 'commands';
}
}

42
src/ServiceProvider.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
namespace Superhelio\Commands;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
/**
* Class PackageServiceProvider
*
* @package Superhelio\Commands
* @see http://laravel.com/docs/master/packages#service-providers
* @see http://laravel.com/docs/master/providers
*/
class ServiceProvider extends BaseServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @see http://laravel.com/docs/master/providers#deferred-providers
* @var bool
*/
protected $defer = false;
/**
* Register the service provider.
*
* @see http://laravel.com/docs/master/providers#the-register-method
* @return void
*/
public function register()
{
$this->registerReloader();
}
private function registerReloader()
{
$this->app->singleton('command.superhelio.reload', function ($app) {
return $app['Superhelio\Commands\Commands\Reload'];
});
$this->commands('command.superhelio.reload');
}
}

0
tests/.gitkeep Normal file
View File