Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asset() autocompletion fails in PHPStorm 2017.3 #1118

Closed
yahyaerturan opened this issue Dec 20, 2017 · 20 comments
Closed

asset() autocompletion fails in PHPStorm 2017.3 #1118

yahyaerturan opened this issue Dec 20, 2017 · 20 comments
Labels

Comments

@yahyaerturan
Copy link

I am using Symfony 3.4.1. In twig templates, it is not suggesting resources in public directory anymore whilst using {{ asset('abc.jpg') }}. It says Missing asset... yet it renders correctly when we display it on browsers.

This is my framework.yaml:

framework:
    secret: '%env(APP_SECRET)%'
    default_locale: tr
    translator:
      fallbacks: ['tr']
    #csrf_protection: ~
    #http_method_override: true

    # uncomment this entire section to enable sessions
    session:
        # With this config, PHP's native session handling is used
        handler_id: ~

    #esi: ~
    #fragments: ~
    php_errors:
        log: true

    templating:
        engines: twig
        form:
            resources:
                - 'App:Form'

This is my PHPStorm version:

PhpStorm 2017.3
Build #PS-173.3727.138, built on November 28, 2017
JRE: 1.8.0_152-release-1024-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.2

Any idea how to gain autocompletion back? Because we love it 💯 percent 😄

@AlexeyKosov
Copy link

As an extra note, neither clearing project's cache nor Symfony plugin's cache helps :(

PhpStorm 2017.3.1
Build #PS-173.3942.32, built on December 12, 2017
JRE: 1.8.0_152-release-1024-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 8.1 6.3

Symfony plugin 0.15.162

Haehnchen added a commit that referenced this issue Dec 20, 2017
…tead of rescanning them to improve performance an drop massive `opendirectoryd` cpu time #809 #1118
Haehnchen added a commit that referenced this issue Dec 20, 2017
…tead of rescanning them to improve performance an drop massive `opendirectoryd` cpu time #809 #1118
Haehnchen added a commit that referenced this issue Dec 21, 2017
…tead of rescanning them to improve performance an drop massive `opendirectoryd` cpu time #809 #1118
Haehnchen added a commit that referenced this issue Dec 21, 2017
fix assets reading and provide explicit resolving for asset files instead of rescanning them to improve performance an drop massive `opendirectoryd` cpu time #809 #1118
@Haehnchen
Copy link
Owner

sry, ... but back in the game also improved performance a lot ;)

@yahyaerturan
Copy link
Author

Seems nicely fixed with version 0.15.163. Thanks. 👍 It is one of the 🔑 plugins to develop Symfony with PhpStorm 😄

@ghost
Copy link

ghost commented Mar 21, 2018

@Haehnchen

This same (mis)behavior -- report of Missing asset... but correct render -- is again occurring with

PhpStorm 2018.1 EAP
Build #PS-181.4203.107, built on March 14, 2018
PhpStorm EAP User
Expiration date: April 13, 2018
JRE: 1.8.0_152-release-1136-b20 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.10-4-default

and

Symfony Plugin (0.16.165)
PHP Annotations (5.3)
PHP Toolbox (0.4.6)

Plugins uninstall/reinstall seems to make no difference.

Assuming I've not missed something, not sure if you want to reopen here, or open as a new bug.

@martinbertinat
Copy link

martinbertinat commented Sep 1, 2018

If you are using Symfony 4.x the default directory for assets is 'public' instead of 'web', so the plugin can't find the assets.

The solution is simply change the Web Directory config in the plugin's settings to "public".

sf

@cybernet
Copy link
Contributor

If you are using Symfony 4.x the default directory for assets is 'public' instead of 'web', so the plugin can't find the assets.

The solutions is simpy change the Web Directory config in the plugin's settings to "public".

sf

I still can't find this setting :(

@martinbertinat
Copy link

If you are using Symfony 4.x the default directory for assets is 'public' instead of 'web', so the plugin can't find the assets.
The solutions is simpy change the Web Directory config in the plugin's settings to "public".
sf

I still can't find this setting :(

What version of PHPStorm are you using?

Here is another screenshot may help you

settings

@cybernet
Copy link
Contributor

the latest version, just found it and wanted to delete the comment :)
offtopic - in symfony 4 app directory shouldn't be src ?

@martinbertinat
Copy link

the latest version, just found it and wanted to delete the comment :)
offtopic - in symfony 4 app directory shouldn't be src ?

Yes, I think... In the last screenshot I was working in a 3.x project

@nicraMarcin
Copy link

I have the same issue. All plugins installed, phpStorm 2019, everything up to date.
Zrzut ekranu 2019-05-24 o 10 33 28
assets directory is in public directory
Zrzut ekranu 2019-05-24 o 10 34 57
but PHPStorm says that tere is no suggestion
Zrzut ekranu 2019-05-24 o 10 37 09

Symfony 4.2
PHPStorm 2019.1
Symfony Plugin v0.17.172
PHP Annotations v5.3.3
PHP Toolbox v0.4.6

@cybernet
Copy link
Contributor

have you tried to rebuild the cache ?

@nicraMarcin
Copy link

@cybernet Yes, I totally removed var/cache also but didn't work

@cybernet
Copy link
Contributor

your problem is with phpstorm, not symfony, therefore, have you cleaned your PHPStorm cache ? under symfony tab you have clear index

@nicraMarcin
Copy link

nicraMarcin commented May 24, 2019

@cybernet Yes I did but stil the same :/
Now, I also tried turn off and turn on the plugin, but without expected effects.

---edited---
I know where problem is but I do not know how to solve it.
Problem is in directory structure. My project root directory isn't directly symofony project. I have BackgroundProject for symfony and FrontProject for store pure html for my frontend developer.

-project root
 |_ BackgroundProject
 |_ FrontProject

In plugin settings I tried configure directory with ./ and without it but it still doesn't suggest.
Zrzut ekranu 2019-05-24 o 14 14 40
When I opened new project using BackgroundProject directory as project root directory it everything works perfectly.
How to configure plugin to work in my directory structure? is it possible?

@NickTick
Copy link

NickTick commented Jun 3, 2019

@nicraMarcin
I had exactly the same problem with the same directory structure. After a few tries I managed to do it with the following settings:

Symfony 3+:
Web Directory: projectdir/source/web
App Directory: projectdir/source/app

Symfony 4+:
Web Directory: projectdir/src
App Directory: projectdir/public

And... always clear the index :) Maybe you should also clear the PHPStorm cache.
It seems to be connected to the .idea settings, which were stored in my root folder "/".

@nicraMarcin
Copy link

nicraMarcin commented Jun 4, 2019

@NickTick Yes, I cleared the index and tried set directories with leading ./ and without. but didn't help.
When I set project in BackgroundProject directory as root it works.

@tom10271
Copy link

tom10271 commented Sep 6, 2019

@nicraMarcin
I had exactly the same problem with the same directory structure. After a few tries I managed to do it with the following settings:

Symfony 3+:
Web Directory: projectdir/source/web
App Directory: projectdir/source/app

Symfony 4+:
Web Directory: projectdir/src
App Directory: projectdir/public

And... always clear the index :) Maybe you should also clear the PHPStorm cache.
It seems to be connected to the .idea settings, which were stored in my root folder "/".

How to clear cache for PHPStorm?

@nicraMarcin
Copy link

@tom10271

How to clear cache for PHPStorm?

Yes, I did, but this didn't help as well.
I solved it by ohter way. I've starded using webpack bundle with symfony framework and this connects front and background well.

@berkut1
Copy link

berkut1 commented Sep 18, 2019

This will fix the problem.
Don't forget to clear index
As example for the folder templates
fix

@CarsonCG
Copy link

CarsonCG commented Feb 7, 2020

After everything above, this is what solve the problem for me:
Ctrl + Alt + S > Languages & Frameworks > PHP > Annotations > Actions > SCHEDULE ANNOTATION REINDEX

Clicked that button, software indexed the project, and I got my sanity and autocomplete back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants