Make doctrine optional

Not needed for most people.
This commit is contained in:
Barry vd. Heuvel
2014-06-29 12:35:57 +02:00
parent 138b3deeb1
commit 0b70167182
3 changed files with 16 additions and 6 deletions
+4 -2
View File
@@ -15,8 +15,10 @@
"illuminate/console": "4.x", "illuminate/console": "4.x",
"illuminate/filesystem": "4.x", "illuminate/filesystem": "4.x",
"phpdocumentor/reflection-docblock": "2.0.x", "phpdocumentor/reflection-docblock": "2.0.x",
"symfony/class-loader": "~2.3", "symfony/class-loader": "~2.3"
"doctrine/dbal": "~2.3" },
"suggest": {
"doctrine/dbal": "Load information from the database about models for phpdocs (~2.3)"
}, },
"autoload": { "autoload": {
"psr-0": { "psr-0": {
+3 -3
View File
@@ -53,10 +53,10 @@ The Illuminate/Support/helpers.php is already set-up, but you can add/remove you
### Automatic phpDocs for Models ### 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 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. 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)`).
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)`).
Please make sure to backup your models, before writing the info. 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. 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. With the `--reset (-R)` option, the existing phpdocs are ignored, only the newly found columns/relations are saved as phpdocs.
@@ -126,6 +126,8 @@ class ModelsCommand extends Command {
*/ */
\n\n"; \n\n";
$hasDoctrine = interface_exists('Doctrine\DBAL\Driver');
if(empty($loadModels)){ if(empty($loadModels)){
$models = $this->loadModels(); $models = $this->loadModels();
}else{ }else{
@@ -158,7 +160,9 @@ class ModelsCommand extends Command {
} }
$model = new $name(); $model = new $name();
if($hasDoctrine){
$this->getPropertiesFromTable($model); $this->getPropertiesFromTable($model);
}
$this->getPropertiesFromMethods($model); $this->getPropertiesFromMethods($model);
$output .= $this->createPhpDocs($name); $output .= $this->createPhpDocs($name);
}catch(\Exception $e){ }catch(\Exception $e){
@@ -170,6 +174,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; return $output;
} }