A PHP script file doesn't have PHP syntax formatting - phpstorm

In my PhpStorm, the file index.php, doesn't look like a PHP script, but a plain text file. How can I fix it?

Settings | File Types | Text files
Find and remove unwanted pattern there -- I expect this to be index.php or very similar
Similar SO questions:
PHPStorm renders a particular file name as plain text
Pycharm utils.py not getting syntax highlight

Follow this steps:
Open PHPStorm settings by using Ctrl+Alt+S
In search box type File types
Select file types option from left side panel
Find PHP Files (PHP) from Recognized file types
Check for .php extension in below area (Registered Patterns). If not found add PHP.

Right click on index.php and select "Mark as PHP".
(This option is there on PHPStorm 7.x, I'm not sure about 6.)

Related

Why is my PHP file class recognized as text file?

I'm working on a Laravel project and when I was creating a new file I miss spelled the php extension ("php") but I didn't notice until I clicked enter so my PHP class files now appear as text files in PhpStorm and appears no hints whenever I write something in any php file.
Im using PhpStorm 2020.2.
Settings (Preferences on macOS) | Editor | File Types
Locate "PHP" entry in the top list (Recognized File Types)
Ensure that the middle list (File Name Patterns) has *.php entry there.
If it's not there then add it. Looks like you somehow re-assigned it to the "Text" file type.
Altought blade.php get recognized right,
That's because *.blade.php is assigned to separate/dedicated "Blade" file type (so IDE can provide Blade-specific support there).
And if you already did as #LazyOne suggested and your file still showing as text then right click the file and do this:

PhpStorm open file in a wrong format

PhpStorm is opening a php as an SQL file. I checked the extension and it is php but PhpStorm insist to open it as an SQL. I've tried to clear the cache but no use.
Go to settings and under Editor>file type.
add a file type that you want to add or may be you remove other file type.

How can I reformat Source Code for files without file extension in WebStorm 2016.1.3?

How can I reformat Source Code for files without file extension in WebStorm 2016.1.3 ?
Example: I've a automated_generated_json_file_without_extension in one line and the name of the files are always different. I don't want to configure all these file names in "File Types" Dialog and register new patterns.
In Sublime you can change the file type at the right bottom corner, is there a similar function in WebStorm?
Unfortunately you cannot change file type of the file on the fly in WebStorm.
Possible workarounds:
Have a set of files (e.g. test.json, test.js etc) somewhere in a project where you can copy-paste this file content, reformat it there and copy it back.
Use "Scratch files" functionality (Tools | New Scratch File...) and then the same copy-paste content to reformat.

Sublime text 2 find in folder with file extension

How do I search in a folder in sublime text 2 with file extension?
My where when I use:
*.js
searches globally for all js files.
If I try to restrict it to a folder:
/project/*.js
it matches nothing.
Instead of this:
/project/*.js
Try using this:
project .js
This should match files which have project in the path and have a .js extension
EDIT: The above assumes you're trying to find all the files with .js extension using the Goto Anything feature in Sublime Text.
In case you'd like to search within .js files located within a directory, you can add an Include Filter in the search path:
/project,*.js
This will search for the text you've entered, limiting the scope to files within /project and it's sub-directories having the extension .js.
Reference: Sublime Text Docs - Search Scope
EDIT 2: For Sublime Text 3, refer Simons answer below.
godfrzero's answer does not work in Sublime 3 as it actually includes ALL JS files plus ALL files in the project folder.
Instead, you need to specify it similar to how you had it originally...
project/*.js
Note that there's no leading slash, as that will treat it as an absolute path which you won't want in most cases. To include multiple file types within the folder, I think you need to specify it like this:
folder/*.ctp,folder/*.php
This will match any of the following files:
/app/folder/example.ctp
/app/folder/example.php
/app/folder/subfolder/example.ctp
/app/long/path/folder/subfolder/example.php
I know you asked about Sublime 2, but hopefully this helps others (like myself) who are Googling for such advice.
Simon.
My Sublime ver: 3.2.2
Adding to above answers, I was trying to find in all python files starting with test_ . so this is how I did it.
After pressing Ctrl+Shift+F, in the window.
Where : /home/WorkDir/test, test_*.py

Compound file extension syntax coloring with Sublime Text 2

I have some files with the extension "js.php" that I would like Sublime to automatically treat as Javascript files not PHP files. Is this possible?
I tried adding "extensions": ["js.php"] to my user settings and then setting View->Syntax->Open All With Current Extension As ->Javascript (while a js.php file was open) but all files with just a .php extension were opened as Javascript files too.
Take a look at the ApplySyntax plugin. It was written to handle just such a scenario.