PhpStorm is JetBrains' integrated development environment for PHP, based on IntelliJ IDEA. As of 2019, PhpStorm may be the best commercial PHP IDE. JetBrains offers PhpStorm for free for Tiki development.
In no particular order (yet) by
tiki-jquery.js:288
or even more amazingly tiki-jquery.js on line 288
And many more...
Wishes
This section is incomplete and likely outdated.
If you are a regular contributor to the TikiWiki project, then you may be eligible for a free license to PhpStorm kindly provided by JetBrains.
The license key you will have received, may be on several lines.
You must enter it exactly like that, without trying to "unwrap" the key into a single line.
Get PhpStorm from http://www.jetbrains.com/phpstorm/
Your IDE should now detect coding style automatically through the .editorconfig file.
/doc/devtools/TikiCodeStyleSettingsPhpStorm.xml. Is being kept up to date with .editorconfig by exporting the TikiCodeStyleSettingsPhpStorm.xml into .editorconfig format. Remember to re-add the comment in the top of the .editorconfig after exporting ๐
For how to manually apply settings, see the phpStorm 2018 tab.
Go to File -> Settings... -> Editor -> Code Style and in the drop-down menu next to the Scheme drop down at the top, select Import Scheme ->Intellij IDEA code style XML.
Go to File -> Settings... -> Editor -> Code Style and in the drop-down menu next to the Scheme drop down at the top, select Import Scheme ->Intellij IDEA code style XML.
This is the content of the third tab
To use the code style, select the code you want to reformat and navigate to Code -> Reformat Code. Any reformatting that can be done automatically to conform to the code style will be applied.
The CI will check your work when a commit is made. To have the same code style evaluation made on your code, with an inspection inside PhpStorm, follow the following steps:
You have to use the developer package for composer to install all the tools.
./temp/composer.phar install --prefer-dist --working-dir="vendor_bundled"
This will install the development packages from Composer.
Then you can run the following console command:
php console.php dev:configure
./temp/composer.phar install --prefer-dist --working-dir="vendor_bundled"
This will install the development packages from Composer.
Preferences -> PHP -> Quality Tools -> PHP_CodeSniffer -> Configuration -> ... -> PHP Code Sniffer path
Now that we have our Code Sniffer binary referenced we can check it is validated as an inspection.
''Preferences -> Editor -> Inspections -> PHP -> Quality Tools -> PHPCodeSniffer Validation
Now that we have our Code Sniffer binary referenced we will set up an inspection.
Preferences -> Editor -> Inspections -> Quality Tools -> PHP Code Sniffer -> ... -> Path to ruleset set to phpcs.xml.dist (in the tikiroot folder)
Make sure Coding standard is set to Custom
You now have near-realtime code sniffer evaluations set up. In addition to code style, it will warn about incompatible PHP.
To learn more read PHP Code Sniffer.
Choose a PHP debugger, either Xdebug or Zend Debugger, install and configure it on the HTTP server's side.
Xdebug is included in XAMPP.
To install Xdebug for PHP 5 on Debian, the following command may be used:
sudo apt-get install php5-xdebug
To install Xdebug under Mac 10.9 Maverick using MacPorts (couldn't manage to install phpunit) :
sudo port install php5-xdebug
To configure Xdebug on the HTTP server's side, the following settings could be used as a reference:
[xdebug] ; Remote settings xdebug.remote_enable = On xdebug.remote_cookie_expire_time = 100000 ; 1 day xdebug.remote_autostart = On xdebug.idekey = PHPSTORM xdebug.collect_return = On xdebug.collect_vars = On xdebug.show_local_vars = On xdebug.show_mem_delta = On xdebug.var_display_max_children = 512 ;xdebug.collect_params = 2
Some useful info on setting up xdebug and phpstorm to do remote debugging can be found here: https://confluence.jetbrains.com/display/PhpStorm/Remote+debugging+in+PhpStorm+via+SSH+tunnel, mainly the part about the ssh port 9000 tunnel - that's the bit that was missing for me
This section is outdated. You should probably skip it. 2017-06-26
PhpStorm expects to find the Php interpreter in a particular location (ex: on my mac, it's /usr/bin/php). But it could be that you are using an interpreter that is in a different location.
Here is how you can do that. The particulars of the steps seem to depend on the version of PhpStorm you use. Below are the steps as described originally by Jonny, and those for PhpStorm 6.0 (written by Alain)
File โ Settings โ PHP (open)
Interpreter > Add
Enter the following:
Name: "php on ubuntu" (free text)
PHP home: /usr/bin/
Debugger: Xdebug
โ See appear the PHP version (here PHP version 5.3.... )
The code edited needs to be in a PhpStorm project. If you are working on several Tiki versions, it is best to create one project per version.
PhpStorm allows using a single window for all projects or one window per project. Most Tiki developers seem to choose the latter option.
Open Run -> Edit configurations...
Click on the plus ("+") sign at the top and select "PHP Web Application".
Adjust the Name and Start URL fields and select OK.
PHPUnit allows us to run our code tests. If you haven't already, we need to be in Tiki's Dev Mode for this to work, so see the "Tiki Code Inspection (phpcs)" section if you have not already.
First, phpStorm needs to know where PHPUnit is Click Prefrences->Languages & Frameworks->PHP->Test Frameworks.
Now point "Use Composer autoloader" to vendor_bundled/vendor/autolaod.php.
The "Default configuration file" should point to phpunit.xml.dist
Now we need to add PHPUnit to the Run/Debug menu.
Click Run->Edit Configurations...->+ button -> PHPUnit
All you need to do here is name it, and make sure "Defined in the configuration file" is checked off.
On the above image, the yellow arrows point to Run, Debug and Generate Code Coverage shortcut buttons.
You may now do the following:
For Tiki 17 and above, in File -> Settings... -> Directories, mark temp/ as Excluded.
In Settings..., Editor -> File and Code Templates, Includes tab, set PHP File Header to something like:
// (c) Copyright 2002-2018 by authors of the Tiki Wiki CMS Groupware Project // // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. // $Id$
A custom search scope will make Find in Path faster and more relevant. In Settings -> Appearance & Behavior -> Scopes, add a local scope which can be named "Tiki proper".
To exclude vendor directories, you can use a Pattern such asfile:*/&&!file:lib/equation/*&&!file:lib/dracula/*&&!file:lib/ical/*&&!file:lib/openlayers/*&&!file:lib/swfobject/*&&!file:vendor_bundled/vendor/*/&&!file:db/tiki-secdb_*.sql
language.php files are a major slowdown. To exclude them only keeping - for example - French (fr) files, you could use a pattern like
file:*/&&!file:lib/equation/*&&!file:lib/dracula/*&&!file:lib/ical/*&&!file:lib/openlayers/*&&!file:lib/swfobject/*&&!file:vendor_bundled/vendor/*/&&!file:db/tiki-secdb_*.sql&&!file:lang//*||file:lang/fr//*
There are lots of plugins that can make work on Tiki easier, but here are a few of the most useful ones.
One of the most useful features I use regularly is the inline viewing of git logs. It can help you to see what was changed when it changed and what the reason was.
It has many useful inspections on code quality. It also offers auto-correct functionality to enhance some code "gotchas"
Makes filling out DocBlocks easer, with better auto-complete.
Makes filling out array keys easier with much better auto-complete.
Yup, another plugin to make auto-complete more useful.
This is a neat plugin that shows you where a function is called from. Shows it all nicely laid out in a tree. It can help visualize where functions are being called from. Often better than using a search feature to find function calls.
You may want to increase the maximum memory (Xmx) setting in Help -> Diagnostic -> Change memory settings if you have the default 750 MB limit and open several Tiki projects at the same time.
Since Remote Host does not support copy-pasting files, uploading changes to a server can be done by copy-pasting the whole contents of modified files.
However, this can change indentation, since PhpStorm reformats on pastes by default. There are 2 ways to avoid this issue. Furthermore, since PhpStorm considers all pasted lines as modified, it will feel free to remove trailing whitespaces by default when the remote file is saved. To keep the remote file as identical as possible, you need to set the "Strip trailing spaces on Save" setting in Editor -> General, Other section to "None". This has the unfortunate side effect of disabling trailing spaces stripping even in new code you write. To minimize the risk that you unintentionally add trailing whitespaces, you may enable Show whitespaces in Settings... Editor -> General -> Appearance.
To update a checkout, do VCS -> Update project....
If you have several projects, select the one to update.
Turn on Autoscroll from source option, so that the project browser repositions itself automatically to the page you currently have in the editors. That way, if you want to do an operation on the file you are editing (ex: delete, rename), or see other files in the viscinity, you can just go from the editor to the project browser.
To set this option on:
Make use of the various navigation and search shortcuts. One really powerful thing about those is that you can search for things by specifying parts of its name, that might not be consecutve. So for example, searching for a file with "tiki permissions" will find "tiki-debug-permissions.tpl".
Below are some of the more useful search and navigation shortcuts:
Useful tip from this 2015 mail:
Seems that the way I do merging of single commits in phpStorm isn't in their documentation, I think I just worked it out several versions ago (don't like manuals mostly
So here's what I do... let's say I want to merge a commit from trunk into 14.x...
The first thing to do is configure the branches in your project (you need that also to do "Compare with branch..." which is really handy too.
https://www.jetbrains.com/phpstorm/help/configure-subversion-branches.html
It should work out where trunk is, and last time I did it added branches, mods, third_party etc as branch locations, you can remove everything apart from branches from there (the lower box).
To do a merge, go back to the Changes panel - Working Copy info pane where the config branches link was and just under it is "Merge from..." - click that and the little drop down branch menu appears, click "trunk" (in this case) and you get the "Select Merge Variant" dialog, with "Quick Manual Select" button, should be obvious from there (?)
The other two options (merge all, only any use when merging an experimental branch back into trunk, but I've never used it, looked too scary!) and Select with pre-filter, which takes ages and ages on tiki, probably due to our extensive history (and svn being a bit rubbish at this).
Hope that helps, odd that it's not on their documentation (afaics)
jonny
P.S. Compare with branch instructions are here https://www.jetbrains.com/phpstorm/help/comparing-with-branch.html
When there are conflicts, the "Apply All non-conflicting changes" button needs to be used to reduce the list of changes to apply to those which conflict.
Since Tiki23.x and due to constant improvement of the Tiki Console previous options became capricious and require constant maintenance.
While it is possible to initiate a php script with arguments from the phpStorm watcher, it is advised to use the Tiki console that includes a scss
command to compile your SCSS into CSS.
Since Tiki21.2 (at some point previous options stopped working anymore) you can use the Tiki console that includes a command to compile your SCSS into CSS from within phpStorm in a convenient way.
/user/www/yourtiki/console.php
(the full path to the console.php of THIS tiki website)
scss:compile yourtheme
(set your theme name else ALL the themes will be compiled)
$FileParentDir$/css/$FileNameWithoutExtension$.css
Your SCSS should be compiled using the console.php command.
(you may have to restart phpStorm) for changes to be applied.
Note: depending your server setting you may need to change console.php permissions.
chmod 755 console.php
Some comments on the settings as shown in the screenshot above:
--no-color $FileName$
$FileParentDir$/css/$FileNameWithoutExtension$.css
/mytiki/vendor_bundled/vendor/leafo/scssphp/bin/pscss
Some comments on the settings as shown in the above screenshot:
--no-color $FileName$
$FileParentDir$/css/$FileNameWithoutExtension$.css
There are cases running the SCSS will throw an error (usually 255) and the log doesnโt give much information.
You can run the console.php equivalent command on your shell or terminal to compile your SCSS file from within your Tiki directory.
console.php scss:compile yourthemename
Note: if you donโt specify a theme, the command will compile all the themes and it is taking much longer
Console.php gives usually a better more verbose error message and helps to solve issues so you can continue to use phpStorm file watcher for SCSS.
If you get this error, it probably means that the permissions on your Tiki files are wrong. Typicall, when you run setup.sh, all the files in Tiki end up being owned by _www with _www as the group (unless you specify other choices). But on most platforms (at least on Mac), PhpStorm runs as your own regular user, which is not part of group _www.
Here is how to fix this issue on Mac. Details for other platforms may vary.
# First, add your username to group _www sudo dseditgroup -o edit -a yourusername -t user _www # Next, rerun setup.sh, but this time, specify # yourusername as the user, but leave _www as # the group sudo sh setup.sh # Then make sure certain directories are writeable # by the _www group. sudo chmod -R g+w db dump img/wiki img/wiki_up img/trackers modules/cache templates_c templates styles whelp
When attempting to run project '9.x' on 'LocalApache' server, I see these messages:
Cannot find PHPUnit in include path (.:/usr/share/php:/usr/share/pear)
Unable to attach test reporter to test framework or test framework quit unexpectedly
Once phpunit is installed (& phpstorm restarted), the error message dissapears.
When attempting to go to "Run > Debug '9.x on LocalApache'", I see this message at the bottom:
Error running 9.x on LocalApache:
Debug server doesn't exist. Check 'Remote' tab in run configuration editor.
Ok, after I added "localhost" as Debug Server, and run again "Run > Debug '9.x on LocalApache'", I did get these messages:
Testing started at 18:35 ...
Executing tests
Http request failed: HTTP/1.0 500 Internal Server ErrorE_WARNING: require_once(Zend/Cache/Backend/ExtendedInterface.php): failed to open stream: No such file or directory
E_COMPILE_ERROR: require_once(): Failed opening required 'Zend/Cache/Backend/ExtendedInterface.php' (include_path='.:/usr/share/php:/usr/share/pear')
Sometimes, nothing happens when you click on the Commit button.
When that happens, make sure you uncheckall the boxes in the Subversion and before commit section have to be unchecked.
You typically get this error when running the debugger PHP Script run configuration.
The error usually means that the PHP interpreter you are using does not have the xdebug extension installed.
To find out which interpreter you are using
To see if xdebug is installed for that interpreter:
pathtoyourinterpreter/php -i | grep xdebug
If the phpinfo doesn't contain any line with xdebug, it means it's not installed.
To install xdebug for use with PhpStorm, see the Configuring the Debugger section above.
If you notice that PhpStorm occasionally gets in a rut and becomes very slow in responding to your actions, it probably means that you haven't allocated enough heap memory to it.
The way to fix it is to add or change the heap size setting. From the main menu, choose Help | Edit Custom VM Options to create a copy of the idea.vmoptions
file in the user home directory. See PhpStorm's help page for more information.
For example, here is Alain's idea.vmoptions file:
-Xms128m -Xmx2048m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=96m -XX:+UseCodeCacheFlushing -XX:+UseCompressedOops
Although the graphical svn UI in PhpStorm is pretty good, there may be a time when you want to use the command line SVN.
If you do that, it could be that the command line SVN will complain that the current directory is in the wrong SVN format.
This is usually due to the fact that PhpStorm uses its own version of SVN (which is embedded as a Java library), and that it uses SVN data format that is more recent than the command line SVN you are using. For example, maybe your command line SVN uses the 1.6 format, while the PhpStorm svn uses 1.7.
There are two ways to deal with this
As of this writing (Oct 29, 2013), the easiest option for Mac users seems to be to redo the checkout, because macport doesn't seem to have version 1.7 of the command line SVN (which is what PhpStorm uses by default).
Free video tutorial to help you setting (Xdebug) and customizing PhpStorm: https://laracasts.com/series/how-to-be-awesome-in-phpstorm/