Laravel-ide-helper: ide-helper:models does not generate phpDoc

Created on 12 Aug 2018  路  11Comments  路  Source: barryvdh/laravel-ide-helper

Hello,

The result of this command is always a failure. Result No phpDoc generated ...
php artisan ide-helper:models
with or without these options --dir='_models directory_', -W, -R, _[modelName]_, etc..

Do you want to overwrite the existing model files? Choose no to write to _ide_helper_models.php instead? (Yes/No): (yes/no) [no]:

no = empty file _ide_helper_models.php
yes = no generation in model files

My config
"php": ">=7.2.0",
"laravel/framework": "^5.6",
"doctrine/dbal": "^2.8",
"laravelcollective/html": "^5.6",
"barryvdh/laravel-ide-helper": "^2.4",

I do not understand why?

Thank you for your help :)

Most helpful comment

I think the --dir option is meant to NOT work with specific model/s. It's for all models in that directory unless listed as ignored (--ignore). For specific model not in default directory (app/), you should specify full namespace (with \\) e.g. php artisan ide-helper:models --write App\\Models\\User

All 11 comments

I just had the same problem. It's related to doctrine somehow. For me changing "doctrine/dbal": "^2.8", to "doctrine/dbal": "~2.3", and then running composer again fixed the issue.

@AraneaDev Fine :+1:

Same error, downgrade dbal to 2.3 doesn't work

Finally found that passing --dir="app/Models" doesn't work, need to publish config and edit model_locations array.

Is there a reason that a specific version of dbal is required?

I think the --dir option is meant to NOT work with specific model/s. It's for all models in that directory unless listed as ignored (--ignore). For specific model not in default directory (app/), you should specify full namespace (with \\) e.g. php artisan ide-helper:models --write App\\Models\\User

model_locations option in the ide-helper.php file only works when running all models like
php artisan ide-helper:models

but if you want to use it for one model is not consider
php artisan ide-helper:models Mymodel DOES NOT WORK
php artisan ide-helper:models App\Models\Mymodel WORKS

@delmicio YUP. This was the fix for me without going through the extra steps outlined above.

@hotrush @delmicio

The following worked for me:

  1. Run php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config

  2. Edit model_locations in app/config/ide-helper.php to 'app/Models'

  3. Change localhost to 127.0.0.1 in .env and in app/config/database.php

  4. Edit composer.json:

    "scripts" : {
        ...
        "post-update-cmd" : [
            ...
            "@php artisan ide-helper:generate",
            "@php artisan ide-helper:models --nowrite",
            "@php artisan ide-helper:meta"
        ]
    }
  1. Run php artisan clear-compiled

  2. Run composer update

That's it!

@barryvdh this was likely a problem with connecting to the database properly, I vote for closing this issue :}

[Windows] In my case, the issue was I did not run the xampp (which I believe holds the database) and was only relying on php artisan serve while running the command php artisan ide-helper: models meaning it was not accessing the database.. So the simple solution(in my opinion) is running whatever server stack (WAMPP or XAMPP) alongside the php artisan serve command...I don't know about on other operating systems

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Newbie012 picture Newbie012  路  4Comments

quantumwebco picture quantumwebco  路  4Comments

anik786 picture anik786  路  3Comments

kickthemooon picture kickthemooon  路  3Comments

Alymosul picture Alymosul  路  4Comments