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

SitePoint PHP Blog:
Automatic PHP Code Generation with Memio
May 05, 2015 @ 11:52:07

On the SitePoint PHP blog a new tutorial shows you how to generate code with Memio, a relatively new PHP-based tool that lets you define "models" as structures for the code you need generated.

Ever thought of writing code responsible for generating certain PHP classes, methods, properties automatically? Read on to get the details on when exactly automatic code generation may be helpful and - what's most important - how to implement it properly using the Memio library.

He starts with a bit of introduction to the basic concept of code generation and mentions a few places it's currently used. Then he gets into the examples, starting with a bit of code showing how to get Twig loaded and injected into the Memio instance. From there he shows a simple example of creating a class with a single method and single line of code. With the basics understood, he gets into a more "real world" example of generating ORM classes with getters and setters for the different properties/column names.

0 comments voice your opinion now!
tutorial generate code memio library example orm realworld

Link: http://www.sitepoint.com/automatic-php-code-generation-memio/

Marc Morera:
Visithor, Testing Your Routes Without Pain
May 05, 2015 @ 09:25:55

In his latest post Marc Morera shares a new tool he's created to help with testing routes for specific HTTP code responses and other attributes of your "HTTP layer" - Visithor.

Many years ago I was thinking about a simple and fast tool to test specific routes, expecting specific HTTP codes and providing an easy environment of ensuring properly your HTTP layer. So... I present you Visithor, a PHP based library that provides you this functionality, with a simple configuration definition and a very easy way of installation.

He starts with a few quick commands to get the library installed (either globally or local to the project) and how to create the first configuration file. This file defines the tests to execute as a set of URLs with allowed HTTP response codes. He also shares a Symfony2 bundle that can be used to integrate it with your current application, allowing for more flexibility in route check configuration and environment settings. He also includes a quick example of integrating it with your Travis-CI build as a "script" command to be executed.

0 comments voice your opinion now!
visithor library testing http response code symfony2 bundle integration

Link: http://mmoreram.com/blog/2015/05/04/visithor/

SitePoint PHP Blog:
Inspecting PHP Code Quality with Scrutinizer
April 29, 2015 @ 11:24:24

The SitePoint PHP blog has a recent tutorial showing you how to use the Scrutinizer service to evaluate the quality and "pain points" in your PHP code, be it a library or full application.

We've gone through a decent number of tutorials about code quality, inspections, auto-build systems and so on here at SitePoint. [...] In this article, we'll take a look at Scrutinizer CI - a continuous integration tool that's quite expensive and closed to private projects, but very handy for public ones.

He starts with a quick comparison of Scrutinizer versus (and really plus) the popular CI service Travis CI. He then walks you through the setup of Scrutinizer to evaluate your application automatically when code is pushed to GitHub. He then gets into the configuration options the service provides including filters, specific checks to evaluate and other tools to execute in the evaluation build. The article then gets into examples of the reports that are provided and a bit of detail about what each view provides. There's also options to hide certain errors that you know aren't actually problems and the "follow up" links it provides for the issues you may not understand.

0 comments voice your opinion now!
inspect code quality scrutinizer tutorial setup configure

Link: http://www.sitepoint.com/inspecting-php-code-quality-scrutinizer/

Christopher Pitt:
Co-operative PHP Multitasking
March 30, 2015 @ 12:47:41

Christopher Pitt has posted a new article on Medium.com about when an "array is like an adventure" when in the context of co-operative PHP multitasking. In it he shows how to make code work asynchronously with out the use of extensions, only generators.

Last week I got the opportunity to share recent work with my colleagues, at SilverStripe. I was going to present Async PHP today, but since I covered ReactPHP last week; I decided to talk about something slightly different. So here's a post about cooperative multitasking.

He starts with some basic arrays and other things that act like them and can be iterated through (Traversable). He talks about implementing custom iterators to act the same way and the use of IteratorAggregate to "cheat" a bit when making them. The he gets into generators, showing how they can be used to iterate similarly. He shows how it's possible to send data to a generator, throwing exceptions inside them and the use of "coroutines" to create asynchronous code. He builds up a queue system with this method and shows how they execute with some simple echo output. He also shows the use of RecoilPHP, another coroutine-based library, to replace the main kernel for a ReactPHP script. He also mentions IcicleIO as another option.

0 comments voice your opinion now!
cooperative multitasking asynchronous code coroutine generator

Link: https://medium.com/@assertchris/co-operative-php-multitasking-ce4ef52858a0

Julien Pauli:
Zoom on PHP objects and classes
March 26, 2015 @ 12:50:49

Julien Pauli has a recent post to his site that "zooms in" on objects and classes with a look behind the scenes at how they're handled in the PHP source (at the C level) with plenty of code examples and explanations as to how they work.

Everybody uses objects nowadays. Something that was not that easy to bet on when PHP5 got released 10 years ago (2005). I still remember this day, I wasn't involved in internals code yet, so I didn't know much things about how all this big machine could work. But I had to note at this time, when using this new release of the language, that jumps had been made compared to old PHP4. The major point advanced for PHP5 adoption was : "it has a new very powerful object model". That wasn't lies. [...] Here, I will show you as usual how all this stuff works internally. The goal is always the same : you understand and master what happens in the low level, to make a better usage of the language everyday.

The article does a great (if lengthy) job of covering everything that happens with PHP's objects and class system, including stats about memory consumption. He includes both the PHP code and the C code to illustrate what's happening with classes, interfaces, traits and object methods/attributes (including object references). He also talks about what "$this" is and how class destructors are handled.

0 comments voice your opinion now!
object class behindthescenes detail c code memory usage

Link: http://jpauli.github.io/2015/03/24/zoom-on-php-objects.html

Piotr Pasich:
Ant, composer and code quality tools
March 18, 2015 @ 11:33:47

In his latest post Piotr Pasich shares some handy tips (and tools) to help you use Composer to do some of the common tasks you might use Ant or Phing for.

I decided to start with something uncomplicated - a simple solution that could help me solve a prosaic, but annoying issue. For instance, XML format. No, I won't fight with it. I see it as great and practical, however mostly I don't need so sophisticated code to cover my needs - the yaml usually fits the purpose. [...] Yet, do I really need this flexibility [of XML configuration] when I use vagrant or docker to maintain the same environment as on the production? For 90% of PHP projects probably I won't use all of the features of the virtualization tools. I only want to install necessary libraries, check the code quality before committing or introduce fixtures. Most of those points are easily feasible in composer.

He then shows how to execute these checks through the functionality included with Composer to run custom scripts. His example measures the quality of the code based on the results first from a single run of the PHP Mess Detector (phpmd) command. He then extends this with the open source contribution he mentions earlier with his CodeQualityThreshold library allowing not only for more checks (phpmd, phpcs, phpcpd, etc) but also allows you to configure the thresholds for each class if desired. He includes an example of it in action and screenshots of the results.

0 comments voice your opinion now!
ant composer code quality phpmd commandline library codequalitythreshold threshold

Link: http://piotrpasich.com/ant-composer-and-code-quality-tools/

Derick Rethans:
Code Coverage Finding Paths
January 07, 2015 @ 09:33:13

Derick Rethans has continued his series looking at the code coverage handling that XDebug and PHPUnit make available, allowing you to find the spots in your code not tested much easier. In this new post he talks about a new feature coming to the XDebug tool - branch and path coverage.

Picking up from where we left last time, in this second article we will look at some upcoming functionality in Xdebug. Sebastian has been pressuring me for years to add branch and path coverage to Xdebug, with issue #1034. In the post I will show you what "branch and path coverage" is, and how it helps.

How does this new type of coverage differ from the current functionality? Derick goes on to explain the difference via a simple example (and its resulting coverage). In the first example, using the XDebug available today, shows a fully tested function despite not all paths being testing correctly (a false coverage report). He gets into the "under the covers" changes he's made including how the opcodes are reported and changes he's made to the VLD to make it handle the branching smarter and make coverage more than just a "lines covered" metric. He shows an updated graph of the new coverage/branch flow and what a resulting coverage report might look like with the new "Paths" reporting.

0 comments voice your opinion now!
code coverage phpunit xdebug report paths vld lines

Link: http://derickrethans.nl/path-branch-coverage.html

Stefan Koopmanschap:
UWYC Use What You Can
January 05, 2015 @ 10:15:21

In his latest post, Stefan Koopmanschap shares an interesting idea he thinks more software developers would do well to adopt - Use what you can (or "don't do it yourself).

In her book, Amanda Palmer talks about DIY, and how when you start asking for help, Do It Yourself is a strange term. Instead, she suggests UWYC, which stands for Use What You Can. I think software developers can learn a lot from this mindset. As Palmer says: "I have no interest in Doing It Myself." This is exactly how we should approach software development.

He points out that, for the most part, the tasks and needs of most software have been solved. There already exists functionality to do those things, so why would you need to create your own? By doing so, you only increase your load as a developer, shifting the hard work of maintenance and improvement into your already loaded work schedule. He does make a good suggestion for using other people's code, though: filter the solutions (according to criteria like following good practices, documentation and if it's in active development).

0 comments voice your opinion now!
opinion code resuse diy usewhatyoucan

Link: http://leftontheweb.com/blog/2015/01/02/use-what-you-can/

SitePoint PHP Blog:
Visualize Your Code's Quality with PhpMetrics
December 26, 2014 @ 12:48:31

The SitePoint PHP blog has a recent tutorial showing how to use PhpMetrics to visualize your application and the quality of its code.

We had been looking into code quality checking tools for a while here on SitePoint - most recently in a series on Jenkins, but none of those could do what a project I've only recently found out about can. PhpMetrics uses D3 and some sophisticated analysis algorithms to scan your application's code and output intricate reports about it.

He walks you through the install (via Composer) and how to clone two example projects, Laravel and Symfony, to evaluate. He includes the command line to run the evaluation and plenty of screenshots showing the results for things like:

  • Cyclomatic complexity
  • Abstractness
  • Maintainability
  • Code density

He uses the results from these two projects in his examples and, at the end of the post, summarizes and compares the results it produced.

0 comments voice your opinion now!
code quality metrics phpmetrics visualize tutorial

Link: http://www.sitepoint.com/visualize-codes-quality-phpmetrics/

Eric Wastl:
Your Job Is Not to Write Code
December 04, 2014 @ 09:05:04

Eric Wastl has written an open letter to software developers out there in response to this post and sharing some of his own thoughts (and corrections) about what it suggested.

Dear [Software] Engineers, Your job is not to write code. Rather, your job isn't only to write code. Your job is to design and build software, and one of the steps in that process happens to be explaining to a computer how to do its new job. An article appeared on Medium recently that writing code isn't really a big deal and it's not really what your job is about. It is. You can smell "Product Manager" miles before the signature line of the article. The article goes on to talk about how your job is to improve your products for your users. This is not the job of an engineer - this is the job of every person at your company.

He talks about some of the "other jobs" the Medium article suggests a software developer be doing including making sure the "code runs the way it should" (devops, testing, etc) and that it "actually gets merged and pushed into production" (a release engineer). He points out the dissonance between the request for things to "run under all conditions" and when it makes sense to add analytics to your code.

Because your job is to write code. Your job is to write the best code you can, as quickly as you can, within budget, meeting all of the expected features, in a maintainable way, and a million other things, and still make the users happy. [...] Your job is to tell someone when you make a mistake. Your job is to work together with your testers and with operations and with product and finance and, yes, even the other engineers. Your job is to figure out what product will ask for before they ask for it, and build the code so that if and when they do, adding the feature is easy because the code wasn't written in a way that requires a year-long refactoring project to do it in a way that wouldn't make Cthulhu literally gleeful at the thought of it.
0 comments voice your opinion now!
software engineer write code opinion correction medium

Link: http://hexatlas.com/entries/5


Community Events

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


release interview application example laravel series conference install library symfony2 podcast php7 language configure performance opinion community api introduction framework

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