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

Matt Stauffer:
How to count the number of lines of code in a PHP project
Jun 25, 2018 @ 15:50:37

In this post to his site Matt Stauffer shares several methods you can use to count the total number of lines of code in a PHP project.

I'm giving a talk soon about Laravel and "the enterprise", and the concept of LOC (lines of code) keeps coming up. It turns out that's actually a much harder number to discover than you might think, so I figured I would write up a few options here.

For what it's worth, I'm not a big fan of LOC as a measure of any importance, but it can at least give us some broad foundations to use to talk about broad differences in project size. If you were to ask me, I would say we shouldn't even think about it. But we don't always have that luxury.

He starts with a tl;dr for those that want the quick win (use PHPLOC) but shares other options with different tools too:

He shares answers to a few FAQs about finding lines of code and the output of each tool/command on the same project to show the differences.

tagged: linesofcode code lines count tutorial phploc cloc phpstorm sublimetext silversearcher

Link: https://mattstauffer.com/blog/how-to-count-the-number-of-lines-of-code-in-a-php-project/

Adam Wathan:
Optimizing Your PHPUnit Workflow in Sublime Text
Jan 17, 2017 @ 18: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 @ 15: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 @ 13: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 @ 14: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

Laravel Podcast:
Episode 29: PHP, Sublime Text, & Decorative Urns.
Jun 12, 2015 @ 16:19:07

The Laravel Podcast, hosted by Matt Stauffer with guests Taylor Otwell and Jeffrey Way, has posted their latest episode - Episode 29: PHP, Sublime Text, & Decorative Urns..

In this episode, the crew discusses 20 years of PHP, their favorite PHP features, Sublime Text, PHP Storm, Nintendo, and Jeffrey's first programming job.

You can listen to this latest episode in a few different ways - either through the in-page player, grabbing the mp3 or subscribing to their feed to get this and future episodes as they're released.

tagged: laravel podcast ep29 sublimetext 20yearsofphp decorative urns

Link: http://www.laravelpodcast.com/episodes/12992-episode-29-php-sublime-text-decorative-urns

SitePoint PHP Blog:
Best PHP IDE in 2014 - Survey Results
Mar 24, 2014 @ 18: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:
Debugging with Xdebug and Sublime Text 3
Feb 28, 2014 @ 17:10:53

The latest post from the SitePoint PHP blog, a new tutorial by Peter Nijssen, shows you how to get started with Xdebug and Sublime Text 3 to debug your PHP applications.

Debugging – we all do it a lot. Writing code perfectly the first time around is hard and only a few (if any) succeed at it. More than a year ago, Shameer wrote an article on SitePoint about how you can debug your application using Xdebug and Netbeans. In this article, we are going to have a look at how we can debug using Xdebug in combination with Sublime Text.

He assumes you already have Xdebug installed (and links to the instructions for those that don't) and helps you configure it to find your listening editor. Back in Sublime, he shows you how to use the package manager to install the Xdebug client and configure the current project to use it. He shows how to set up breakpoints and view the stack/watch data when the point is hit.

tagged: debug xdebug sublimetext remote tutorial package client

Link: http://www.sitepoint.com/debugging-xdebug-sublime-text-3/

Phil Sturgeon:
PHP Static Analysis in Sublime Text
Aug 21, 2013 @ 14:49:59

Phil Sturgeon has put together a new post for his site showing you how to set up static analysis of PHP code in the Sublime Text editor using various tools.

Coding Standards have been around for the longest time and recently they're starting to become more widespread in PHP. While learning Python I really enjoyed how Sublime Text 2 would shout at me for using too many empty lines, using tabs instead of spaces and even things like declaring unused local variables, importing modules that were never used, etc. This was pretty cool, and I was soon writing beautiful Python code without any concern over which way things should be done. I've been doing this with PHP for the last year, but trying to get a new-hire going with this stuff was hard. We smashed through it taking notes so now I've written it up for you guys.

He's broken it down into a few different steps (three of them) to get things like the right version of PHP, PHPMD and PHP_CodeSniffer installed and configured. There's a few config settings you'll need to change in Sublime to get things working correctly, but it's a relatively painless setup.

tagged: static code analysis phpmd phpcs sublimetext install configure

Link: http://philsturgeon.co.uk/blog/2013/08/php-static-analysis-in-sublime-text

NetTuts.com:
Pro Workflow in Laravel and Sublime Text
Mar 15, 2013 @ 14:48:39

NetTuts.com has a new article today for the Laravel developers out there (an up and coming PHP framework) with some handy Sublime Text tips you can use to streamline your workflow.

Not too long ago, I built a handful of generators for Laravel, which ease the process of various tasks. Today, thanks to help from Gaurav Narula, we’re turning things up a notch with the release of a new Sublime Text plugin that leverages the power of Artisan and the generators from directly within your editor.

They help you get it installed and running and show (via a screencast) the steps to use it when working in your code. Their examples show the creation of resources (all MVC aspects and configurations), working with Artisan commands, migrations and other bits of code.

tagged: laravel sublimetext editor package generator plugin

Link:


Trending Topics: