nvlad / yii2support

Yii2 Support for PhpStorm / IntelliJ IDEA
https://plugins.jetbrains.com/idea/plugin/9388-yii2-support
Other
295 stars 52 forks source link

The extension can not see the view files #173

Open slepciu opened 6 years ago

slepciu commented 6 years ago

What steps will reproduce the problem?

In IDE, I have to emphasize that the view does not exist. However, it exists and works what I checked by running the application. The controller is in the path: E: \ project \ rts \ api \ app \ public \ cron \ controllers \ GrantDbController.php The view is in the path: E: \ project \ rts \ api \ app \ public \ cron \ views \ grant-db \ show-compare.php Error response line: return $ this-> render ('show-compare'); In the Yii plugin settings, the root path is set to: E: \ project \ rts \ client \ app \ public

Themes path map: @ app / themes / * -> @ app / views

Q A
IDE Name PhpStorm
IDE Version 2017.3.4
Plugin version 0.8.42.3
nvlad commented 6 years ago

What Yii template using? yii-app-basic or yii-app-advanced? What namespace for GrantDbController.php?

nvlad commented 6 years ago

what path in error?

image

vtvz commented 6 years ago

The same issue. screenshot_343

nvlad commented 6 years ago

@vtvz Your have setup Yii root? What Yii template using? yii-app-basic or yii-app-advanced? Need more details of project structure.

vtvz commented 6 years ago

@nvlad I started from blank project without any templates (To be fair I injected Yii2 to existing non Yii2 project). But it's looks like basic template a little bit.

Project structure looks like this:

www
| - app
|   | - config (folder)
|   | - console (folder)
|   | - models (folder)
|   | - web
|   |   | - controllers (folder)
|   |   | - views (folder)
|   | - yii (executable file)

Yes. I setup Yii root. Tried empty, www folder and www/app (full path of couse)

Does not use any templates. Pure PHP.

nvlad commented 6 years ago

@vtvz your controller located at web/controllers namespace?

Please test dev build with fix for your trouble (may be).

Plugin in attached archive: yii2support.zip

vtvz commented 6 years ago

Error occurred: Message:

Error while indexing /home/path/to/project/www/c3.php

Details:

Error while indexing /home/path/to/project/www/c3.php
To reindex this file IDEA has to be restarted: String index out of range: -56
java.lang.StringIndexOutOfBoundsException: String index out of range: -56
    at java.lang.String.substring(String.java:1967)
    at com.nvlad.yii2support.common.YiiApplicationUtils.getApplicationName(YiiApplicationUtils.java:52)
    at com.nvlad.yii2support.views.util.ViewUtil.resolveView(ViewUtil.java:51)
    at com.nvlad.yii2support.views.index.ViewFileIndex$ViewDataIndexer.map(ViewFileIndex.java:84)
    at com.nvlad.yii2support.views.index.ViewFileIndex$ViewDataIndexer.map(ViewFileIndex.java:78)
    at com.intellij.util.indexing.impl.MapReduceIndex.mapInput(MapReduceIndex.java:273)
    at com.intellij.util.indexing.VfsAwareMapReduceIndex.calculateUpdateData(VfsAwareMapReduceIndex.java:98)
    at com.intellij.util.indexing.impl.MapReduceIndex.update(MapReduceIndex.java:213)
    at com.intellij.util.indexing.FileBasedIndexImpl.a(FileBasedIndexImpl.java:1654)
    at com.intellij.util.indexing.FileBasedIndexImpl.a(FileBasedIndexImpl.java:1582)
    at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.freezeFileTypeTemporarilyIn(FileTypeManagerImpl.java:511)
    at com.intellij.util.indexing.FileBasedIndexImpl.a(FileBasedIndexImpl.java:1541)
    at com.intellij.util.indexing.FileBasedIndexImpl.indexFileContent(FileBasedIndexImpl.java:1529)
    at com.intellij.util.indexing.UnindexedFilesUpdater.a(UnindexedFilesUpdater.java:109)
    at com.intellij.openapi.project.CacheUpdateRunner$MyRunnable.a(CacheUpdateRunner.java:227)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1127)
    at com.intellij.openapi.project.CacheUpdateRunner$MyRunnable.a(CacheUpdateRunner.java:243)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:157)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:543)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
    at com.intellij.openapi.project.CacheUpdateRunner$MyRunnable.run(CacheUpdateRunner.java:240)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:315)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

The same error with views

craiglondon commented 6 years ago

I think I am having this same issue. I am using the Yii2 Advanced Template. Getting false positives by this detection. View file for "select" not found in "/advanced/views/payment-method/select.php" . The correct path for that file is "/advanced/frontend/views/payment-method/select.php"

nvlad commented 6 years ago

@craiglondon your Yii project located at root PhpStorm project?

nvlad commented 6 years ago

Check latest release (v0.8.42.5)

vtvz commented 6 years ago

@nvlad Nothing was changed. The same problem happens. image // Прости меня за ужасный английский. Короче, все та же ерунда. Не зависимо от того, какой Yii2 Root я указываю. Использую, ествесственно, самую последнюю версию всего

craiglondon commented 6 years ago

This appears to be resolved on 0.8.42.5 and configuring the Yii Root Path.

slepciu commented 6 years ago

@nvlad apologize for the long response time. I've updated the extension (0.8.42.5), but it's still the same. Namespace for GrantDbController.php -> cron\controllers I used yii-app-advanced, but I have a slightly changed directory structure. All files with configuration and parameters have in 2 directories in the main folder public ├── mainApp ├── common
├── config
├── console
├── cron
├── configLocal
├── vendor
├── yii

jeffersoncechinel commented 6 years ago

Im am having the same issue on all my views. Im using advanced template. The view is in src/frontend/views/estimates/create.php and works fine but the plugin seems to be skipping any endpoint folder.. in my case frontend is not added into the plugin's path.

image

jeffersoncechinel commented 6 years ago

Hi there! I just updated the plugin and configured the root project folder and now everything works fine! Please ignore my last comment. Thank you!

slepciu commented 6 years ago

@nvlad I have updated the plugin to version 0.8.42.6 and is already correctly checking the existence of the view. Unfortunately, when he does not find the view and tries to create it, he creates the file in the wrong place. It should be found here: image

Instead, it creates a new directory structure in the main Yii directory:

image

Config: image

sallfris commented 6 years ago

2018-09-18_17-05-47 PhpStorm 2018.2.3 Yii2 template basic image image image the problem has appeared after updating PhpStorm

sallfris commented 6 years ago

Проблема решилась путем добавления пустой папки controllers в корень проекта. И воспроизводится если ее удалить.

sallfris commented 6 years ago

Короче как я понял проблема тут image Если в корне не найдена папка controllers то считается что это шаблон advanced и корневой директорией назначается первая папка из пути к файлу от корня проекта. Хз как исправить логику, но помогает добавление папки в корень. Скорей всего у @slepciu та же беда, но у него закрашено и не понятно есть ли папка

slepciu commented 6 years ago

Maybe it will help image

sallfris commented 6 years ago

@slepciu if you use advanced template, you need set phpstorm sources folders and set package prefix image

slepciu commented 6 years ago

It works