mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Make doctrine optional
Not needed for most people.
This commit is contained in:
+4
-2
@@ -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": {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user