Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Robert Basic:
Current Vim setup for PHP development
Feb 10, 2017 @ 11:46:10

For those out there always interested in how other developers have their development environment, Robert Basic has some info on his own setup that might interest you. In this new post to his site he shares his configuration using the Vim editor when writing PHP code.

I made some changes to my Vim setup for PHP development recently, so it’s time to write it all down. I’m more than sure that I’ll break it soon and won’t be able to remember all the things I did to have the current setup.

Some new plugins popped up on my radar, I tweaked some older plugins and I even wrote one for PHPStan!

He starts with the improvements in tag support he's found recently using the Gutentags plugin. He also covers other tools and functionality like:

  • Jump to definition
  • (Getting the ) current PHP class and method
  • PHP namespaces
  • Linting
  • A promising completion engine for PHP
  • PHPStan in Vim
  • Debugging

He finishes up the post with a few other helpful supporting plugins for indenting, searching and argument swapping.

tagged: vim editor setup development plugin programming

Link: https://robertbasic.com/blog/current-vim-setup-for-php-development/

Adam Wathan:
Optimizing Your PHPUnit Workflow in Sublime Text
Jan 17, 2017 @ 12:55:10

Adam Wathan has a post over on his site showing you how you can optimize your PHPUnit workflow in Sublime Text with the help of a few handy snippets.

I've been a big fan of Sublime Text's snippets feature for years.

They make it really easy to generate repetitive boilerplate code, and if you know how to use placeholders and substitutions properly, you can do some pretty magical stuff.

He shares some of his own snippets for automagically:

  • creating a new test matching the filename currently selected
  • making new test methods with some placeholder content
  • making the tests easier to run

For this last point he shows the use of the Sublime PHPUnit package to run the tests through the Sublime menu. Finally he ties it all together in a much simpler workflow including a final "all tests" run before he commits.

tagged: sublimetext editor phpunit workflow testing plugin snippet

Link: https://adamwathan.me/2017/01/16/optimizing-your-phpunit-workflow-in-sublime-text/

Laravel News:
Run PHPUnit Tests From Sublime Text
Dec 29, 2016 @ 09:30:48

On the Laravel News site they've posted a guide showing you how to setup and run PHPUnit tests from Sublime Text, one of the more popular editors for code development.

Sublime Text is a great editor. It’s lightweight, fast, and extremely customizable. However, one downside to it compared to a full blown IDE is it doesn’t come with support for running your PHPUnit tests directly from the test class you are working with.

To solve this problem, Adam Wathan created and released a free package named Sublime PHPUnit that allows you to run your tests from a keyboard shortcut. Let’s take a look at how to add this package to your arsenal.

The post walks you through the installation of the tool (manually cloning the repository) and how to then use it via Sublime's command palette. There's also some instruction on customizing the plugin's setup and allowing for shortcut keystrokes bound to events the plugin provides. The final tip helps you change the tool used to run the tests (the Terminal app by default) over to something like ITerm.

tagged: phpunit test unittest sublimetext editor plugin keystroke run

Link: https://laravel-news.com/sublime-phpunit

Rob Allen:
Checking your code for PSR-2
Jul 28, 2015 @ 08:17:20

Rob Allen has posted a guide showing you how to make your code PSR-2 compliant with the help of some handy tools, both in and out of your editor/IDE.

Most of the projects that I work on follow the PSR-2 coding style guidelines. I prefer to ensure that my PRs pass before Travis or Jenkins tells me, so let's look at how to run PSR-2 checks locally.

He looks at three different methods - not the only ones out there but three quick to implement ones:

  • Using the PSR-2 sniffs for PHP_CodeSniffer
  • Automating the checks with Phing
  • Editor integration (he shows VIM and Sublime Text)

There's links to the tools mentioned here and screenshots/configuration information showing how to get it set up too.

tagged: psr2 code style check phpcodesniffer phing editor vim sublimetext

Link: http://akrabat.com/checking-your-code-for-psr-2/

Matt Stauffer:
Sublime Text (3) for PHP Developers
Jun 29, 2015 @ 09:25:55

Matt Stauffer has posted a set of helpful hints for developers using Sublime Text (3) to help make them more efficient and writing code much easier.

A lot of folks in the PHP community have been checking out PHPStorm lately, including myself and most of the developers I work with. We love the code intelligence we get from PHPStorm, but still miss the speed, quick boot-up, and convenience of Sublime Text. Before I blindly assume PHPStorm is the only way to go, I wanted to see: Can I bring the things a PHP-focused IDE provides PHP developers back to Sublime Text and get the best of both worlds?

He starts with a list of "must haves" for him to be able to move from PHPStorm, features it provides that Sublime, an editor not IDE, might not come with out of the box. Most of his suggestions use the Package Control functionality in Sublime so you'll need that installed to try out his examples. He then shows several tools you can install including:

  • Sublime PHP Companion (package)
  • AllAutocomplete (package)
  • Cmd-click for function definition
  • Integrating Code sniffing and PHP_CodeSniffer
  • DocBlockr (package)
  • Git helpers

...and many more. If you're a Sublime Text user, definitely take a look at his list and see if you can find something to help make your development easier.

tagged: sublimetext phpstorm editor ide features package tips integration

Link: https://mattstauffer.co/blog/sublime-text-3-for-php-developers

Programming With Yii2: Rich Text Input With Redactor
Jun 19, 2015 @ 10:38:55

NetTuts.com continues their series about programming with the Yii2 framework in this new article moving on to the use of the Redactor rich text editor that comes bundled with the framework.

In this Programming With Yii2 series, I'm guiding readers in use of the newly upgraded Yii2 Framework for PHP. In this tutorial, I'm going to introduce you to using the rich text editor Redactor within the Yii Framework. For these examples, we'll continue to imagine we're building a framework for posting simple status updates, e.g. our own mini-Twitter.

Thanks to the Yii community purchasing an unlimited license for the Redactor rich text editor, it's easy to install and use via the "yii2-redactor" extension. They help you get it installed and update a sample form to use it instead of the normal basic HTML textarea for content input. They also show you how to add image support and what it looks like both inline in the editor and the resulting HTML output.

tagged: yii2 series tutorial programming redactor richtext editor image

Link: http://code.tutsplus.com/tutorials/programming-with-yii2-rich-text-input-with-redactor--cms-23174

SitePoint PHP Blog:
Multiple Editors per Node in Drupal 7
Jun 11, 2015 @ 09:57:49

The SitePoint PHP blog has posted a new Drupal tutorial about allowing multiple editors to work on the same node of content.

have encountered a practical use case where the default configuration options are not enough. Namely, if you need to have multiple users with access to edit a particular node of a given type but without them necessarily having access to edit others of the same type. In other words, the next great article should be editable by Laura and Glenn but not by their colleagues. However, out of the box, users of a particular role can be masters either of their own content or of all content of a certain type. So this is not immediately possible. In this article I am going to show you my solution to this problem in the form of a simple custom module called editor_list.

He walks you through the process, first creating the .info file needed to define the module and the changes needed for the .module file. He creates a few helper functions to get the editor listing for a node and its matching access rules. With the module created he then gets into building the fields, again making helper methods to get the editors for the fields. Finally he "tidies up" and adds an "Authored on" section to the node editor with a helper function to receive and handle the results of this field when the form is submitted.

tagged: multiple editor drupal node field tutorial

Link: http://www.sitepoint.com/multiple-editors-per-node-drupal-7/

Matthew Setter:
Can VIM Ever Replace PHPStorm?
Mar 02, 2015 @ 10:54:13

In an interesting new post to his site Matthew Setter wonders if an IDE like PHPStorm can be replaced by VIM, a standard in the editor community for decades.

Is it reasonable, even practical, to expect that a 30 year old application can match a modern one? Is it conceivable to be able to code as well using VIM, said 30 year old application, as I can in PhpStorm, with all the IntelliSense-lead functionality PhpStorm offers?

He starts with some of his recent experience with the editor and some of the things he's (happily) found it can do he didn't know before. He includes a screenshot of a multi-pane view, explains what each is and what he can do with them. He points out that this example is Markdown documents but it can just as easily be used for code too. Finally he talks about the subject any PHPStorm user wants to know about, the IntelliSense functionality. Unfortunately, while there are some tools he mentions that can do similar things, they don't provide the context PHPStorm can deliver.

He ends the post with an interesting question: is IntelliSense the right approach? He wonders if having more context is a better answer rather than just the auto-complete handling IntelliSense offers.

tagged: vim editor replacement phpstorm opinion autcomplete context screenshot

Link: http://www.matthewsetter.com/can-vim-ever-replace-phpstorm/

SitePoint PHP Blog:
Best PHP IDE in 2014 - Survey Results
Mar 24, 2014 @ 13:15:42

The results are in and the SitePoint PHP blog has officially announced the most popular PHP IDE based on the answers to their survey. The overall winner is PHPStorm (from JetBrains) but several others weigh in on their editor of choice too.

This article will focus on the IDE results alone. We’ll analyze the PHP community in general in a future piece after the data has been cleaned to a greater extent. Please note that these are preliminary results, and not much detailed filtering has taken place yet. The data will still be processed and additionally verified. The ballpark is in the correct ranges, but cannot be deemed precise (might be off by a couple dozen in every category – not enough to influence the end result), hence only percentage values will be displayed in the charts. For exact figures, see the raw data.

The results show PHPStorm coming in at first place in both the business and personal votes with Sublime Text and Netbeans pulling in behind for 2nd and 3rd. The post also shares comments from some of the votes, people adding some of their own thoughts and reasons for their choice of editor/IDE. Other tools that were mentioned include Vi, TextMate, Eclipse/PDT and Dreamweaver.

tagged: survey results popular ide editor tool phpstorm sublimetext netbeans

Link: http://www.sitepoint.com/best-php-ide-2014-survey-results/

SitePoint PHP Blog:
How to Dynamically Localize TinyMCE
Dec 02, 2013 @ 10:37:41

The SitePoint PHP blog has a post from Roland Clemenceau about localizing the TinyMCE editor, a web-based Javascript HTML WYSIWYG editor. It's dropped in to make textareas rich-text editing components of your page quickly and easily.

This tutorial assumes you have built a PHP multilingual site/framework and you, or whoever the admin is, would like TinyMCE to automatically switch to the current language of your site. [...] Although TinyMCE is a great wysiwyg editor that provides localized files for almost every known language, it still does not come with an automatic language-switching feature. It's very easy to roll your own solution to this problem, though, so that's what we're going to do now.

He shows how to use extra language files in coordination with a "language" setting. This setting (usually something like "en" or "es") can then be set as a configuration option when the TinyMCE instance is added to the page.

tagged: localize tinymce editor wysiwyg tutorial html

Link: http://www.sitepoint.com/dynamically-localize-tinymce/