Quickly Folding Functions In Vim

Vim IconThe is really a Vim tip on how to fold any code block including functions. It’s really helpful if you want to collapse a function or any other type of code block. Best of all, it is quick and easy to do.

Navigate your cursor somewhere inside of the code block you want to fold. You do not have to have your cursor on the opening brace, anywhere in the block is fine. Make sure you are in command/normal mode and type:

To save your folds between vim sessions you need to issue the command :mkview otherwise when you close vim your folds will be lost (your folds, not your code). To make life easier on you, you can have your folds automatically saved for you by adding this to your .vimrc file

PHP Documentation Help In Vim

Vim IconSupposing you are whipping up some PHP code in Vim and want to quickly check the PHP documentation for the function you just typed. I wrote a quick little script to do just that. It uses the _open_ command is OSX to launch your default web browser to the page in the online PHP documentation for the function name under your cursor. All you have to do is press shift+K

Continue reading

Force WordPress To Check For Plugin Updates

WordPressSometimes you know there is an update for your plugin but WordPress doesn’t know about it yet. You can force WordPress to check for plugin updates by deleting the content out of the _site_transient_update_plugins row in the wp_options table.

After running the query below on your WordPress database, login into your WordPress admin panel, navigate over to the plugins page and you should see all available updates.

How To Remove Empty Array Elements In PHP

PHP LogoQuick PHP tip: It is common to want to explode a string based on some delimiting character, then iterate over the array. Most of the time you don’t care about the empty items in the array. Suppose, for example, you have a dynamically constructed string of id numbers from a database or something and you want to iterate over them and do something. Here is a quick code sample to remove any entry that evaluates as false in the array.
Continue reading

What’s The Best PHP Framework?

PHP LogoThere is an enormous number of PHP frameworks available so I thought I share my experiences working with some of the most popular frameworks for PHP development. I have personally used all of the frameworks I describe either for my own projects or for actual client work. Here are my notes on how I evaluated various PHP frameworks and why I chose the PHP Fat-Free Framework as my PHP framework of choice.

Continue reading

Sync Local And Remote Databases For Web Development

I develop WordPress sites, themes, and plugins all the time and have been working on improving my workflow. I have configured our server using git (gitosis) for easy deployment of WordPress (and related files) which I’ll write about in a later post. This post is to share a little script I use for copying my local database to/from the remote (live) database.

Continue reading