• Home
  • About
  • Contact
  • tweets by me

    About me
    • Achievement unlocked: killed our Crucible server with a Code review for one refactoring :) 2012-10-10
    • I think the code review I 'gave' to my co-worker is one in the category _BAMBAM_! ..sorry.. 2012-10-10
    • Still recuperating of #phpnw12 super event but the lack of sleep before and during the event has worn me down a little :) 2012-10-09
    • More updates...
  • Recent Posts

    • Live templates in phpStorm
    • phpStorm and component-based projects
    • DocBlox is unmasked … it is really phpDocumentor 2!
    • Outputting formatted XML using PHP
    • SSH Tunneling across multiple hosts in Linux
Next Page »

Live templates in phpStorm

Feb 22
Posted on February 22nd, 2013 In category Articles  PHP 
By mvriel Tagged as phpstorm  templates  tips 

For phpDocumentor I have the strict rule to apply a File DocBlock on the top with the necessary legal information such as copyright, license information and where to find the homepage. Anytime I add a new file, I have to open another existing sourcefile, copy the File DocBlock and paste it into the new file.

Of course this was too much effort for me so I wanted a quick way to add these DocBlocks without having to switch context. Luckily phpStorm offers such a functionality using Live Templates.

These templates allow you to define code snippets and assign an abbreviated name for them. When you need one of those in your editor all you have to do is press the shortcut key Ctrl+J, type the name of the abbreviation (of course there is auto-completion) and press ‘enter’. phpStorm will insert your code fragment of choice there and you did not have to copy-paste or switch context.

So any time I need a File DocBlock I type: <CTRL+J>phdfd<ENTER> and that’s it!

Another great thing about Live Templates is that they support placeholder locations (variables); that you can define by inserting a string surrounded by dollar signs ($). phpStorm will understand that this is meant to be a location where, after inserting the template, the mouse cursor should jump to so that you can start typing.

If you use phpStorm I really recommend investing a little time to get to know Live Templates, they can speed up your work significantly when used efficiently.

No Comments »

phpStorm and component-based projects

Mar 28
Posted on March 28th, 2012 In category Development  PHP 
By mvriel Tagged as modules  phpDocumentor  phpstorm 

For phpDocumentor I sometimes need to edit both a template and the main project in tandem to fix an issue. A sub-optimal solution as it is a clear sign of code coupling yet sometimes your template just relies on a bugfix or new feature in the host application.

Previously I always opened 2 phpStorm windows to manage this and this was always a bit unsettling. As much as they are two separate components, they are still two pieces of one final puzzle.

And then I remembered the directories panel in the Settings. There you can define multiple ‘content roots’ which actually act as modules in one project file. phpStorm even knows how to manage the version control for these separate roots, making it ideal to manage multiple components from one project!

This is what your project looks like afterwards:

Here you can clearly see that my project structure now contains two ‘main’ folders instead of one. It seems simple but it is actually pretty neat when working with component-based projects.

No Comments »

DocBlox is unmasked … it is really phpDocumentor 2!

Mar 16
Posted on March 16th, 2012 In category PHP 
By mvriel Tagged as DocBlox  merge  new  phpDocumentor  release 

Announcing phpDocumentor 2 – the merging of the old (phpDocumentor) and the new (DocBlox).

With the first alpha release of phpDocumentor (2.0.0a1), the new “Responsive” default template sports a new page layout, along with the useful layout improvements that the original DocBlox templates provided (which remain available) over the old phpDocumentor templates (which will retire with old phpDocumentor). Explore this new template at http://demo.phpdoc.org/Responsive/index.html.

But what will this mean for DocBlox and phpDocumentor users?

Old phpDocumentor is retiring.  Some bugfix effort may continue into bringing phpDocumentor 1.x to a close, but most effort going forward will be spent on 2.x.  On that 2.x effort, you can expect monthly releases as 2.0.0 stabilizes, followed by monthly releases for new features and bug maintenance.

Existing DocBlox resources will be rebranded rather than removed, so that existing contributors can “come along for the ride” without much effort.

Let us know what you think, at #phpdocumentor on Freenode and @phpDocumentor on Twitter.

Mike van Riel (@mvriel) and Chuck Burgess (@ashnazg)

phpDoc2 is given a life anew by DocBlox and you.

No Comments »

Outputting formatted XML using PHP

Oct 23
Posted on October 23rd, 2011 In category Code  PHP 
By mvriel Tagged as format  PHP  prettify  snippet  xml 

For an interpreter it doesn’t matter how much whitespace there is in an XML document and often you find that machines strip it all out to reduce the amount of bandwidth used. Often at the receiving end you want to show the output in a log file or page and need it to be formatted so that it is easily readable by humans.

(more…)

No Comments »

SSH Tunneling across multiple hosts in Linux

Jun 10
Posted on June 10th, 2011 In category Linux 
By mvriel Tagged as host  jumphost  Linux  multiple  ssh  tunnel  tunneling 

Sometimes you need to communicate with a server (or other device) that is not directly accessible from your own computer. If you can reach this server via another server this is not an issue and can be solved by setting up a SSH Tunnel across your network.

An example

Let’s start with a example:

  • Computer A is where you are working.
  • Server A is accessible by computer A.
  • Server B has a administration web interface but its IP Address is completely shielded by a firewall; except for Server A.

Thus the only way to reach the web interface on Server B from Computer A would be through Server A.

The solution

You can solve this by setting up an SSH Tunnel which spans several server; the command for this is:

ssh -t -t -L[LOCAL_PORT]:localhost:[PORT_ON_A] [USER]@[SERVER_A] 'ssh -L[PORT_ON_A]:localhost:[PORT_ON_B] [USER]@[SERVER_B]'

Basically you are chaining a specific IP port to guide traffic from and to your PC.

The variables shown here represent:

  • LOCAL_PORT, the port on you local PC where you want to connect to in order to communicate with SERVER_B
  • PORT_ON_A, the port on SERVER_A which is used to transfer your data across to SERVER_B (may be any port number but make sure it does not collide with other tunnels / uses)
  • USER, your account name / login name on SERVER_A and/or SERVER_B
  • SERVER_A, the hostname or IP address of your first jump point
  • PORT_ON_B, the destination port to which you want to connect; in our example we wanted to connect to a web interface (port 80) thus we use the value 80 here
  • SERVER_B, the hostname or IP address of your intended destination

You might notice the use of a double -t argument in our command; this is not an error but is actually required in order to create the connection (without it your system might complain that it is unable to acquire a TTY; explaining the details of this would go beyond this blog posting)

Our example command

To complete this exercise I will show you the full command with which we could satisfy the requirement in our opening example:

ssh -t -t -L8081:localhost:10000 mvriel@a.server.example.com 'ssh -L10000:localhost:80 mvriel@b.server.example.com'

See that we used port 8081 as local port? We did that to prevent collisions with services on our local machine. Were you to use (for example) port 80 it might produce unwanted results such as your local apache (if you have one) being unreachable.

Now all we need to do to visit the website on Server B would be to enter the following URL in your browser:

http://localhost:8081

That’s all there is to it. If anything is not clear, just leave a comment.

5 Comments »

Pre-commit hook in Git: Running PHPUnit

May 16
Posted on May 16th, 2011 In category Articles 
By mvriel Tagged as gist  git  hook  PHP  phpunit  pre-commit 

Pre-commit hooks in git are one of those things you hardly think about but can help you automate tasks and do last-minute checks. A good example of this is running unit tests before commits, to make sure nothing broke; or checking your files using PHP_CodeSniffer.

With [DocBlox][1] I use them to run my unit tests as I personally believe these should be ran (and fixed!) before any commit.

(more…)

1 Comment »

Multiple types of opening braces when matching pairs with the tokenizer/ext

Feb 24
Posted on February 24th, 2011 In category Articles 
By mvriel Tagged as braces  DGA  DocBlox  matching  PHP  tokenizer  tokens 

Whilst I was testing DocBlox on the Solar Framework I found a bug in the part of the application where I match the curly brace pairs of structures (like classes, functions, methods, etc). Every time a variable was imported in a string using the {$var} notation my algorithm thought that the function/method had ended at the closing brace of that string.

To my surprise I found out that the issue was caused by the fact that the Tokenizer has three different tokens for recognizing an opening curly brace and only one for a closing curly brace.

(more…)

3 Comments »

Introducing: DocBlox

Feb 01
Posted on February 1st, 2011 In category PHP 
By mvriel Tagged as DGA  DocBlox  documentation  generator  github  PHP  phpDocumentor 

LogoEver since I discovered phpDocumentor I have been fascinated by the idea of automatic Documentation Generation. Especially for large projects where an in-depth understanding of the code is a requirement.

Unfortunately, the more I got to work with phpDocumentor the more issues surfaced with its performance, ease of use and above all: memory usage.

Over time I have encountered at least 1 project which could not be processed by phpDocumentor. This was unfortunate and thus I decided to try and contribute to the phpDocumentor project. After a pleasant introduction and solving a minor bug I attempted to solve, or at least decrease, the memory usage issues which were the main cause of my dissatisfaction.

(more…)

14 Comments »

Human readable memory usage in Linux per process

Dec 12
Posted on December 12th, 2010 In category Linux 
By mvriel Tagged as bash  command  Linux  memory 

LinuxI like to tune my VPS to use as little memory as possible. Not because I really want to; but because I just don’t have the money to spend on a 2+ GB RAM VPS and I would like to run Jira.

In order to do this I keep a close eye on the processes running and how much memory each takes. (more…)

7 Comments »

Updated the design of this blog

Dec 11
Posted on December 11th, 2010 In category Personal 
By mvriel Tagged as blog  design  site  usability 

Naenius logoAfter less than 2 years I have finished my new WordPress template for this blog. The previous theme was clunky and lacked many of the features that WordPress has to offer. I hope to address these issues and enhance this site even more. To be honest: the graphic design was finished about a year ago but the conversion process took quite some time (life got in the way multiple times).

(more…)

No Comments »

Next Page »
| Log in | Icons are part of the Crystal Project and copyright of Everaldo Coelho
Mike van Riel is a Senior Software Developer at Unet BV, an ISP for the corporate segment based in the Netherlands.

With a passion for industry standards and Quality Assurance he loves nothing more than to discuss methods to improve code and ways to 'Do-It-Better'™ in general.

You can contact him by:
mike.vanriel[at]naenius.com
@mvriel
http://www.linkedin.com/in/mvriel
mike.vanriel[at]naenius.com
mike.vanriel[at]naenius.com
mike.vanriel