PHP Community

PHP World Championship of the Nations of the Innovation Award

Planet-PHP - Wed, 15/01/2014 - 11:37
By Manuel Lemos
This year is starting a new initiative that aims to distinguish the countries where are the most innovative PHP developers. It is the PHP World Championship of the Innovation Award.

Read this article or watch the explanatory video to learn all about this initiative and how you and your country can be distinguish for your great PHP contributions.
Categories: Open Source, PHP Community

sabre/http 2.0 released

Planet-PHP - Wed, 15/01/2014 - 03:58

Last week we released the 2.0 version of sabre/http. This package had been integrated into sabre/dav since 2009.

The old API was pretty much grown organically based on changing requirements. It worked well, but had some issues that made it not super intuitive to work with.

So we used the 2.0 release to take a deep look at the core requirements, and adjust the API to make it easier to use, while also being more elegant.

What is it?

sabre/http provides at it's heart a Request and a Response object.

The request objects acts as a wrapper around the $_SERVER array and php://input. The response object wraps php://output, echo() and header().

Because all of these PHP language constructs operate globally, by wrapping these in classes objects we can use all the standard OOP functionality such as polymorphism.

To aid with this, a Request-, and ResponseDecorator have also been included.

In addition to that, it also provides a simple HTTP Client. This client just wraps around Curl with not much fuss and simply allows you to re-use the existing Request and Responses, for a consistent experience.

The client doesn't attempt to give you all the features on the planet such as Guzzle. It just gives you a simple event-based asynchronous API, but if you need advanced Curl features, you do get easy access to them.

By doing both a Client and a Server-side of this, this also makes it ridiculously easy to build stuff like a reverse proxy server right in PHP.

To read more, all the documentation can be found on the github page.

How does this compare to symfony's http foundation?

Symfony's http-foundation is very similar, in that it provides an OOP abstraction around PHP requests and responses.

When this library was first written, neither that package, nor an easy way to depend on it existed yet. That has changed though, so I did consider integrating it instead.

The first deterrence was that both it's API and implementation are quite ugly, there are a massive number of classes, and a bunch of design decisions have been made that I consider violations of seperations of concerns.

I was willing to get over those for the sake of interopability. The main issue I ran into then was that I absolutely required features that the authors were unwilling to implement. Specifically the retention of the capitalization of http headers.

This made me realize that because sabre/dav is really a power-user for this type of package. WebDAV is an extension of HTTP, and uses nearly every feature out there. It leans much heavier on HTTP than most browser applications and even API's do. In addition to that it has to work with many broken clients. WebDAV clients are not nearly as well-behaving as Browsers.

So we decided this package was 'core' enough to maintain ourselves, so we can have full control over it. Looking back I think this was a good decision, as symfony has also done a number of backwards-compatiblity breaking releases since I originally looked at it.

Also, it's a small enough package that there's not that much of a maintenance burden, and it was hella fun to write.

Integration with SabreDAV

This package will be part of the next major SabreDAV release. So don't use it with the current line of releases (1.8.x), as it will not work!

In conclusion

Well, I hope you like it. I'd probably still recommend using symfony's package, for the sole reason that it has a much larger user-base, but if you are looking for something pure and lightweight to solve this particular problem, perhaps you can consider sabre/http instead.

Categories: Open Source, PHP Community

SitePoint PHP Blog: New Features in PHP 5.6

PHPDeveloper.org - Tue, 14/01/2014 - 20:56

On the SitePoint PHP blog Bruno Skvorc has posted a guide to what's new in PHP 5.6, the upcoming release of the language.

It's been a while since the release of PHP 5.4, and new versions have been coming out faster and faster ever since. When 5.5 hit and introduced some unexpectedly great features, the PHP community breathed a sigh of relief and regained hope of a more dedicated, structured and smart core development. Whether or not we'll actually get this remains to be seen, but the future does indeed look promising, especially if one looks at the PHP 5.6 changes made so far.

He goes through the list of things (so far) that will be in the upcoming release:

  • MIME types in the CLI web server
  • Internal Operator Overloading
  • Uploads of over 2GB are now accepted
  • POST data memory usage decreased
  • Improved syntax for variadic functions
  • Constant Scalar Expressions
  • PHPDBG bundled by default
  • Zip improved
  • Importing namespaced functions

Each item on the list comes with either some sample code to show its use or a brief explanation of the features it adds or updates.

Link: http://www.sitepoint.com/new-features-php-5-6

Phil Sturgeon: The "Framework" is Dead, Long live the Framework

PHPDeveloper.org - Tue, 14/01/2014 - 19:16

Phil Sturgeon has stirred the pot once more with a new post to his site suggesting that the "framework" is dead, but the framework still lives on (the difference being one is a structured whole, the other is made up of packages).

There have been a few posts over the last few months saying that the age of the framework is dead, and that Composer is the true savior, and other similar messages. This is half-true, but lots of people have been using the word "framework" differently over the years and I wanted to really work out a good definition of what a "framework" was in relation to PHP development, and in relation to these discussions.

His suggestions, sparked by a conversation on Twitter, suggest that frameworks should only provide the architecture of the application, a "set of lines to color inside". He goes back in time and looks at PHP frameworks past (like CodeIgniter and Kohana) and compares them to some of the popular ones of today like Zend Framework 2, FuelPHP, Laravel and Aura. He also talks about the good and bad of traditional frameworks, how they can be harmful to beginners in PHP and how much more difficult it's getting to be to say "That framework is popular" because of the changing definitions.

Link: http://philsturgeon.co.uk/blog/2014/01/the-framework-is-dead-long-live-the-framework

Konstantin Kudryashov: Conceptual difference between Mockery and Prophecy

PHPDeveloper.org - Tue, 14/01/2014 - 18:47

In a new post to his site today Konstantin Kudryashov takes a look at two PHP testing tools and the differences/similarities between them - Mockery and Prophecy. Mockery is a mocking tool created by Pádraic Brady to make mocking simpler and Prophecy is more of a mocking framework, both for use in PHP unit testing.

Today I've been asked twice what's the difference between Mockery and Prophecy just to suddenly discover that I didn't clarify this aspect never before. Well, that's about time. If we were to remove all the syntactical and implementation differences between two libraries what we'll be left with is one really big conceptual difference and it's the fact that in contradiction to Mockery, Prophecy puts messaging (aka how objects communicate) before structure (aka when objects communicate).

He starts with a sample class (the usual "calculator" example) and shows how it would look to mock it out with each tool, setting return values for both the "getRating" and "setRating" methods. He enhances the tests a bit more to include an event dispatcher and raising an event. The approach is similar, but Prophecy uses something called "message binding" to more effectively handle changes to the class under test.

Link: http://everzet.com/post/72910908762/conceptual-difference-between-mockery-and-prophecy

Voices of the ElePHPant: Interview with Eli White

PHPDeveloper.org - Tue, 14/01/2014 - 17:19

The Voices of the ElePHPant podcast has release their latest episode today - another interview with a member of the PHP community. This time it's with Eli White of Muskteers.me and [php]architect.

In the interview Cal and Eli talk about the differences between conferences like ZendCon and [php]tek and where the group is looking to take the [php]tek conference in the future. They discuss the idea of the many local conferences that have popped up over the last year and how they've almost become the "community conferences".

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

Link: http://voicesoftheelephpant.com/2014/01/14/interview-with-eli-white-2

Create personalized phar files in PHP

Planet-PHP - Tue, 14/01/2014 - 16:20
Created a screencast to show how you can create phar files, most importantly personalized phar files to store some information inside it and protect it using user’s password. Those information is usable only when user providers a correct password. For packaging, I used http://box-project.org which is an excellent phar packager. I’ve also used two functions... Read More in Create personalized phar files in PHP
Categories: Open Source, PHP Community

Community News: Packagist Latest Releases for 01.14.2014

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

Community News: Latest PECL Releases for 01.14.2014

PHPDeveloper.org - Tue, 14/01/2014 - 15:01
Latest PECL Releases:
  • ircclient 0.3.0 * Allow infinite timeout in Session::run() * The read and write fd arrays may now be empty and still trigger a select() in Session::run()

  • yaf 2.3.0 - Fixed Issue #80 (Segfault if empty application.directory is set) - Implemented Yaf_Response::setHeader, getHeahder, setAllHeader, clearHeaders Methods - Added Yaf_Route_*::assemble()

  • yaf 2.3.1 - Fix package

  • yaf 2.3.2 - Fixed windows build - Changelog 2.3.0: - Added Yaf_Response::setHeader, getHeahder, setAllHeader, clearHeaders Methods - Added Yaf_Route::assemble. (Now you can assemble url via routes) - Fixed Segfault if a empty application.directory is set

Interview with Eli White

Planet-PHP - Tue, 14/01/2014 - 07:00
Categories: Open Source, PHP Community

Aura.Cli 2.0.0-beta1 Released

Planet-PHP - Mon, 13/01/2014 - 23:08

The Aura.Cli package provides the command-line equivalents of web request and response objects. The Context (request-equivalent) object allows insight into the $_ENV, $_SERVER, and $argv values, along with a Getopt object that lets you build and then parse flags and options passed at the command line. The Stdio (response-equivalent) object provides access to to the standard input/output/error streams.

Via .

Categories: Open Source, PHP Community

The Aura.Cli Package

Planet-PHP - Mon, 13/01/2014 - 23:08

The Aura.Cli package provides the command-line equivalents of web request and response objects. The Context (request-equivalent) object allows insight into the $_ENV, $_SERVER, and $argv values, along with a Getopt object that lets you build and then parse flags and options passed at the command line. The Stdio (response-equivalent) object provides access to to the standard input/output/error streams.

Via http://auraphp.com/blog/2014/01/11/aura-cli-2beta1/.

Categories: Open Source, PHP Community

PHP 5.5.8 is released

php.announce - Mon, 13/01/2014 - 20:23
Categories: PHP Community, PHP.net

SitePoint PHP Blog: PHP and Neo4j: Introduction to Graph Databases

PHPDeveloper.org - Mon, 13/01/2014 - 20:18

On the SitePoint PHP blog today they've posted a new tutorial by Mehul Jain about combining PHP and Neo4J, a popular graph database tool as an alternative to the typical table-driven database structure. This is the first part of a series and only explains some of the basics behind the technology. The actual PHP implementation comes next.

For a long time, data has been typically stored in tabular form so as to increase the indexing and readability. Nowadays, the trends are changing as Graph databases are quickly gaining popularity. In fact, it would not be wrong to call them "the future of DBMS". New to the world of graphs and databases? Don't worry, by the end of this introductory article you will have sound theoretical knowledge about the topic - just enough to easily glide through the rest of the series - actual implementation.

He starts with the basics - introducing the ideas behind graph databases and some of the most basic concepts behind them. He continues, looking at common uses for them including dealing with connected data and how it lets you "move through" the data rather than jumping from record to record. He includes some real world examples if this kind of data ranging from social networks to network management.

Link: http://www.sitepoint.com/php-neo4j-introduction-graph-databases/

Engine Yard Blog: The Outer Iterator

PHPDeveloper.org - Mon, 13/01/2014 - 19:45

On the Engine Yard blog they have a new tutorial posted by Cal Evans looking at an object offered by the Standard PHP Library - the OuterIterator.

When PHP 5 arrived there was great excitement and rejoicing over the new object model. For many of us who struggled through PHP 4′s "Object Based" paradigm, PHP 5 was a ray of sunshine. We were so excited that many of us lost sight of another important addition to PHP 5, the Standard PHP Library (SPL).

Since then, the excitement over the object model has died down. Many authors and speakers have talked about, blogged about, and written about the SPL. However the SPL itself is a very large topic. We are going to narrow our focus down a bit to a subtopic of a specific section of the SPL. This blog post will deal with the OuterIterator. This is an interface defined in the SPL and used by several of the built in iterators.

He goes on to give a brief introduction about what the OuterIterator is and some examples uses for it, including one of the easier to follow - using it with a FilterIterator-based class. He gets into more detail about how the OuterIterator works and includes example snippets to help clarify. His "DwarfPrinter" class extends the FilterIterator and echoes out the names of The Seven Dwarves. He also includes an example of the output showing a more formatted output that follows the nesting and execution of the iterator. He finishes off the post with a list of iterators are useful to pair with the OuterIteator.

Link: https://blog.engineyard.com/2014/the-outer-iterator

Perl Library for the Webthumb API

Planet-PHP - Mon, 13/01/2014 - 19:06

David Precious has released a perl library for the Webthumb API.

Its available on CPAN, WebService::Bluga::Webthumb

Thanks David.

Categories: Open Source, PHP Community

NetTuts.com: Building a Customer Management App Using AngularJS and Laravel (Part 1)

PHPDeveloper.org - Mon, 13/01/2014 - 18:37

On NetTuts.com today they've posted a new tutorial showing you how to combine two powerful (and popular) technologies to make a customer management application - Laravel and AngularJs. This is the first part of a series and focuses on the backend work in Laravel.

When creating a single-page app we should use some kind of framework to do some of the job for us, so we can focus on the actual functionality. AngularJS fits here perfectly, because features like dynamic dependency injection and bi-directional data binding are just great. Sometimes we also require some kind of server. If you've chosen PHP then Laravel may be your best option, as it's easy to work with and pretty powerful.

They assume that you'll already have an instance of Laravel all set up and that you'll have access to a MySQL server for a database. Other than that, they provide all of the code you'll need to get the server side up and running. The application stories simple data about customers and transactions and walks you through making models and controllers for each.

Link: http://net.tutsplus.com/tutorials/php/building-a-customer-management-app-using-angularjs-and-laravel/

Nikita Popov: The case against the ifsetor function

PHPDeveloper.org - Mon, 13/01/2014 - 17:22

In his latest post Nikita Popov aims to make a case against the introduction of the "ifsetor" function to be introduced into the PHP language. This function takes in a variable to find and, if found returns it. If not, it doesn't produce an error (or warning).

Recently igorw wrote a blog post on how to traverse nested array structures with potentially non-existing keys without throwing notices. The current "idiomatic" way to do something like this, is to use isset() together with a ternary operator. [...] Someone on /r/PHP pointed out that there is an alternative approach to this problem, namely the use of an ifsetor function.

He goes on to talk about by-reference argument passing, why requesting an undefined array index doesn't really throw an error and how writes don't have the same issues as reads. He then gets into his own issues around the "ifsetor" function, namely:

  • Creation of dummy values
  • No notices for nested indices
  • Null values treated as non-existing
  • Default is always evaluated
  • By-reference passing often forces a copy

He summarizes most of the issues in one statement - "there is way too much by-ref magic involved". He then looks at some of the ways that this could be helped but opts instead for something more like "get_in" as proposed by Igor.

Link: http://nikic.github.io/2014/01/10/The-case-against-the-ifsetor-function.html

PHP.net: PHP 5.5.8 Released

PHPDeveloper.org - Mon, 13/01/2014 - 17:10

The PHP development group has officially released version 5.5.8 of the PHP language:

The PHP development team announces the immediate availability of PHP 5.5.8. This release fixes about 20 bugs against PHP 5.5.7 components.

There's no critical issues fixed in this release, but - as always - it's recommended that you update. Changes cover a wide range of areas in the language including the Date, DOM, Filter, GD MySQLi, SOAP and Sockets functionality. You can download this latest source version from the downloads page or the Windows binaries. If you'd like to view the full list of fixes and changes, check out the Changelog.

Link: http://php.net/index.php#id2014-01-10-1

Community News: Packagist Latest Releases for 01.13.2014

PHPDeveloper.org - Mon, 13/01/2014 - 16:02
Recent releases from the Packagist:
Syndicate content