Shorthand notation for Yii commands in Git Bash and Windows Terminal

Developing PHP applications in Yii 2 makes you use Yii command-line commands quite often (for example for migrations). Since I am a Windows maniac that uses XAMPP, I have to type:

php yii

before each command each and every time.

A bit tiring so I wanted to make this a little bit easy. For example, to be able to type:

y migrate

instead of:

php yii migrate

Getting there was quite easy for Windows scripts and using Windows Terminal. Things has got a little bit complicated when trying to achieve the same in PhpStorm. Which uses GitBash instead of Windows Terminal.

Read More “Shorthand notation for Yii commands in Git Bash and Windows Terminal”

Navigating through selected text instances in Sublime Text 3

Ryan Urie‘s answer on StackOverflow has finally solved my little, but annoying struggle with Sublime Text 3’s key bindings (keyboard shortcuts) for navigating through all instances of currently selected text.

But that wasn’t enough for me! :>

Since ST3 is sometimes used by non-developers then these people my not catch up, how extremely important (to developer) is to be able to select addForeignKey method for example and to navigate through every existing instance of the same method call in entire file with simple keyboard shortcuts. This problem isn’t covered by default setting of Sublime Text 3 keyboard shortcuts and I had to deal with this myself.

Here is the ultimate solution to this problem. Quick and easy, as everything in Sublime Text.

Read More “Navigating through selected text instances in Sublime Text 3”

Keep Sublime Text 3’s replace panel open after replacing all elements

By default, if you open the replace panel (Ctrl+H) enter search and replace patterns and click Replace All button or hit Ctrl+Alt+Enter, replace panel will be hidden. This is very annoing to many users. However, there’s a partial solution to this problem.

This is tested only in Sublime Text 3, but should work in Sublime Text 2 as well:

  1. Select Preferences > Key Bindings — Default.
  2. Search for ctrl+alt+enter and copy entire block.
  3. Select Preferences > Key Bindings — User.
  4. Paste copied block anywhere and remove , "args": {"close_panel": true} part from it.
  5. Save Key Bindings — User and test it (you don’t need to restart Sublime Text).

Since, you have just modified key binding, then you should remember, that expected behavior will work only if you execute Ctrl+Alt+Enter inside it. If you click Replace All button, the “old” behavior will be applied — i.e. replace text panel will be closed.

Posted to Stack Overflow.

Sublime Text 3’s user configuration

As you probably know, there are no configuration dialogs, windows or generally any UI to click-through configure your Sublime Text 3. Actually, nearly everything is customized by editing ST3 configuration files.

Default configuration file is very well documented, but it is quite long and may be overwhelming. To help some of you with that problem, I wrote this article, where I show the list of configuration settings that I changed in my own development environment, that you may find interesting or at list worth considering.

Read More “Sublime Text 3’s user configuration”

Netbeans-like keyboard shortcuts in Sublime Text 3

I’ve been using Netbeans for over five years. Though it is so deadly slow, I didn’t manage to change to Sublime Text 3 (which is extremely fast) up until now. Five years of constant use of some program causes that you get used to it very hard and you’re very opponent to any changes.

This blog entry is supposed to help you configure Sublime Text 3 in the way as close to Netbeans as possible. But, Sublime Text 3 is not Netbeans. You’re able to achieve a lot of similar functionality (plus a lot more of things that you could only dream about in Netbeans), but there still be a span of things that are not replicable.

Read More “Netbeans-like keyboard shortcuts in Sublime Text 3”

Force Sublime Text 3 to auto-pair quotes before semicolon

By default, Sublime Text 3 will not auto-pair quotes (add closing quote, when you enter opening one), when following character is a semicolon (;). This is a little bit unhandy for PHP developers.

But, since nearly everything in Sublime Text 3, this can be easily tweaked, by changing ST3 configuration.

You’ll find all the details in this wonderful Stack Exchange answer, made by MattDMo after my question asking, how to fix this problem.

Read More “Force Sublime Text 3 to auto-pair quotes before semicolon”

Useful plugins for Sublime Text 3

Sublime Text 3 is powerful and really kicks ass even in its bare installation. But, when you power it up with proper combination of plugins it simply kills entire life on the planet!

Package Control claims to have over 1800 plugins for Sublime Text 3. Browsing this number of them seems impossible. Many of them are abandoned, some are for very specific reasons.

In this article I am only listing just a few plugins that I am using within Sublime Text 3.

If you’re reading this text, I assume, that:

  • you have Package Control installed and
  • you’re after reading my Beginning with Sublime Text 3 article.

If not, skip back and pass these two points.

Read More “Useful plugins for Sublime Text 3”

CTags and Goto source definition in Sublime Text 3

One of the most important functionality of each high class IDE is “Goto source definition” mechanism, which let you click particular symbol (i.e. class or method name) in any source file of your project and be immediately redirected to file (and line) that contains its definition.

Sublime Text 3 is not supporting this functionality natively. But, we can add it quite easily, using CTags plugin.

Read More “CTags and Goto source definition in Sublime Text 3”

SublimeCodeIntel and Code intelligence in Sublime Text 3

There’s an article about using CTags plugin to implement “Goto source definition” functionality in Sublime Text 3 — a mechanism, which let you click particular symbol (i.e. class or method name) in any source file of your project and be immediately redirected to file (and line) that contains its definition. You’ll find it here: “CTags and Goto source definition functionality in Sublime Text 3“.

This functionality is often called “Code intelligence” and there is another plugin — SublimeCodeIntel — that implements it in Sublime Text 3. If you want this kind of functionality in Sublime Text 3, but don’t want to use CTags plugin, this article will tell you more about alternative to it.

Read More “SublimeCodeIntel and Code intelligence in Sublime Text 3”

Working with code snippets in Sublime Text 3

This is another article about my transition from Netbeans to Sublime Text 3. This time I’m going to handle code snippets topic. This is another area, which is much better solved in Sublime Text 3 than in Netbeans.

This article is generally based on “Working With Code Snippets In Sublime Text” blog text from And — of course — wonderful, yet unofficial Sublime Text documentation’s chapter about snippets. With some my personal additions and updates.

Read More “Working with code snippets in Sublime Text 3”

Useful keyboard shortcuts in Sublime Text 3

This is one of the last article in my private serie of blog entries targeting developers, who starts their journey with Sublime Text 3. Treat it as memo or list for easy remembering sometimes very useful, not always often, keyboard shortcuts, that are available in ST3. Where it is possible, I’m adding links to Sublime Text Unofficial Documentation, which is great source of information in any aspect related to Sublime Text 3.

Note, that entire document is based on default Sublime Text 3 key bindings, before any user changes, like for example those mentioned in [Netbeans-like keyboard shortcuts in Text 3.txt] text. Also note, that when speaking about Alt key, I’m referring to left key. As on some non-English keyboards, right Alt key may have different meaning (entering language-specific letters etc.).

Read More “Useful keyboard shortcuts in Sublime Text 3”

Beginning with Sublime Text 3

My journey started with reading (and watching videos) two good blog entries done by Stuart Herbert:

However, both texts are old and covers Sublime Text 2 only. And both are quite long. If you want a shorter version, updated for Sublime Text 3, then read on…

Note, that this article is filled with many comparisons to that Netbeans. Intentionally. I’ve been using Netbeans for past five or more years. And from the first day, I started using Sublime Text 3, I feel like I’m a newborn developer again. And I finally have super-fast, super-powerful IDE instead of old, slow, buggy, cranky Java-based Netbeans. Whoa! :]

Read More “Beginning with Sublime Text 3”

Changing sidebar’s font size in Sublime Text 3

Changing font size of editor (by adding "font_size": 14 for example to Preferences > Settings – User file) changes font size of editor area. But leaves font size of sidebar unaffected. I have found files and folders’ names, drawn on sidebar with 10 pt font size, quite not so comfortable on Full HD resolution screen.

So, I needed a fix.

There’s (of course!) a Stack Overflow answer, that explains, how to achieve this in Sublime Text 2. I managed to port this solution to Sublime Text 3.

Read More “Changing sidebar’s font size in Sublime Text 3”

Setup PHP to use Xdebug in Netbeans

This guide shows, how to setup Netbeans (edition for PHP developers) and local PHP interpreter with Xdebug — a world famous on-line debugging tool for PHP.

Since I’m using XAMPP package as my server in development environment, you may find some references to it in this text. But most of it should be clearly readable to anyone using Netbeans and Xdebug.


Double or even tripple check, if you have correct Xdebug configuration (see below)! I was fighting with some stupid bug for nearly two days only to find out, that it was caused by incorrect configuration. During that time I’ve read more than a dozen guides and each time I run into “Configuration” section or “check your configuration” statement I was always automatically assuming: “yes, yes — it is correct“. As it turned out (after two days), I was wrong and configuration was not correct. Don’t repeat my mistakes and don’t waste your time so stupidly!

Also, keep in mind, that if you’re using Windows 7 or newer version and you’re running your webpage locally, you should definitely use address everywhere, instead of localhost. This will give you a much faster performance, speed and server response times. Follow to Stack Overflow, to this answer to find out a detailed explanation, why this is happening.

Which Xdebug for me?

First of all, get correct version of Xdebug for your PHP environment. As you go to Xdebug’s download page you will notice, that list of available editions is long enough to get a headache.

You must closely match version of Xdebug to:

  • your PHP version (5.3 or similar),
  • your system / platform version (either 32-bit or 64-bit),
  • version of compiler used to compile your PHP version (not Xdebug itself), for example VC6, VC9 or VC11,
  • and finally, whether your PHP was compiled in thread-safe mode (TS) or in non-thread-safe mode (Xdebug version without TS addition).

And this can be a hard task.

To make it easy, Xdebug author has provided us with tailored Installation Instructions.

Setup Xdebug

Installing Xdebug in your PHP is easier than most guides shows.

Locate and open php.ini in your editor. Remember, that PHP is Linux/Unix software at first, only ported to Windows, so pay attention to use text editor that supports Linux line endings (LF). Make sure, that you don’t write changed php.ini with Windows line endings (LF&CR). If you see everything in this file bloated in one line (for example after opening in Notepad), then this is clear evidence that you’re using wrong editor.

Locate extensions part of php.ini and after last extension= add a new line with extension=xdebug.dll. Supply correct filename, you’ve copied to ext folder.

Then hit Ctrl+F to locate [Xdebug] group and do some Xdebug configuration changes there. List of options is quite long, some of them may already be selected other are commented-out (ignored). After, a fairly good, but bloaty and poorly written article I cite, that you should consider at least these settings:

zend_extension = C:xamppphpextxdebug.dll

Make sure, that zend_extension points to correct location of your Xdebug DLL.

Consult above mentioned article for more details on each option, you enable here. I only wanted to have Xdebug working and to be honest I didn’t much care what am I setting here.

If you’re using Zend Optimizer, you have to disable it, by commenting out any zend_optimizer settings in php.ini. Consult above article for more details on this. I don’t have Zend and all, I don’t like it (too heavy) and I don’t care.

Restart Apache and carefully check, if there are any errors reported during startup. Either as message box or in Apache’s logs. Correct anything that looks wrong or suspicious.

Run any PHP script with phpinfo() command to display environment information and use Ctrl+F to determine, if your installation of Xdebug is OK. If you find xdebug group, followed by xdebug support -- enabled information, then you’re fine. Congratulations!

Setup Netbeans

Run Netbeans, if it is not running yet and open your project inside.

Open Tools > Options and go to General > Web Browser to set your prefered web browser, that will be used in debug process. The best option seems to be selecting internal browser, to not get crazy of pressing Alt+Tab all the time to switch between browser and Netbeans. But see some side notes on this below.

Configure debugger in Netbeans, by opening Tools > Options and going to PHP > Debugging. You should leave most options in default states. The only thing you may consider is unchecking Stop at First Line checkbox.

And… you’re done! :]

Note, that Netbeans powered by Xdebug can easily debug simple websites and pure-PHP applications as well as complex apps written basing on any framework.

Debugging with Xdebug and Netbeans

Set some breakpoints and click proper toolbar icon or hit Ctrl+F5 to start debugging your currently selected Netbeans PHP project.

Debugging of your project should start. And your webpage or application should be opened in external or internal browser, according to your selection in Netbeans configuration. If there are any problems at this stage, you can always click your project (in projects tree) with a right mouse, select Properties from context menu and go to Run Configuration section. Check, if everything is OK there, at first place.

When your application or webpage start in debug mode, Netbeans will switch to selected browser (either internal or external). If execution flow is halted by an error or breakpoint, you’ll be switched back to your code only in case of using internal browser. In you’re debugging in external one, you have to manually switch back to Netbeans.

Once your debug starts, you get access to all debug information, Xdebug can get out of your webpage or application and provide to Netbeans. You can see all variables available in current context. If debug stops on any of your breakpoints or run into an exception, you can see entire call stack of your current context.

After stopping on a breakpoint you have access to all standard execution flow control functions like Step Into (F7), Step Over (F8), running to cursor etc.

To end current debug session, press Shift+F5.

Some browser side-effects

For debugging process (as well as for simple running your project) you can use either internal (based on WebKit) or external browser. You set it in configuration, in Tools > Options > General > Web Browser. There are some side-effects depending on what you actually choose.

When choosing external browser, you can test your application in any environment you would like. But you have to switch manually between Netbeans and that browser, each time something change in execution flow (an error, a breakpoint etc.) or each time, you want to check a variable, stack trace etc. You can also end up bloated with browser’s tabs (or even windows), because Netbeans opens up new one for each debug session initiated and second one with “DEBUG SESSION ENDED” message, once your done in current debugging session (this is most initiating).

I don’t know, why it (or Xdebug or browser itself) can’t take over existing tab, especially because it uses the same Xdebug token (netbeans-xdebug) all the time. Opening new tabs or windows for each new debug session was understandable in Eclipse, because that IDE uses different token for each debug session. In Netbeans this has to be some bug, especially that when using internal browser, it can always work on one and only tab. As I said, I don’t know, why this is happening. But this is stupid, annoying and was key factor for me to choose internal browser instead.

If you do the same and choose internal browser, you have to suffer the fact, that altough it is based on a WebKit (not ugly, pesky, standard-less IE), but it still far from general browsers development stream. Which means, that your website or application will lack some newest solutions and in general may look a bit different than in external browser. I think, this is acceptable, as we’re using internal browser only to catch-up bugs and fix them. And once they’re fixed, we finally test application in external browser, so everything is fine at the end.

Using internal browser is also convenient, because Netbeans will automatically switch you to code tab, once it reaches a breakpoint or an error.

Netbeans opens up internal browser window (tab) automatically, after you press Ctrl+F5 to start the debug process, but it can’t close it after debug session ends. Probably another stupid bug in IDE. So, in current version (7.3) you always end with _DEBUG SESSION ENDED_ message once you’re done with debugging and there is no auto-going back to code. But, in case of internal browser, it can be easily worked around. Simply learn yourself to press Shift+F5 (terminate debug session) followed immediately by Shift+W (close internal browser tab).


I must admit, that I was quite surprised on how good Netbeans and Xdebug works together in debug process of a PHP application. After all, PHP is a scripting language, where general application execution flow is request-reply based. But these two binded together lets you debug it nearly the same as you would debug any standard application. I.e. allowing to stop on breakpoints, giving you full flow control (including fabulous Run to Cursor) and even working perfecly on complex, framework-based applications.

Xdebug is a famous debugging tool for PHP. Maybe even the most famous. The other one is ZendDebugger. I haven’t got chance to check it out, because Zend and Microsoft agreed some time ago that the only stable way of running PHP on Windows is NTS mode (non-thread safe mode). Zend followed that and since PHP 5.2 started to publish only NTS versions of ZendDebugger. Unfortunately my server package (XAMPP) was not invited into that Microsoft-Zend meeting, was not part of that agreement and does understand, that running PHP on Windows in thread safe mode is the same as in non-thread safe. And continues to publish PHP in TS mode only. In other words, I haven’t got chance to check out ZendDebugger, because it is not available for me. But since Xdebug does the job perfectly and since I don’t like Zend at all, I’m fine and happy with that.

Netbeans vs. Eclipse

Netbeans is much slower and has a lot of bugs, but even so I decided to continue using it for my PHP development environments. There are few strong arguments, which beats Eclipse like a hell. Here you’ll find why. I’m trying to answer here, why quite experienced developer (that would be me! :>) decided to use less stable, slower and more buggy IDE than Eclipse.

Keep in mind, that I’ve been using Eclipse only for a few hours, while Netbeans over three hears. This may influence my judgement.

Read More “Netbeans vs. Eclipse”

Correcting code completion in NetBeans

General code completion in NetBeans works quite good (expect for its speed), but since NetBeans was made for Java and has only “added” support for PHP then it has some issues code completion for PHP and for coding in Yii framework it fails nearly completely.

Here you’ll find approach to fix this and make Yii developers using Netbeans life a little bit easier.

Read More “Correcting code completion in NetBeans”

Forcing default encoding on all files in Netbeans

A default file encoding for every file in Netbeans is defined at project level — see Project Properties dialog, Sources category. But there’s nothing similar (possible) for particular files without a project. If you’re using Netbeans just as an editor then all files opened from outside any project will be scrambled, because Netbeans is not using UTF-8 encoding by default on all files.

Read More “Forcing default encoding on all files in Netbeans”