News Feed
Jobs Feed
Sections




News Archive
feed this:

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

Loosely Coupled Podcast:
Episode 2 My Code Is Perfect
April 16, 2014 @ 13:59:40

The Loosely Coupled podcast (with PHP community member hosts Jeff Carouth and Matt Frost) has released their latest episode, Episode #2: My Code is Perfect.

Writing clean code isn't something you pick up overnight, nor is it a brand new topic. In this episode Jeff and Matt discuss the characteristics and mechanics of creating clean code and how to approach your project from a clean code perspective. [...] In this episode, Jeff and Matt talk about code quality and beautiful code. Beautiful code follows a standard. If you don't have one, find one and adopt it.

There's some great notes in the post to accompany the recording with other suggestions, resources and links to other sources that can help you write cleaner, better code. You can listen to this latest episode either through the in-page player or by downloading the mp3 directly. You can also subscribe to their feed to get the latest episodes as they're released.

0 comments voice your opinion now!
looselycoupled podcast ep2 code perfect standard cleancode

Link: http://looselycoupled.info/blog/2014/04/14/episode-2-my-code-is-perfect/

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

SitePoint PHP Blog:
PHP Extension Development with PHP-CPP Object Oriented Code
April 08, 2014 @ 09:11:17

The SitePoint PHP blog has posted the second part of their look at the PHP-CPP tool and how to use it for developing PHP extensions. In this second part of the series Taylor Ren builds on what was learned in part one and talks more about the OOP features of the tool.

In this part, we further elaborate its OO features. We will mimic a complex number (in the form of 3+4i) class to demonstrate some more useful and powerful sides of the PHP-CPP library.

He walks you though a few changes to the environment files (the .ini configuration file and the Makefile) to set things up. He then gets into the C++/PHP constructor and getters and setters for private class variables, much like PHP's __get and __set. His example shows a set of methods that do some mathematical calculations including one to show the result in a "more friendly way". He includes the code for registering these functions and, finally, the steps to compile, install and test the extension.

0 comments voice your opinion now!
phpcpp extension development part2 series oop code

Link: http://www.sitepoint.com/php-extension-development-php-cpp-object-oriented-code

NetTuts.com:
Refactoring Legacy Code Part 1 - The Golden Master
March 24, 2014 @ 12:56:32

NetTuts.com has kicked off a new series of posts looking to help you get a handle on that big pile of legacy code you're having to work with. In part one of their "Refactoring Legacy Code" series they talk about the "Golden Master", a method of testing all the things before starting on changes.

Old code. Ugly code. Complicated code. Spaghetti code. Jibberish nonsense. In two words, Legacy Code. This is a series that will help you work and deal with it. In an ideal world, you would write only new code. You would write it beautiful and perfect. You would never have to revisit your code and you will never have to maintain projects ten years old. In an ideal world... Unfortunately, we live in a reality that is not ideal. We have to understand, modify and enhance ages-old code. We have to work with legacy code.

They start with a definition of what "legacy code" is and link to a codebase they'll guide you through for refactoring. They talk some about understanding the code and scanning through it to get an overall feel for it. They recommend some testing techniques (including the Golden Master) and include the code to create it and some of the sample output.

0 comments voice your opinion now!
tutorial refactor legacy code series part1 goldenmaster

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-1-the-golden-master--cms-20331

The PHP.cc Blog:
PHPUnit 4.0 Code Coverage Improvements
March 10, 2014 @ 10:47:41

The latest version of the popular PHP unit testing tool PHPUnit has officially been released (version 4.0.0) and comes with some nice improvements. In this post to the PHPcc blog Sebastian Bergmann talks about enhancements in one area - code coverage reporting.

One of the highlights of PHPUnit 4.0, which was released last week, is an improvement of the @covers annotation and the addition of the @uses annotation for better code coverage analysis.

He includes a few simple code snippets showing you how the "@covers" annotation has been working and how it can be used in both strict and non-strict modes. He also introduces the "@uses" annotation to define which objects the test is using and how the two interact. He finishes off the post with a mention of the "--strict-coverage" command line flag (or the more general "--strict").

0 comments voice your opinion now!
code coverage improvements phpunit unittest

Link: http://thephp.cc/viewpoints/blog/2014/03/phpunit-4-0-code-coverage-improvements

Pantheon Blog:
Please License Your Code
February 26, 2014 @ 13:18:55

In a recent post to the Pantheon blog community member Cal Evans makes one request for the developers out there (PHP and others) - please license your code.

It is wonderful that you have put your code up on GitHub. That is the essence of "Social Coding". However, if you do not put a license on it, you are just teasing developers. In essence, you are saying "See what I made? You can't use it, but I wanted to show you anyhow." Granted, sometimes, developers will use unlicensed code in their projects anyhow, but usually not. Without a proper license, others have no idea what is a permissible use. You wrote it, you own it, you shared it, so let people know they can use it.

He points out that GitHub makes it easy to just throw code up and expose it to the word for use. Unfortunately, due to restrictions put in place by business or technology groups, code without a license simply can't be used. If you're not familiar with code licenses, he links to the Choose a License site that can walk you through the choice via a series of questions.

0 comments voice your opinion now!
code license github choosealicense

Link: https://www.getpantheon.com/blog/please-license-your-code

Pádraic Brady:
Composer Downloading Random Code Is Not A Security Vulnerability?
February 21, 2014 @ 10:04:52

In his latest post Pádraic Bradyhas posted a response to a recent post stating that in issue in Composer where the wrong package could be installed is not a security issue. Pádraic disagrees, here's why:

The problem here is quite simple. A user defines a composer.json file that requires the package bloggs/framework. Someone else creates a package on Packagist.org called evil/framework whose own composer.json states that it replaces bloggs/framework. Next, a group of poor random victims, potentially thousands, use composer to install applications with a dependency on bloggs/framework. Composer does some internal wizardry and installs evil/framework when certain conditions are met. The victims didn't request evil/framework but they get it anyway.

He suggests that this is a kind of remote file inclusion and possibly a remote code execution vulnerabilities. He points out that the manual steps suggested in the post aren't listed in the Composer documentation and fixes for it are still pending work.

Saying one thing, but acting like it's the other thing you don't want people to call it, makes me think it really is the other thing. Probably because it is. Users can fall victim to a replace and it's called "unintuitive", but if a package states that it replaces something that might lead to the unintuitive behaviour, it's an abuse.
0 comments voice your opinion now!
composer random code vulnerability security package

Link: http://blog.astrumfutura.com/2014/02/composer-downloading-random-code-is-not-a-security-vulnerability/

VG Tech:
Generating Code Coverage of Behat Tests
January 22, 2014 @ 10:52:57

On the VGTech blog today Christer Edvartsen looks at a method of generating the code coverage of Behat tests using a special bit of code and the $_SERVER superglobal to detect what parts of the code is being executed.

Yes, I know, it sounds silly, but bear with me. The nature of acceptance tests is not really to tests units of code, but to assure that the behavior of your application meets a certain set of criteria (Behat Scenarios). When your applications grow over time, code coverage can be a nice tool to help you pinpoint where you need to add more tests. In a perfect world tests are added while implementing new features so that your applications are always fully tested, but that isn't always as easy as it sounds.

The first chunk of code is something that would go in the router of your application, capturing the "collect coverage" and "enable coverage" input variables. The other part of the code creates a unique ID in the set up and uses it in a call (via Guzzle) to the server to start the tracking. In the tear down method, it sends the call to get the coverage results and process them through the PHP_CodeCoverage tool from Sebastian Bergmann.

0 comments voice your opinion now!
code coverage behat test tutorial functional

Link: http://tech.vg.no/2014/01/21/generating-code-coverage-of-behat-tests

QaFoo.com:
Code Reuse By Inheritance
January 20, 2014 @ 10:55:18

On the Qafoo blog today Kore Nordmann has a new post talking about code reuse through inheritance. He talks about base classes, sharing code and abstraction.

To me, inheritance has two properties: Defining an is-a relationship [and] making it possible to share code between classes by extending from a common base class. The is-a relationship between classes is one thing I like to use inheritance for. [...] The other thing you can use inheritance for is to share code between multiple classes. [...] I personally think that the latter is one of the worst things you can do in object oriented design. Bear with me for a moment and let me try to explain why I think that.

His example of doing it the wrong way is using the Active Record design pattern and how it's usually implemented - storage logic in the base class and business/table logic in the extending class. He then gets into an example that's a bit "smaller" creating diff display functionality and how the "code reuse by inheritance" creeps in a lot in helper methods. He also briefly looks at testing (or not testing) private methods and and the "Depth of Inheritance Tree" metric's recommended value.

0 comments voice your opinion now!
code reuse inheritance helper activerecord testing depth

Link: http://qafoo.com/blog/063_code_reuse_by_inheritance.html

KillerPHP.com:
What is Refactoring PHP Code?
January 17, 2014 @ 09:16:40

If you're relatively new to programming, there's a term you might have heard floating around but not really understood - "refactoring". If you're interested in learning more about it and want a gentle introduction of how it works in PHP to help make your code better, check out this introductory video from Stefan Mischook.

In a nutshell: It is the process of code refinement - taking messy code and reorganizing it into much more manageable (cleaner) chunks. Refactoring is such an important part of coding, that I slap my programmers on back of the head, if they fail to refactor their code!

He talks about refactoring being something that's done constantly, not just later down the line. He also talks about when to refactor and suggests a few methods that you can use. You can watch the video either in the in-page player or over on YouTube for a larger size.

0 comments voice your opinion now!
refactor code video screencast introduction

Link: http://www.killerphp.com/articles/what-is-refactoring-php-code/


Community Events











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


install podcast framework release package facebook application security language symfony2 opinion component introduction support hack composer performance database hhvm unittest

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