PHP.net

CiteWorld.com: Facebook's Hack language a silver bullet for user-developers

PHPDeveloper.org - Wed, 26/03/2014 - 17:41

In this new post to CiteWorld.com, they're making the claim that the Hack language from the developers at Facebook is the "silver bullet for user-developers".

How do you modernize the way we build the web? That's the question at the heart of the release of a flurry of new languages and development platforms -- all from companies that run and build large scale web services. [...] While getting more out of CSS is good, as is replacing JavaScript; Facebook's HHVM and Hack combo is targeting one of the foundations of the modern web: rapid application development.

They talk some about the overall goals of Hack (improved performance, a stricter typing system) and include a brief example of some Hack code. They consider it to be a "more modern language" that brings PHP-based development up into a different level of languages. He also talks about HHVM a bit, migration from PHP to Hack and the potential for Hack to be adopted on other platforms outside of the current HHVM runtimes.

Link: http://www.citeworld.com/development/23156/hack-future

PHP Town Hall: Episode 22: The Great Joomla! License Battle of 2014

PHPDeveloper.org - Wed, 26/03/2014 - 16:59

The PHP Town Hall podcast has released their latest episode today - Episode 22, The Great Joomla! License Battle of 2014 with guests David Stanley and Don Gilbert.

This week Ben Edmunds is joined by new guest David Stanley and recurring guest Don Gilbert to discuss the latest Joomla! framework licensing drama. Phil was too busy having a real world life to join us this week, boo! Don does a great job of articulating why switching the Joomla! Framework to an LGPL license would be best for everyone and just might cure cancer. Ben tries to play devil's advocate but eventually can't even maintain the ruse. David talks now and then, mostly about his new found love of the AeroPress.

You can catch this latest episode in a few different ways: either through the in-page audio player, by downloading the mp3 or you can watch the video of the live recording.

Link: http://phptownhall.com//blog/2014/03/25/episode-22-the-great-joomla-license-battle-of-2014/

Community News: Packagist Latest Releases for 03.26.2014

PHPDeveloper.org - Wed, 26/03/2014 - 15:05
Recent releases from the Packagist:

ServerGrove Blog: Composer 101

PHPDeveloper.org - Fri, 21/03/2014 - 19:14

You might have heard about Composer but aren't quite sure what all the fuss is about it. In this new tutorial on the ServerGrove blog, they introduce you to it, help you get it installed and show how it can help you make dependency management simpler.

Composer is a tool for dependency management in PHP. It allows us to declare the libraries (packages from now on) on which our project depends on and downloads them for us. With many high quality packages available to us, the are redefining they way we are building PHP software. You can browse through the wide variety of packages at the composer main repository packagist.org. Composer is a simple tool to use and this tutorial will go over the installation and usage basics.

They walk you through the installation (or either *nix or Windows) and help you get started with your first "composer.json" configuration file. They talk about "composer.lock" and the role it plays and how Composer uses is (and the json version) to pull in dependencies for your libraries of choice. The article also briefly covers the "composer" command and the options it provides.

Link: http://blog.servergrove.com/2014/03/19/composer-tutorial/

Community News: Weca.mp Announced

PHPDeveloper.org - Fri, 21/03/2014 - 18:33

A new PHP-oriented conference has been announce, but this one has a bit of a twist. Weca.mp is taking place on an island and, instead of passively listening to speakers, attendees will "develop awesome stuff" with PHP.

WeCamp is a new event focusing on not just hearing about cool technology, but also applying it. During the 5 days of the event, you'll get to work on a project together with 4 random other people, under the guidance of an experienced coach. Together with your team mates, you'll work on improving both your technical skills while developing on the project as well as your soft-skills in managing the project and communicating with your team members.

The focus of the event is different than the usual conference-goer might be used to. It puts an emphasis on a work/relaxation mix with several activities besides things tech-related. Attendees will share tents ("glamping" style) with others for each evening of this five-day event and several "coaches" will be on hand to help guide activities. If you're interested check out the conference site or just pick up your tickets now - Early Bird is already sold out!

Link: http://weca.mp

Michael Dowling: Favor Hash Lookups Over Array Searches

PHPDeveloper.org - Fri, 21/03/2014 - 17:47

Michael Dowling has a recent post to his site comparing the performance of hash lookups versus array searches.

A common programming requirement is to match a string against a set of known strings. For example, let's say you were iterating over the words in a forum post and testing to see if a word is in a list of prohibited words. A common approach to this problem is to create an array of the known prohibited words and then use PHP's in_array() function to test if the string is found in the list. However, there's a simple optimization you can make to significantly improve the performance of the algorithm.

He includes two pieces of sample code - one showing the searching of an array using in_array and the other running an isset to locate a key. He points out that the in_array method is quite a bit slower than the hash (key) lookup and includes a benchmark script to prove it.The results are pretty clear, with the hash lookup coming in about 480% faster than the in_array. He also points out that as the size of the strings you're comparing grows, the performance of in_array drops even more.

Link: http://mtdowling.com/blog/2014/03/17/hash-lookups-over-array-search/

Community News: Facebook Releases the Hack Programming Language

PHPDeveloper.org - Fri, 21/03/2014 - 16:03

Yesterday marked a major point in the evolution of PHP and its ecosystem. Facebook released their version of PHP, Hack, based on the work they've been doing with the HHVM (HipHop Virtual Machine) and compiler.

Hack is a programming language for HHVM that interoperates seamlessly with PHP. Hack reconciles the fast development cycle of PHP with the discipline provided by static typing, while adding many features commonly found in other modern programming languages. Hack provides instantaneous type checking via a local server that watches the filesystem. It typically runs in less than 200 milliseconds, making it easy to integrate into your development workflow without introducing a noticeable delay.

One of the key features is that it mixes well with PHP and will feel very familiar for those already used to using PHP. The homepage for the language includes all the details you'll need to get started with it, including an interactive tutorial walking you through some of the basics. Some of the features included in the language are things like type annotations, generics, native collections and lambdas. You can find out more in their official announcement.

Link: http://hacklang.org

Community News: Packagist Latest Releases for 03.21.2014

PHPDeveloper.org - Fri, 21/03/2014 - 15:03
Recent releases from the Packagist:

SitePoint PHP Blog: CMS Showdown: Nginx, Ghost, PHP and Phalcon

PHPDeveloper.org - Thu, 20/03/2014 - 19:58

On the SitePoint PHP blog today Bruno Skvorc has written up the first part of his look at installing Ghost with Nginx and Phalcon on his hosting provider. This is the first post in his "showdown" series of trials on various CMS systems.

You might be wondering why I'm writing about Ghost on a PHP oriented channel - this series will be a showdown of all the various PHP based CMS' I can find, benchmarked against each other and against Ghost, as I look for the next best alternative. Since my DigitalOcean droplet already runs Nginx as a reverse proxy for the blog, I'll also be deploying all the CMS' on that same installation, each on its own subdomain.

He walks you through the whole process from start to finish:

  • Installing PHP on Nginx
  • Setting up a virtual host on a subdomain
  • Installing Phalcon
Link: http://www.sitepoint.com/cms-showdown-nginx-ghost-php-phalcon

Master Zend Framework:Simplifying Unit Testing (and asking for help when needed)

PHPDeveloper.org - Thu, 20/03/2014 - 18:54

On Matthew Ssetter's "Master Zend Framework" blog today he talks about simplifying unit testing and some of his experience with getting too complicated in his own testing practices.

Recently I was a bit stuck, trying to figure out how to test a section of an application I've been developing. Specifically, I was trying to mock a HydratingResultSet in a controller test, so it could be the return value of a method call on a datasource, my controller needed. I was sure it was the right approach to help ensure the functionality in question was working properly. But no matter what I tried, my tests didn't work, because I wasn't mocking it correctly. [...] I asked for help [on IRC], laying out the problem as I saw it. The first response which came back, from Ocramius, stopped me dead in my tracks: "Why are you trying to do that?"

He includes a bit of background on what he was trying to test and the functionality around it and how, when he stopped to think about it, wondered why he was testing it too. He talks about the refactor he made to his code with a positive end result - the tests now passed. He suggests a few questions to ask yourself when writing your tests such as "am I doing too much?" or "am I testing code in the right place?" Chances are, if you step back and really look at what you're testing, you might realize that the answer to these questions is just to simplify.

He finishes the post with a few suggestions, some of his own personal favorites, of places you can go for help when questions do pop up. He points out that the usual excuses shouldn't be a blocker on asking for help. He is "encouraging you to set your pride, ego and excuses aside and when you're stuck: ask for help."

Link: http://www.masterzendframework.com/people/right-approach-unit-testing-asking-help

The PHP.cc Blog: Disintegration Testing

PHPDeveloper.org - Thu, 20/03/2014 - 17:20

In this new post on thePHP.cc blog today Sebastian Bergmann relates the unfortunate disintegration of the Mars Climate Orbiter (back in 1999) back to a lesson on software testing and errors.

One of the most important tasks in software testing is to find the smallest scope in which a test case can be implemented. The smaller the scope in which a test is run, the faster it can be executed and the more precise its result. Unit Tests exercise one unit of code in isolation from all collaborators. Integration Tests verify the interaction of two or more collaborators in isolation from the rest of the system. Edge-to-Edge Tests run the software as end-to-end as possible in a single process (and without using a web browser or a web server). End-to-End Tests, or System Tests, look at the whole system and in the case of a web application send a HTTP request from a web browser to a web server running the software to inspect the HTTP response that is sent back.

He talks some about the difference between unit tests and acceptance tests and how "easy and seductive" functional tests can be over unit testing. He points out how fragile (and sometimes slow) this can be though, and how their failure only shows a problem and not where it is.

The promise of being able to develop both the business model as well as the software that implements it in an agile fashion should be reason enough for enterprises to invest in a modern, highly decoupled software architecture. And when the members of the software development team communicate well, both among themselves and with the other stakeholders, then there is not much that can really impede the success of the project. Link: http://thephp.cc/viewpoints/blog/2014/03/disintegration-testing

Joshua Thijssen: Dynamic form modification in Symfony2

PHPDeveloper.org - Thu, 20/03/2014 - 16:42

Joshua Thijssen has a new post to his site looking at a way to dynamically modify forms in a Symfony2-based application. Form handling can be a bit tricky (especially with more complex elements), and modifying them on the fly can be even more difficult.

Sometimes (or actually, a lot of the time), handling forms will go beyond the basics. And even though symfony2 gives you out-of-the-box a really clean way of creating forms, it sometimes just isn't enough. Fortunately, you are not alone in writing forms, and many posts exists with information on how to handle complex forms. In this post, I will try and demonstrate how to create a dynamic form where you can select a city based on the chosen province.

His example lets the user pick their province and then populates the other select with cities in that area. He includes the code for the form to create these two selects and how to pull out the list of provinces to populate the first. He goes through each part of the example code explaining the methods, what they're doing and how a pre-submit event can be used to populate the second list.

Link: https://www.adayinthelifeof.nl/2014/03/19/dynamic-form-modification-in-symfony2

Community News: Packagist Latest Releases for 03.20.2014

PHPDeveloper.org - Thu, 20/03/2014 - 15:09
Recent releases from the Packagist:

Medium.com: Getting Started With Laravel 4 - A Book Review

PHPDeveloper.org - Wed, 19/03/2014 - 19:52

On Medium.com there's a recent post reviewing the book "Getting Started with Laravel 4". In the review Christopher Pitt briefly covers both the good and bad parts of the book.

This book is aimed at newcomers to PHP development, and to Laravel 4 in particular. It doesn't disappoint. It starts slow, talking about the need for, and role filled by frameworks. It explains what Composer does, and why it's useful for frameworks like Laravel. It's not the typical "Laravel needs Composer, here's the code you use" stuff. There are 40 pages of what is essentially a very gentle introduction, before you even start writing code.

He talks about the sample application the book walks you through creating and some other topics around it including unit testing and artisan commands. He mentions the more popular Code Bright book and points out that he believes it (Code Bright) to be a better deal for the money if you're looking for the more comprehensive intro to Laravel.

Link: https://medium.com/tech-reviews/f8881d2014c7

php[architect]: March 2014 Issue Released - The New PHP

PHPDeveloper.org - Wed, 19/03/2014 - 18:17

The php[architect] publishing group has just released the latest edition of their magazine, the March 2014 issue. This issue, titled "The New PHP" includes articles like:

  • "Leveraging PHP 5.5" (Dirk Merkel)
  • "Coming Soon to a PHP Near You!" (David Rogers)
  • "The Confident Coder: Confident, Not Cocky" (Aaron Saray)
  • "Education Station: Getting Started with Phavour-Template" (Matt Setter)
  • "Laravel Tips: Adding Real Template Engines to Laravel 4" (Dirk Merkel)

You can pick up a single copy of you own from the php[architect] site or you can subscribe to a fill year of their print or PDF versions and get PHP goodness like this all year long.

Link: http://www.phparch.com/2014/03/march-2014-phparchitect-magazine-released/

SitePoint PHP Blog: Understanding Drupal's EntityFieldQuery

PHPDeveloper.org - Wed, 19/03/2014 - 17:02

On the SitePoint PHP blog there's a recent post that aims to help you understand the EntityFieldQuery class in the Drupal framework. The class lets you find entities based on properties, field values and other generic metadata.

When building complex web apps, you'll eventually have to interact with a database. To retrieve data in Drupal one can use the database abstraction layer provided, which requires some SQL knowledge to be used properly. From Drupal 7 EntityFieldQuery API is provided, which lets you fetch information about entities from Drupal without actually building SQL queries. In this article, let's see how we can use the EntityFieldQuery API to fetch data from Drupal and use it in our modules.

He starts by explaining a bit about the class and includes a bit of code showing how to create an instance of it. He then moves into the creation of a sample module that only locates an entity and relays the results back to the calling script. As a part of the example, he shows how to make the query to locate all "node" entity types and create a sidebar with links to each. He shows the addition of conditionals to the location call for properties, values and fields (as well as ordering the results).

Link: http://www.sitepoint.com/understanding-drupals-entityfieldquery/

VG Tech: Comparing Your Privates in PHP

PHPDeveloper.org - Wed, 19/03/2014 - 16:56

In a new post to their blog, the VG Tech folks talk about "comparing your privates" with a "hidden" feature of PHP. Don't worry, they're referring to private class properties on object instances here...

I was going to compare several private properties between to objects and started making a piece of code to perform the actual comparison using getters for the properties. I felt the approach sucked, and started looking into alternatives way to do this.

He shares what the current PHP documentation shares about comparing objects, but neither of them take private properties into account. He remembers, however, that object visibility is at the class level not instance level, allowing two object instances of the same class to have access to all properties of the other, regardless of exposure level. He includes a code snippet showing how to use this to compare those private properties.

Link: http://tech.vg.no/2014/03/14/comparing-your-privates-in-php/

Community News: Packagist Latest Releases for 03.19.2014

PHPDeveloper.org - Wed, 19/03/2014 - 15:03
Recent releases from the Packagist:
Syndicate content