PhpStorm: multiple projects with common core - phpstorm

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

Related

How to include software in PhpStorm project

I have just started using PhpStorm. In my project I am receiving a lot of undefined variable errors because I am creating a plugin for vBulletin.
I was wondering is there a way to include the main software I am working with in my plugin development, to avoid getting undefined vars, and functions? Kind of how the WordPress plugin development works.
For example I have my projects folder: c://wamp/www/projects/projectname/ and I have vBulletin in c://wamp/www/vb3/
I want to be able to tell PhpStorm "hey the core scripts to this project are here".
As LazyOne said I was able to achieve this using include paths.
Include paths are used for holding third-party code that is used for completion and reference resolution in some functions/methods that use file paths as arguments, for example, require() or include().
Note that the files added via include paths are not meant to be edited within the scope of your project. If you have the existing code that you need to access and modify from within several projects, consider adding it via an additional content root.
Do one of the following:
To configure the include paths for the current project, in the
Settings/Preferences dialog Ctrl+Alt+S, click PHP under Languages &
Frameworks.
To configure the include paths that will be applied to all newly
created projects, use the default new project settings (File | New
Projects Settings | Settings for New Projects ).
On the PHP page that opens, configure the list of include paths on the Include path tab:
Use Add and Remove to add and remove paths.
Use Move up and Move down to reorder the items in the list.
Click the Sort Alphabetically button to sort the paths alphabetically in the ascending order.

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.

Variable file include path in Flash Pro when build an android app using Air

As far as I know, the only way to include a folder in an Air package (in Flash Pro, not Builder) is through the GUI:
Publish Settings > Player Settings > General Tab > Included Files
... but it's kind of a huge hassle to manually add and remove folders over and over again if you have to publish the app with a dozen different versions of the content, you know?
Is there a way to conditionally include folders based on text somewhere - the app config xml, maybe? or something else that will be checked when the APK is compiled? That way I could just copy and paste in the folder name to switch which asset folder is being included, instead of going through the whole process inside of the flash IDE?
This idea might possibly be of some use although it could require some management due to possibly meaning you have duplicated assets.
I typically store all my assets inside an 'includes' folder/directory and just add this to the Settings > Include Files pane.
I also have folders which store the target specific includes, such as 'IOS' and 'ANDROID', (but aren't added to the Include Files pane).
When publishing, I swap out the contents of the includes folder. So it's just a case of deleting the existing contents if the includes folder and copy/pasting from the relevant source folder into the includes folder.
Hope that makes sense.
There are a couple of things you could do, though they're not 100% solutions per se.
1) Use conditional compilation:
Depending on how your imports/includes are set up, you could change it to always be the same file, but change the code/embed inside depending on a compile time constant. You can add a compile constant by going to File > Publish Paramaters > Flash (tab) > Parameters > Configure Constants:
Your constants would be in the form CONFIG::debug or FOO::bar, then in code, you wrap your code like this:
CONFIG::debug
{
// code is only included if CONFIG::debug is true at compile time
}
Then, by flipping constants, you can include or exclude blocks of code. There's a bit more detail here: http://divillysausages.com/blog/as3_conditional_compilation
NOTE: this is much easier to do in an IDE like FlashDevelop.
2) Use an external IDE
Taking the FlashDevelop example, when building for mobile, a number of .bat files are created. Depending on the environment vars set, you can include/exclude folders as you wish. I do this to include different assets depending on if it's a desktop, Android, or iOS build.
3) Use the Flex SDK command line or ANT
With either of these, you can specify a config.xml file for the files that you want to include. External IDEs (like FD) use the command line directly, so you can almost copy/paste the command if necessary.
For ANT, it's not my strongest point, but you can find out a bit more here: http://charlespatricknewman.com/blog/?p=325

Maintain 1 codebase for SWF that is sometimes standalone, sometimes module

I have an app that has been a standalone app 'til now; however, in another app it's going to be a wee little module.
Is it possible to somehow maintain 1 codebase when the standalone has a source tag of:
<mx:Application>
and the module has a source tag of:
<myModuleBase>
Or is it better to keep a separate branch and just merge them together when the standalone has new changes that I want to propagate to the other?
The standalone app will eventually be taken down as part of phase 2 of this new project but that is several months off and features may be added in the interim.
Can I do this with a separate application file?
Thanks for any helpful tips!
This shouldn't be too difficult to implement. (Disclaimer: I have not messed with modules in Flex)
You have two top-level files, appNameStandalone.mxml and appNameModular.mxml
Those only include the main mx:Application and MyModuleBase tags, and contain inside them an MXML component that represents the actual application.
//appNameStandalone.mxml
<mx:Application ...properties>
<myComponents:UIAndFunctionalityComponent/>
</mx:Application>
//appNameModular.mxml
<MyModuleBase ...properties>
<myComponents:UIAndFunctionalityComponent/>
</mx:MyModuleBase>
If you're not certain how to do this in practice (say, in Flash Builder), you can work under one project directory with two Flex Applications (Project -> Properties -> Flex Applications) or have two separate projects containing only the top-level MXML file with the source folders containing the remainder of the application in the build path (Project -> Properties -> Flex Build Path -> Source Path).
If I've got some misunderstanding as to how the modular version works, please let me know and I'll attempt to correct my answer.

Is there a generic Hudson reporter?

Our build has a variety of generated HTML reports. I would like to have those reported and accessible on the build page, like JavaDoc entries. Is there a generic way to expose these reports without writing a custom plug ins ?
If that isn't available, is there a way to post an HTTP link on the page ?
You can choose "archive the artifacts" and archive for example "reports/*.html"
These will appear under the project page under the heading "Last successful artifacts".
Even if you clear your workspace before each build, these artifacts are moved to a separate directory.
You could also add a build script which will modify or update a file in your userContent directory (since Hudson 1.299), and link to these build artifacts in yet another location.