From 0b70167182d16f4af59c51ef20bd63873185deac Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 29 Jun 2014 12:35:57 +0200 Subject: [PATCH] Make doctrine optional Not needed for most people. --- composer.json | 6 ++++-- readme.md | 6 +++--- src/Barryvdh/LaravelIdeHelper/ModelsCommand.php | 10 +++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index f873c8f..9eea7a5 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,10 @@ "illuminate/console": "4.x", "illuminate/filesystem": "4.x", "phpdocumentor/reflection-docblock": "2.0.x", - "symfony/class-loader": "~2.3", - "doctrine/dbal": "~2.3" + "symfony/class-loader": "~2.3" + }, + "suggest": { + "doctrine/dbal": "Load information from the database about models for phpdocs (~2.3)" }, "autoload": { "psr-0": { diff --git a/readme.md b/readme.md index ed22928..8bb15b5 100644 --- a/readme.md +++ b/readme.md @@ -53,10 +53,10 @@ The Illuminate/Support/helpers.php is already set-up, but you can add/remove you ### Automatic phpDocs for Models +> **Note:** Since v1.10 you need to require `doctrine/dbal: ~2.3` in your own composer.json. + If you don't want to write your properties yourself, you can use the command `ide-helper:models` to generate -phpDocs, based on table columns, relations and getters/setters. Still in beta, so please provide feedback if you want. -You can now also write the comments directly to your Model file, using the `--write (-W)` option. By default, you are asked to overwrite or -write to a separate file (\_ide\_helper\_models.php) (You can force No with `--nowrite (-N)`). +phpDocs, based on table columns, relations and getters/setters. You can write the comments directly to your Model file, using the `--write (-W)` option. By default, you are asked to overwrite or write to a separate file (\_ide\_helper\_models.php) (You can force No with `--nowrite (-N)`). Please make sure to backup your models, before writing the info. It should keep the existing comments and only append new properties/methods. The existing phpdoc is replaced, or added if not found. With the `--reset (-R)` option, the existing phpdocs are ignored, only the newly found columns/relations are saved as phpdocs. diff --git a/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php b/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php index 801cdf0..e9f700a 100644 --- a/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php +++ b/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php @@ -126,6 +126,8 @@ class ModelsCommand extends Command { */ \n\n"; + $hasDoctrine = interface_exists('Doctrine\DBAL\Driver'); + if(empty($loadModels)){ $models = $this->loadModels(); }else{ @@ -158,7 +160,9 @@ class ModelsCommand extends Command { } $model = new $name(); - $this->getPropertiesFromTable($model); + if($hasDoctrine){ + $this->getPropertiesFromTable($model); + } $this->getPropertiesFromMethods($model); $output .= $this->createPhpDocs($name); }catch(\Exception $e){ @@ -169,6 +173,10 @@ class ModelsCommand extends Command { } } + + if(!$hasDoctrine){ + $this->error("Warning: 'doctrine/dbal: ~2.3' is required to load database information. Please require that in your composer.json and run 'composer update'."); + } return $output;