Skip to content

Commit 53946c6

Browse files
committed
Laravel 5 support
1 parent 7d8f232 commit 53946c6

File tree

9 files changed

+78
-118
lines changed

9 files changed

+78
-118
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Stolz https://github.com/Stolz
3+
Copyright (c) 2015 Stolz https://github.com/Stolz
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Laravel SchemaSpy
22

3-
[Laravel SchemaSpy](https://github.com/Stolz/laravel-schema-spy) is a [Laravel artisan command](http://laravel.com/docs/commands) that acts as an interface for the program [SchemaSpy](http://schemaspy.sourceforge.net). With SchemaSpy you can analyze the schema metadata of a database and generate browser readable files with useful information such:
3+
[Laravel SchemaSpy](https://github.com/Stolz/laravel-schema-spy) is a [Laravel artisan command](http://laravel.com/docs/master/commands) that acts as an interface for the program [SchemaSpy](http://schemaspy.sourceforge.net). With SchemaSpy you can analyze the schema metadata of a database and generate browser readable files with useful information such:
44

55
- Visual ER diagram.
66
- Proper table insertion/deletion order for database migrations.
@@ -19,9 +19,9 @@ Graphvis is not required to view the output, only the `dot` command that is used
1919

2020
## Installation
2121

22-
To get the latest version simply require it in your Laravel project `composer.json` file by running:
22+
Install via [Composer](https://getcomposer.org/)
2323

24-
composer require "stolz/laravel-schema-spy:dev-master" --dev
24+
composer require stolz/laravel-schema-spy --dev
2525

2626
Once the package is installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key.
2727

@@ -38,11 +38,11 @@ If no connection is provided Laravel's default one will be used. After successfu
3838

3939
## Configuration
4040

41-
To configure the package use the following command to copy the configuration file to `config/packages/stolz/laravel-schema-spy/config.php`.
41+
To configure the package use the following command to copy the configuration file to `config/spy.php`.
4242

43-
php artisan publish:config stolz/laravel-schema-spy
43+
php artisan vendor:publish
4444

45-
All available settings are included inside `config.php` and with the provided comments they should be self-explanatory.
45+
All available settings are included inside `spy.php` and with the provided comments they should be self-explanatory.
4646

4747
## License
4848

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"squizlabs/php_codesniffer": "2.*"
1818
},
1919
"autoload": {
20-
"psr-0": {
21-
"Stolz\\SchemaSpy": "src/"
20+
"psr-4": {
21+
"Stolz\\SchemaSpy\\": "src/"
2222
}
2323
},
2424
"config": {

phpunit.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Stolz/SchemaSpy/Command.php renamed to src/Command.php

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<?php namespace Stolz\SchemaSpy;
22

3-
// use Symfony\Component\Console\Input\InputOption;
3+
use Illuminate\Console\Command as ConsoleCommand;
44
use Symfony\Component\Console\Input\InputArgument;
5-
use Config;
65

7-
class Command extends \Illuminate\Console\Command
6+
class Command extends ConsoleCommand
87
{
9-
108
/**
119
* The console command name.
1210
*
@@ -21,43 +19,26 @@ class Command extends \Illuminate\Console\Command
2119
*/
2220
protected $description = 'Generate a database report using http://schemaspy.sourceforge.net';
2321

24-
/**
25-
* Default command to run schemaSpy.jar
26-
*
27-
* @var string
28-
*/
29-
protected $command = 'java -jar schemaSpy.jar';
30-
3122
/**
3223
* Parameters passed to schemaSpy.jar
3324
*
3425
* @var array
3526
*/
3627
protected $parameters = [];
3728

38-
/**
39-
* Create a new command instance
40-
*
41-
* @return void
42-
*/
43-
public function __construct()
44-
{
45-
parent::__construct();
46-
}
47-
4829
/**
4930
* Set parameters from config file
5031
*
51-
* @return SchemaSpyCommand
32+
* @return Command
5233
*/
5334
protected function setParametersFromConfig()
5435
{
5536
// Set output dir parameter
56-
$this->parameters['-o'] = Config::get('laravel-schema-spy::output', app_path('database/schema'));
37+
$this->parameters['-o'] = config('spy.output', app_path('database/schema'));
5738

5839
// Set database connection parameters
59-
$connections = Config::get('database.connections', []);
60-
$connection = ($this->argument('connection')) ?: Config::get('database.default');
40+
$connections = config('database.connections', []);
41+
$connection = ($this->argument('connection')) ?: config('database.default');
6142
if(isset($connections[$connection]))
6243
{
6344
$this->info("Using '$connection' connection");
@@ -81,7 +62,7 @@ protected function setParametersFromConfig()
8162
public function fire()
8263
{
8364
// Merge automatic parameters with user configurable parameters
84-
$this->parameters = array_merge($this->setParametersFromConfig()->parameters, Config::get('laravel-schema-spy::arguments', []));
65+
$this->parameters = array_merge($this->setParametersFromConfig()->parameters, config('spy.arguments', []));
8566

8667
// Ask for missing mandatory parameters
8768
if( ! isset($this->parameters['-db']))
@@ -91,7 +72,7 @@ public function fire()
9172
$this->parameters['-u'] = $this->ask('Enter database username');
9273

9374
// Build command
94-
$command = Config::get('laravel-schema-spy::command', $this->command);
75+
$command = config('spy.command', 'java -jar schemaSpy.jar');
9576
foreach($this->parameters as $key => $value)
9677
$command .= " $key $value";
9778

@@ -120,16 +101,4 @@ protected function getArguments()
120101
array('connection', InputArgument::OPTIONAL, 'Database connection name'),
121102
);
122103
}
123-
124-
/**
125-
* Get the console command options.
126-
*
127-
* @return array
128-
*/
129-
protected function getOptions()
130-
{
131-
return array(
132-
// array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
133-
);
134-
}
135104
}

src/ServiceProvider.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php namespace Stolz\SchemaSpy;
2+
3+
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
4+
5+
class ServiceProvider extends LaravelServiceProvider
6+
{
7+
/**
8+
* Path to the default config file.
9+
*
10+
* @var string
11+
*/
12+
protected $configFile = __DIR__ . '/config.php';
13+
14+
/**
15+
* Register bindings in the container.
16+
*
17+
* @return void
18+
*/
19+
public function register()
20+
{
21+
// Merge user's configuration
22+
$this->mergeConfigFrom($this->configFile, 'spy');
23+
24+
// Bind 'stolz.schemaspy.command.spy' component to the IoC container
25+
$this->app->bind('stolz.schemaspy.command.spy', function ($app) {
26+
return new Command();
27+
});
28+
}
29+
30+
/**
31+
* Perform post-registration booting of services.
32+
*
33+
* @return void
34+
*/
35+
public function boot()
36+
{
37+
// Register paths to be published by 'vendor:publish' artisan command
38+
$this->publishes([
39+
$this->configFile => config_path('spy.php'),
40+
]);
41+
42+
// Add artisan command
43+
$this->commands('stolz.schemaspy.command.spy');
44+
}
45+
46+
47+
}

src/Stolz/SchemaSpy/ServiceProvider.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/config/config.php renamed to src/config.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44

55
/*
66
|--------------------------------------------------------------------------
7-
| Base command to run schemaSpy.jar on your system
7+
| Directory where generated files will be written
88
|--------------------------------------------------------------------------
99
|
10-
| No parametes here, instead use 'arguments' array below!
10+
| NOTE: For security reasons, setting this option to any path within your
11+
| public_path() directory will be a really bad idea.
1112
|
12-
| Default: java -jar schemaSpy.jar
13+
| Default: app_path('database/schema')
1314
|
1415
*/
1516

16-
//'command' => 'java -jar schemaSpy.jar',
17+
'output' => app_path('database/schema'),
1718

1819
/*
1920
|--------------------------------------------------------------------------
20-
| Directory where generated files will be written
21+
| Base command to run schemaSpy.jar on your system
2122
|--------------------------------------------------------------------------
2223
|
23-
| NOTE: For security reasons, setting this option to any path within your
24-
| public_path() directory will be a really bad idea.
24+
| No parameters here, instead use 'arguments' array below!
2525
|
26-
| Default: app_path('database/schema')
26+
| Default: java -jar schemaSpy.jar
2727
|
2828
*/
2929

30-
//'output' => app_path('database/schema'),
30+
'command' => 'java -jar schemaSpy.jar',
3131

3232
/*
3333
|--------------------------------------------------------------------------
@@ -41,9 +41,9 @@
4141
|
4242
*/
4343

44-
/*'arguments' => [
45-
'-t' => 'mysql',
46-
'-dp' => '/mysql/mysql-connector-java-5.1.30-bin.jar', // download from http://dev.mysql.com/downloads/connector/j/
47-
'-hq' => null,
48-
],*/
44+
'arguments' => [
45+
'-t' => 'mysql',
46+
'-dp' => '/path/to/mysql-connector-java-5.1.30-bin.jar', // download from http://dev.mysql.com/downloads/connector/j/
47+
'-hq' => null,
48+
],
4949
);

tests/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)