PhpStorm and workspace issue - phpstorm

I have the newest version of PhpStorm.
Previously I worked with Eclipse and had the opportunity to see my whole workspace. In PhpStorm I need to open one instance per project.
In my daily workflow I need to search for strings in my workspace. In
PhpStorm I would need to switch from instance to instance and need to execute the string search again and again per instance.
Is there another solution or do I really need to execute my search multiple times?
In addition eclipse had the "Open Resource" function for the whole workspace. Does PhpStorm offers the Open Resource for whole workspace too?

In PhpStorm I need to open one instance per project.
That's correct -- currently having more than one project in one frame is not supported.
https://youtrack.jetbrains.com/issue/WI-15187 -- watch this ticket (star/vote/comment) to get notified on progress.
Is there another solution or do I really need to execute my search multiple times?
You can always attach any folder (from any project) to current project as Additional Content Root (will be listed as separate branch in Project View panel).
Settings (Preferences on Mac) | Project | Directories --> "Add Content Root" button.
Note that it will still be treated as one project (no separate settings) -- additional content root is treated as just a bunch of files/folders.
In addition eclipse had the "Open Resource" function for the whole workspace. Does PhpStorm offers the Open Resource for whole workspace too?
Look for commands under Navigate menu.
Navigate | File... Ctrl + Shift + N (using Default keymap) is
most likely what you need.
Useful info:
https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+for+Users+of+Eclipse+PDT+and+Eclipse-based+IDEs
PhpStorm has separate keymap that similar to what Eclipse uses.

Related

PhpStorm: multiple projects with common core

Due to security reasons, I have to split one project to divisions (client, admin, ...), and deploy them to different web servers. These divisions have one common script base, but each division has its own functions. As an IDE I use PhpStorm.
The question: what is the best way to organize project's structure and settings, so the common core part will be visible for IDE indexing in all project's divisions, but at the same time, being maintained from a single project (perhaps, standalone)?
In Java you can do lib jar files for further linking in various projects.
But how it can be done in PHP?
There are multiple ways of how to reference extra PHP code in a project.
If you plan to actively edit such extra code in the same project (and want to see their TODOs, code inspection warnings, include references in code refactoring etc):
You can just add it as an additional Content Root: Settings/Preferences | Directories. Folder added this way will be treated as a part of the project itself and will be shown as a separate node in the Project View panel (just as the main code, which is a Content Root as well).
Or you can open 2nd project while 1st one is already opened and when asked, just chose "Attach":
It's not going to be full 2 projects in one frame, more like something in between attaching Content Root and having 2 projects opened in separate frames.
https://www.jetbrains.com/help/phpstorm/opening-multiple-projects.html
Simple symlink will also do the job (but you need to place it somewhere in a project, e.g. PROJECT_ROOT/libs/my_symlinked_code). You then will need to provide a path mapping for that folder for debugger (if you will debug it of course) as PHP/Xdebug works with "final/resolved path" while IDE works with the path as is.
If you do not need to actively edit that extra code in the same window (and ignore any TODOs, code inspection warnings and other inspection results etc):
Do it as a composer package then? Composer can use custom sources (e.g. GitHub repo or a folder on a local filesystem).
Just add the path to that folder as a "Include Path" at Settings/Preferences | Languages & Frameworks | PHP --> Include Path tab. Code referenced this way is meant for 3rd party libraries (the code that you just use but not edit, e.g. framework code, your send mail/ORM library etc). Composer packages will also be included here by default.
https://www.jetbrains.com/help/phpstorm/php.html#include-path-tab

How to attach a project without mixing class declarations in PhpStorm?

I like PhpStorm's ability to attach multiple projects to the current window:
I've noticed, however, that all classes declared in both projects are available in both projects, which can lead to duplicate declarations:
I understand how this can be useful at times, however I'd like to attach projects just to navigate easily between them (I prefer this to switching windows), while keeping them separate as if they were in separate windows.
Is this possible?
Currently IDE does not have "scoped indexing" that may be able to resolve this. Right now you would need to exclude such duplicate files or tell IDE to not to treat them as PHP so they do not get indexed as such.
Your current options:
Use Mark Directory As | Excluded via context menu in Project View panel (or manually via Settings (Preferences on macOS) | Directories) for a folder(s) from additional project.
Mark individual files as Plain Text via context menu in Project View panel. The downside: such "marking" is IDE-wide as far as I know, so the same file path will be excluded in another project as well.
Any other exclusion mechanic that is currently available (e.g. Settings (Preferences on macOS) | Editor | File Types | Ignore files and folders -- global as well and based on file name only and file will be completely ignored from all operations... so not really acceptable for your case).
Consider watching after https://youtrack.jetbrains.com/issue/WI-17646 (star/vote/comment) and related tickets to get notified on any progress.
If they are the same classes, have you thought about making a composer package for them? Would be easier to manage it all I think.

How do you reopen messages.json in Sublime Text (3)?

I read packagecontrol.io's doc
regarding messages.json, but what I'm referring to is the file tab that sublime text typically displays upon a new package install. It appears as a continuous roll of installation notes throughout multiple installations. It appears that this is a feed of the individual messages.json files displayed when the packages are downloaded. Is there a way to open the unified file that displays messages from multiple packages? Or is there a more common way to access these package files?
What you are asking about are the install and release messages pointed to by those keys inside messages.json. For example, from one of my packages,
{
"install": "messages/install.txt",
"1.2.1": "messages/1.2.1.txt",
"1.3.0": "messages/1.3.0.txt",
"1.3.1": "messages/1.3.1.txt",
"1.4.2": "messages/1.4.2.txt",
"2.0.1": "messages/2.0.0.txt",
"2.1.1": "messages/2.1.0.txt",
"2.2.0": "messages/2.2.0.txt",
"2.2.1": "messages/2.2.1.txt"
}
Whenever someone installs the package for the first time, Package Control prints the contents of messages/install.txt to that new view you mentioned. It will also print the file corresponding to the current release, which is a "release" tagged on Github. If I were to go and release 2.3.0, for example, and not update messages.json, no update message would be printed telling users I'd pushed out a new version. In some cases this is desirable, in case I had to quickly push out a point release to fix some stupid mistake I made in a major (or minor) release, not that I've ever done that before :) But, in most cases, I want to keep users up to date on development, so I'll write a message for them in a new file, and add an appropriate key and value to messages.json.
Is there a way to open the unified file that displays messages from multiple packages? Or is there a more common way to access these package files?
The view that opens and shows you the messages from all the newly-installed and -upgraded packages is unique to you and your particular situation - there is no way to recover it once you close the tab. However, if you're interested in a particular package's message(s), just use PackageResourceViewer (in ST3) to open the package, view the messages.json file to see which is the most recent file you want to view, then find and read that file. In ST2 all packages are already unpacked in your Packages folder.

PhpStorm perpetual favorites

In NetBeans, I was able to add a folder to the Favorites window and it would stay there across all projects. This was super helpful for me to quickly access my .ssh folder and some other deeply-buried folders in Windows that I often need to get into (like C:\Windows\System32\drivers\etc and C:\xampp\apache\conf\extra).
Is there a way to pin those somewhere in PhpStorm so I can always get to them, regardless of what project I have open?
In PhpStorm (and other IDEA-based IDEs) favorites are project-based only.
The only possible alternatives I can think of:
Custom plugin that adds dedicated button into FileChooser dialog (like File | Open..., File | Open Directory..., File | New Project | ... and many other places -- anywhere where you can call dialog to choose the path the the file or folder).
Here is a screenshot with one Global favorite folder added (called from File | Open...)
Create and use External Tools for such tasks. The idea here is that you just call Windows Explorer with path of folder to be opened.
You can keep such commands under one sub menu/group (e.g. "Fav Folders") so they do not mix with other entries.

PhpStorm multiple project navigation, quick switch between projects

How can I open few projects in left work area in PhpStorm? I need to quick switch between projects.
If you want to open more than one project in this way (and by this I mean so they have their own different settings), then currently it is not possible.
http://youtrack.jetbrains.com/issue/WI-15187 -- vote/star/comment to get notified on progress.
If you need to include files from those projects for reference purposes (to see how you have done it there, to copy some code from there etc) -- you can include them under "External Libraries" -- Settings | PHP | Include paths. Files included this way are protected from modifications.
If you need to modify those files ... you can add them into actual project as Additional Content Root (Settings | Directories| Add Content Root) -- such folders will be treated as part of the actual project with no separate settings.
Other than that -- Alt + Tab (or whatever the shortcut is on your OS) to switch between different PhpStorm windows (each project is opened in separate window/frame).
This is a right on time answer.
It is possible to quick switch between project by adding a keyboard shortcut to the "manage project" menu.
To do just that, go to Settings > Keymap and search for "Manage Projects". Then add it the keyboard shortcut you desire and you're all set.
Hope this will help someone looking for an answer like I did.
As LazyOne said, you can add paths to your project from Setting | PHP | Include paths or from the useful keystroke F4.
But I'd like to also share how I organise my projects, I think when you create a project, you should not open a new window but instead open it in the same window.
This way you don't get confused between the different opened windows.
In settings you can assign a keystroke to Reopen recent projects. I then use ctrl + shift + R but it is up for you to chose the keystroke you like.
Hope this will help you as I struggled as well to find a way to manage all my current projects.