News Feed
Sections




News Archive
feed this:

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

Expert Developer:
Install PHP CodeSniffer on Windows Machine
July 29, 2014 @ 10:33:45

On the Expert Developer site there's a new tutorial showing you how to get the PHP CodeSniffer tool up and working on a Windows installation. PHP CodeSniffer provides functionality to enforce standards and best practices in your application's development (providing code quality).

In this article we will focus on improving Code Quality. Very first step towards improving code quality is to maintain coding standards across developers. [...] Here we will talk about PHP CodeSniffer, which help us to maintain coding standard across multiple developer. Dealing with CodeSniffer is much easier: create rule set, validate your file against your rule set and get the result immediately. It will immediately show how many mistakes you have made in terms of following coding standards and eventually all developer will start coding as per coding standards you have defined.

There's two main parts to the article: first is getting PEAR installed (a package manager for PHP) and then using it to install CodeSniffer. Complete instructions and commands are included as well as a few screenshots along the way.

0 comments voice your opinion now!
install tutorial codesniffer windows code quality

Link: http://www.xpertdeveloper.com/2014/07/install-php-codesniffer-on-windows-machine/

Three Devs & A Maybe Podcast:
Functional Programming with Simon Holywell
July 23, 2014 @ 11:03:45

Three Devs & A Maybe podcast has released their latest episode today: Episode #35 - an interview with Simon Holywell. Simon is the author of an upcoming book about functional programming in PHP.

This week we are lucky to have Simon Holywell on the show to talk all things Functional Programming. Initially starting off with a concrete definition of Functional Programming, we move on to a brief history of the paradigm and immutability. Following this we explain recursion (and tail-recursion), along with closures and higher-order functions. From this base we are able to then talk about the different languages available to you which cater towards the functional mindset (i.e. Haskell). We then set our sights on the PHP language and what/wish it had to offer when exploring the functional paradigm. Finally, we mention his upcoming book, along with experiences presenting at user-group meet-ups.

Topics mentioned in this episode include:

You can listen to this latest episode either through the in-page player or by downloading the mp3 directly.

0 comments voice your opinion now!
threedevsandamaybe podcast ep35 simonholywell functional php

Link: http://threedevsandamaybe.com/posts/functional-programming-with-simon-holywell/

Zumba Engineering Blog:
Enforce code standards with composer, git hooks, and phpcs
April 15, 2014 @ 09:13:48

The Zumba Engineering blog has a new post looking at a way you can control code quality and standards with the help of Composer, git hooks and the PHP Code Sniffer (phpcs) tools.

Maintaining code quality on projects where there are many developers contributing is a tough assignment. How many times have you tried to contribute to an open-source project only to find the maintainer rejecting your pull request on the grounds of some invisible coding standard? [...] Luckily there are tools that can assist maintainers. In this post, I'll be going over how to use composer, git hooks, and phpcs to enforce code quality rules.

These three technologies are combined together to make a more seamless experience for the developer while keeping the code quality high. Their method makes use of the "scripts" (post-install-cmd) feature of Composer to, after the installation of all packages, set up a git hook script that will run the phpcs checks on pre-commit. It's a pretty simple shell script that kicks back any errors it might find before the user can commit their changes.

0 comments voice your opinion now!
code standards composer git hook phpcs codesniffer install precommit

Link: http://engineering.zumba.com/2014/04/14/control-code-quality

Pádraic Brady:
Coding Standards Humans Are Not Computers
February 11, 2014 @ 10:26:06

In his latest post Pádraic Brady shares some of his thoughts around coding standards and the existence of tools to be sure the code is exactly formatted correctly.

The problem with coding standards is not the notion of following conventions to ensure all programmer can quickly read and understand code (and other good stuff), but that someone created a tool to actually check compliance: PHP_CodeSniffer. This isn't a complaint about the operation of phpcs, but to complain about the mere fact of its existence. [...] Using the cover of such automated tools, we can make judgement calls about code quality, integrate style checks into Continuous Integration scoring schemes, complain about pull requests and patches, and generally impose a time penalty on writing code. There is a point at which common sense morphs into sheer nitpicking, and an automated tool is the perfect nitpicker.

In his opinion, coding standards should be "invisible and flexible" as well as easy to learn so the developers could learn and follow it quickly. He looks at these thoughts applied to the PSR standards and how adhering to them could quickly turn into something much more time consuming than it should. In his opinion a good coding standard is one that "limits the rules, eradicates ambiguity, formulates multiple use cases and avoids trivialities".

0 comments voice your opinion now!
coding standard psr phpcs codesniffer opinion

Link: http://blog.astrumfutura.com/2014/02/coding-standards-humans-are-not-computers/

Phil Sturgeon:
PSR-2 v CodeSniffer PSR-2 A Success Story
October 16, 2013 @ 09:34:15

In a new post to his site Phil Sturgeon talks about the "success story" around the PSR-2 PHP-FIG standard and his work to get the PHP CodeSniffer checks to be more correct for it.

I've had static analysis tools running in Sublime Text for a long time, but for most of that time I have had CodeSniffer and it's PSR-2 rules disabled. I couldn't for the life of me remember why I had done that, until I turned it back on again. All of a sudden it started complaining about code that I had always considered to be perfectly compliant. It reminded me of multiple conversations I've had with others in the FIG and the community in general, about how CodeSniffer often enforces rules in the PSR-2 spec that do not exist, or were not what was meant when it was written. Two months ago I set off on a mission, to get CodeSniffer in line with what PSR-2 really is.

He gets into a bit of the backstory around the checks and the addition of "Errata" to add to the specs that have already been defined. The goal isn't to alter what's been defined, but to help clarify some issues (or close some loopholes) that might have come up. After polling the PHP-FIG mailing list about it - and it passing unanimously - the Errata was added and the CodeSniffer rules were updated to match (PHP_CodeSniffer 1.4.7).

If you're interested in other unclear places in the PSR-2 spec and want to discuss it, check out this gist and the conversation that goes with it.

0 comments voice your opinion now!
psr2 codesniffer rule clarity errata phpfig

Link: http://philsturgeon.co.uk/blog/2013/10/psr2-v-codesniffer-psr2

Christian Weiske:
PHP_CodeSniffer notify-send report
August 15, 2012 @ 09:54:07

In a new post to his site Christian Weiske shares an update he contributed to the PHP_CodeSniffer functionality to make working with and checking the validity of local PHP code easier - a notifier for PHP_CodeSniffer using the "notify-send" commonly installed in most Linux distributions.

I use emacs as IDE, and wanted to have direct feedback about the validity of my .php files when writing them. The most easy way was to add a save hook that runs PHP_CodeSniffer - but the results should be displayed in a nice, unobtrusive way. phpcs has multiple reporting modes - xml, checkstyle, csv etc. - but nothing for the desktop. I thought that notify-send would be the right fit since it is able to display pretty popup messages without getting in the way.

He also includes the details on his original objective - including it in a "on save" hook as well as providing it in a keystroke shortcut, making checking his code even easier.

0 comments voice your opinion now!
codesniffer notifysend popup emacs desktop


NetTuts.com:
So You Want to Accept Credit Cards Online?
June 14, 2012 @ 09:30:25

On NetTuts.com they're posted a new tutorial about using the Stripe service to accept credit cards on your site. Thanks to some handy libraries they provide, integration is a relatively simple process.

Until recently, accepting credit cards on a website was expensive and complicated. But that was before Stripe: a radically different and insanely awesome credit card processing company. Today, I'll show you how to start accepting cards in 30 minutes or less - without spending a dime.

They step you through the whole process you'll need to get the full flow set up:

  • Install an SSL Certificate (on your server)
  • Create an Account
  • Create Your Payment Form
  • Collect The Form Values
  • Request a Token
  • Create a Server-Side Script

Screenshots of the Stripe interface, HTML, Javascript and PHP code are all included - everything you need to make the simple card handling work. One of the keys to how Stripe deals with credit cards is that you provide it the card info, it gives you a token. Your app uses this to work with the card instead of storing the card information in your database (also making it more secure).

0 comments voice your opinion now!
creditcard stripe tutorial processing javascript html php library


Project:
CodeSniffer for PSR's (PSR-0, PSR-1 & PSR-2)
June 09, 2012 @ 11:17:50

Klaus Silveira has created a set of PHP_CodeSniffer rules that can be used to test your code for the recently approved PSR-1 & PSR-2 standards.

This is a PHP_CodeSniffer sniff to check against the PHP Standard Resolutions: PSR-0, PSR-1 and PSR-2. Those standards were approved by the PHP Framework Interoperability Group. You can read more about the PHP FIG and the PSR's on this excellent article by Paul Jones.

The github repository also provides an overview of the standards themselves and how to get these sniffs installed.

0 comments voice your opinion now!
psr codesniffer rules psr0 psr1 psr2


Lorna Mitchell's Blog:
PHP Static Analysis Tool Usage
August 03, 2011 @ 10:50:22

In an informal poll Lorna Mitchell recently asked fellow developers to weigh in on what static analysis tool they used on their code. She's posted the results to her blog today with one of the tools being a clear winner.

My interest was mostly because I'm working on a book chapter which includes some static analysis content, and there are a couple of these tools that I include in my own builds, but I don't do much with the output of them. However I didn't want to drop anything from the chapter if it was actually a valuable tool and I was just missing the point - pretty much all the tools got a good number of votes though, so I'll be covering all of the [options].

According to her results, the most used tool by developers is the PHP_CodeSniffer with the PHP Mess Detector and PHP Copy & Paste Detector tied for second place.

0 comments voice your opinion now!
poll results static analysis tool codesniffer phpmd phpcopypaste


Christian Weiske's Blog:
How to integrate PHP_CodeSniffer with Git repositories?
May 27, 2011 @ 11:16:48

Christian Weiske has a problem he hopes you can help with - he's trying to get the PHP_Codesniffer tool integrated into his git workflow (well, the workflow of his team) as an automatic process that runs on commit. Unfortunately he's having some issues.

At work, we used a SVN server and enforced our project coding standard with a pre-commit hook on the server that ran PHP_CodeSniffer. Whenever a developer tried to commit some code that does not match the standard, he got it rejected. [...] The only way to enforce the standard is a pre-receive hook on our central Git repository server that all devs push to. Just installing the SVN hook on it isn't the solution, though.

Because of how git handles commits (possibly multiple in one push) the usual methods won't work. Other tricky things like file renaming and allowing for legacy code check-ins are also needed. He's posted the question on StackOverflow too, but no one's come up with a good answer yet (at the time of this post).

0 comments voice your opinion now!
git phpcodesniffer codesniffer commit hook stackoverflow



Community Events





Don't see your event here?
Let us know!


introduction framework api language package community list deployment release tips interview laravel series podcast install zendserver symfony opinion update library

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework