PHP.net

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:

ServerGrove Blog: Symfony2 components overview: Translation

PHPDeveloper.org - Tue, 18/03/2014 - 23:37

The ServerGrove blog has posted their latest up-close look at the various components that make up the Symfony2 framework. In their latest post, they focus in on the Translator component.

Modern applications need to be internationalized and localized to be able to reach people from all over the world. Internationalization - aka i18n - is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization - aka l10n - is the process of adapting internationalized software for a specific region or language by adding locale-specific components such as dates or currency. The Translation component provides different tools to get your application internationalized, but not localized.

The post covers the three main parts of the component - Catalogues, Loaders and Dumpers - and includes a simple example of creating the object, adding resources and calling "trans" to translate. There's also an example of using the YAML file loader to include the translated strings. There's also mentions of pluralization, translation "domains" and custom loaders.

Link: http://blog.servergrove.com/2014/03/18/symfony2-components-overview-translation/

Community News: Packagist Latest Releases for 03.18.2014

PHPDeveloper.org - Tue, 18/03/2014 - 15:01
Recent releases from the Packagist:

Community News: Latest PECL Releases for 03.18.2014

PHPDeveloper.org - Tue, 18/03/2014 - 14:04
Latest PECL Releases:
  • pthreads 2.0.1 Add globals inheritance option Add method to execute block in global scope Fix build when SPL is not loaded (spl sucks)

  • qb 2.1.1 Initial release

  • gmagick 1.1.7RC2 Changes to update support for PHP 5.6.0beta

  • solr 1.1.0b - SolrClient::system Access system servlet which fetch Solr Server System Information - SolrClient::commit argument $maxSegments is now DEPRECATED - SolrClient::commit Added support for expungeDeletes on - All SolrClient methods throws SolrClientExceptions instead of E_WARNING + SolrClientException - SolrClientExceptions' messages are more informative in case of connection errors - Added json extension validation - All SolrResponse, SolrQueryResponse, SolrUpdateResponse, SolrPingResponse, SolrGenericResponse, SolrDocument, and SolrInputDocument classes are now final - All parameters functions throws SolrIllegalArgumentException instead of E_RROR - SolrParams/SolrModifiableParams/SolrQuery throws SolrIllegalArguments Exception instead of E_ERROR (Feature #66858) - Various Bug Fixes

  • pthreads 2.0.2 Fix build in BSD and other *nix where PTHREAD_MUTEX_RECURSIVE_NP is enum

  • eio 1.2.4 Fix: Bitbucket issue #1: eio_open fails when file is owned by root

  • pthreads 2.0.0 Fix errors; inheritance and scope in threads (bugs in prepare) Fix fault; accessing destroyed objects (throw ex) Make use of inheritance within pthreads (bc compatible using alias) Remove abstract flag from ::run method Remove use of errors in favour of exceptions Remove all final modifiers on threaded objects Fix fault; submit to incorrectly constructed Pool Fixed fault; (re)using primitives that are object members across contexts Fixed fault; intermittent fault on session_start inside threads Various internal improvements

  • memcached 2.2.0RC1 - Fixes incorrect size when compressing serialized objects - Fixes endianess of compressed values

  • oci8 2.0.8 Enhancement - Improve performance of multi-row OCI_RETURN_LOB queries (Bug #66875)

  • mongo 1.5.0RC1 ** Bug * [PHP-995] - JSON detection * [PHP-996] - Broken with cyrus-sals 2.1.23 * [PHP-999] - Inline mapReduce command ignores read preferences * [PHP-1000] - RP support for "mapReduce" command, not just "mapreduce" ** Improvement * [PHP-998] - Include maxWriteBatchSize and maxMessageSizeBytes in connection info ** Task * [PHP-407] - MongoBinData should default to type 0 instead of 2 * [PHP-960] - Use createIndexes command when available * [PHP-987] - Use maxWriteBatchSize from ismaster for write command batch splitting. ** Sub-task * [PHP-993] - Merge batch return values into one return value

Syndicate content