Including projects in other projects in PHPStorm - phpstorm

Say I am working on a couple of PHP projects named Framework and Application, where the latter is using the former. When I dive in the Application's classes, I see some of them extending Framework's classes, for example:
class Application_Controller extends Framework_Controller
When I hover mouse over Framework_Controller and click Ctrl, I want the name to become clickable link upon clicking on which the source code of the Framework_Controller class from the Framework project will be opened.
Currently I have achieved almost the same thing by adding the Framework codebase path to the "Include path" list (having the Application project opened, go to File/Settings/PHP). The Framework codebase tree appears under "External Libraries" in the Project window. So when I click on Framework_Controller as described above the Framework_Controller class file gets opened indeed. However, PHPStorm does not take into consideration that the file actually belongs to another project named Framework — it just opens the file. This has the following disadvantages:
On the top navigation bar, the full path to the file is shown (i.e.
starting from "/") rather than starting from the Framework project
root directory.
If I want to edit the file (and possibly more related files in the Framework codebase), I would have to manually switch to the Framework project window and find the same file in there.
So I am wondering if there is any way I could tell PHPStorm that the Application project uses/includes the Framework project, so that when I click on Framework_Controller as described above, the Framework_Controller class file gets opened in the Framework project window rather than just a file external to the Application project.

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

Exception Breakpoint fires when copying View Controller between projects

I've customized a tutorial and am trying to import it into my project. After copying one View Controller Scene from Document Outline into my main project, it's throwing an exception without any description of the issue. The View Controller is subclassed, so I've made sure to import the associated Swift file and set it in Document Attributes.
I don't know how to troubleshoot this one.
===EDIT===
I'm at a total loss here. I created a new project and was able to import, build, and run the project. The only difference between my main project and the new one is the VC is not the initial View Controller.
The tuturial was written in XCode 11 and Swift 4. I haven't upgraded yet, but again I was able to import into a new project w/o issue.
Check the Connections inspector (the last option on the right sidebar) and make sure there are no connections with exclamation marks (!) after them.
If there are errors, check in the Identity inspector (the third option from the left on the right sidebar) if the class of the view controller is correct.
If the connections are not needed anymore (you gave the outlet a new name etc.), remove them by clicking on the X next to them.

PhpStorm - Create normal HTML, JS, CSS project

Is it possible to create a simple Project which only uses HTML, JavaScript and CSS, or do I have to use netbeans?
I tried to start a new project, but I have only these options:
and I am not sure what "HTML5 Boilerplate" is.
Just use the top most "PHP Empty Project" option.
If you do not have local or remote PHP -- just choose <no interpreter> option for "CLI Interpreter" field.
In the end you will get empty project.
Alternative solution:
Create empty project folder using your file manager/terminal.
Using PhpStorm use Open from Welcome screen (or File | Open Directory if you have some project already opened") and point to the project root folder -- IDE will create new project (or reuse existing one (if it finds .idea subfolder)) from those files.
I am not sure what "HTML5 Boilerplate
You may click on blue link on the top right corner of that screen and it will take you to the GitHub page for that project.
From there: https://github.com/h5bp/html5-boilerplate
HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.
This project is the product of many years of iterative development and combined community knowledge. It does not impose a specific development philosophy or framework, so you're free to architect your code in the way that you want.

Add containing folder to project in PhpStorm

I'm developing a plugin for Moodle and created a project inside my Moodle installation. I'm extending a class called block_base but PhpStorm says undefined class block_base. My guess is that is because all the moodle files (including the class block_base) aren't in the project files.
How do I add this to the project files? I could just simply make the entire Moodle installation the project but I don't want that because i'm using GitHub and I then have to put all of the Moodle files on there as well and that is just pointless.
PHPStorm can handle multiple git roots within a single project (this is how I manage my plugins).
So, you can do the following:
Check out a copy of the main Moodle repo (from git#github.com:moodle/moodle.git)
Put your plugin (including the .git subdirectory) in the correct place in the Moodle code
Set the whole of the Moodle code as the project for PHPStorm
Go to File > Settings > Version Control
Usually PHPStorm will (at the bottom of the dialog) display a list of detected git roots and you can just click 'Add root'. If not, click on the '+' on the right and add the path for your plugin.
Now, you can make changes to your plugin and update, without having to check in a full copy of Moodle (as an added bonus, it makes it nice and easy to pull the latest Moodle code, so you can test your plugin against upgrades).

Adding an external jar library to Intellij IDEA

I'm having a silly problem : I'm trying to add the Jsoup library (which is just an external jar) to my android application developed in Intellij Idea and it seems and don't do it right .
I put the library in the libs folder , then I went in Project Structure -> modules and selected dependencies , select add global library , select attach source and click ok.
When I write code it is able to automatically import classes and to compile , but when running I get " java.lang.NoClassDefFoundError: org.jsoup.Jsoup"
Copy the .jar file into your lib/ directory.
Right click the new .jar in the lefthand file browser in IntelliJ / Android Studio
Choose "Add as Library..."
Voila!
-Open the External Libraries node on the Left hand panel.
-Select Open Library Settings
-Project structure dialogue opens up.
Select the Libraries.
Click the "+" to browse the file.
![add external jar1
In IntelliJ IDEA 15 you can also access the Project Structure menu item from "File" item in the menu bar. Select Libraries from the list on the left. Click the "+" to browse the file, select it and you're done. It will be added to the "External Libraries" directory in your project.
Have a look at the newer artifacts section. Perhaps you don't add the JAR into your deployment properly.
UPDATE:
I'd like to update my answer based on lessons learned over the past six years since I first answered this question.
The best way to manage 3rd party JAR dependencies in Java projects is to learn Maven (my preference) or Gradle. IntelliJ has terrific integration with both.
If you combine those with an enterprise repository like Nexus you'll have no problems. Your dependencies and versions will be completely specified. Conflicts will be identified for you. Updates will be relatively simple.