2013年2月28日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

Community News: Packagist Latest Releases for 02.28.2013

Recent releases from the Packagist:

Andrew Podner: Rock On, Refactor, or Re-roll?


In his latest post Andrew Podnet looks at a common situation for developers during one project or another. It's the struggle whether to "rock on" and keep developing a project as it's planned, refactor what's already there into something new or re-roll the whole thing completely, scrapping it for a possibly better structure.



I went to my standard code library, developed on my own over a period of 3 or 4 years and starting piecing together a core application that I could start building on. I worked on this application diligently from June to September, and I would say in that time I had made it 70% of the way through the app. I was being relatively careful about doing manual functional tests, and I felt good about what I was doing with the application where security practices were concerned. Then 2 things happened almost simultaneously that really put a wrench in the works.


He was working on a project for several months, but due to other circumstances, he had to set it aside for a while. When he came back, he had a new perspective on things and saw lots of places in the code that things could have been done different/better. The post goes through some of his thought process and how it relates to the three "roll on", "refactor" or "re-roll" the current state of the application. He does have a reminder for developers facing the same situation, though:



The whole reason I am writing this post, other than to just get my thoughts down and help make the call, is to illustrate the importance of remembering that as developers, one of our key objectives for the client is to deliver value. This is a fact that can sometimes get away from us.

Matthew Weier O'Phinney: On PHP-FIG


Matthew Weier O'Phinney has a new post to his site today covering the reasons he left the PHP-FIG, the PHP Framework Interoperability Group that was designed to help unify the framework (and PHP) communities with common goals and structure. He talks some about his reasons for leaving and what he hopes the group will, eventually, become.



I had high hopes for the group. It was the culmination of something I've been ruminating on for almost a decade (see post number 12 on my blog, dated to January 2004, for proof). My thoughts have mainly been around coding standards and best practices, helping educate developers around their benefits, and how to leverage both in order to create maintainable code.


He talks about some of the things he sees as shortfalls of the group including the definition of some of the standards (and interface structure), the current thoughts of changing of said standards and some of the "discussion" that happens in the group via the mailing lists and pull requests. He mentions that there were several times that the same discussions would happen all over again, despite people saying it had, and is tired of it.



I have better things to do with my time, things I want to create, software I want to support, hobbies and interests I want to pursue. Debating brace placement, tabs vs spaces (for the umpteenth time), or whether or not annotations have a place in programming in a dynamic language? Not so much.

2013年2月27日星期三

Community News: Latest Releases from PHPClasses.org

Community News: Packagist Latest Releases for 02.27.2013

Recent releases from the Packagist:

WebDevRadio: Episode 108: New Ruby, Regex and my Framework Security Rant(tm)


Michael Kimsal has just released the latest episode of his WebDevRadio podcast series, Episode 108: "New Ruby, Regex and my Framework Security Rant(tm)". His framwork security comments are related to PHP frameworks and why almost none of them seem to come with security features already included.



Ruby 2 was just released, and the new 'refinements' feature presents some interesting challenges for JRuby and just about anyone wanting to read Ruby code. Brief chat about the regex security affecting Rails back in January, but more broadly speaking, what does this say about regex in general? Should we embrace it, or find better alternatives? Finally, I've got a new blog post up about web framework security - why do (almost) no web frameworks ship with security baked-in?


The podcast references some of the thoughts from his recent post about framework security. You can listen to this latest episode either through the in-page player or by downloading the mp3.

Simon Holywell: Idiorm and Paris 1.3.0 released - the minimalist ORM and fluent query builder for PH


Simon Holywell has a new post to his site about a project that aims to be a minimalist ORM library and make it easier to built queries on the fly for your applications (and is installable via Composer) - the Idorm + Paris combination.



Idiorm is a PHP ORM that eschews complexity and deliberately remains lightweight with support for PHP5.2+. [...] However, having said this, Idiorm is very powerful and it makes most of the queries PHP applications require pain free. Some of these features include fluent query building, multiple connection support and result sets for easy record manipulation. Paris sits on top of Idiorm to provide a simplified active record implementation based upon the same minimalist philosophy.


He includes examples in the post of both queries with Idiorm - simple things like creating and finding records - and using Paris to make models out of PHP objects. He also talks some about the current state of the project, recent advancements and some of the things they're looking to do with it in the future (including dropping PHP 5.2 support and use late static binding).

Ulrich Kautz: C-based Web Frameworks for PHP


In this recent post to his site Ulrich Kautz takes a look at an interesting development in the PHP framework world - C-based frameworks installable as PHP extensions. He covers some of the good and bad things about this approach.



At the End of 2012 I had my first contact with a C-based PHP frameworks, namely YAF. Coincidently, some day afterwards Bruno from phpmaster.com pointed me towards Phalcon - a more modern interpretation of the same idea. So I was hooked.


In his "good idea" category he notes that it's faster because it's already loaded in on the request (no long list of includes) and the memory footprint is less than a PHP equivalent. The "bad" side of things mentions some pretty major hurdles though, including the small communities vs larger ones on PHP-based frameworks and the issues that could come with debugging/upgrading.

2013年2月26日星期二

Community News: Latest PECL Releases for 02.26.2013

Latest PECL Releases:
  • leveldb 0.1.2
    2013-02-24 - leveldb 0.1.2
    - Fixed bug when explict specify NULL comparator/snapshot raises exception
    - Fixed memory leaks when sepecify invalid snapshot
    - Fixed memory leaks of LevelDB::get()


  • leveldb 0.1.3
    2013-02-24 - leveldb 0.1.3:
    - 0.1.3 is a version number fix upon 0.1.2 which forgot to
    remove '-dev' suffix before release


  • event 1.2.5
    This is the first release on PECL since 1.0.0. Previous releases are available
    here: https://bitbucket.org/osmanov/pecl-event

    Add: callbacks and the callback arg are now passed to EventBufferEvent::__construct as optional arguments
    Change: EventBufferEvent enable/disable methods return bool now
    Change: instead of stream pass numeric file descriptor to EventListener's accept-connection callback
    Fix: unneeded Z_ADDREF_P() calls in EventListener, EventBufferEvent constructors and factory methods
    Fix: EventListener cached file descriptor for all connections


  • eio 1.2.1
    Fix: build failed without sockets extension
    Fix: eio_write failed when buffer length was lesser than size + offset


  • dio 0.0.7
    Added far better windows error reporting. Warnings now raised when Win32 API
    calls return errors. The warnings include the underlying Windows error
    message.


Community News: Packagist Latest Releases for 02.26.2013

Recent releases from the Packagist:

PHPMaster.com: Functional Programming and PHP


On PHPMaster.com today there's a new tutorial written up by Shameer C looking at functional programming with PHP - some of the basic concepts of it and how much is possible in the language.



Many programmer like to talk about functional programming, but if you ask them if they've ever done it, most of their replies will be "No". The reason is quite simple: we are taught to think in an imperative manner when we first start learning to program, in terms of flow charts and steps to be followed in the program. So in this article I'll explain some important concepts to functional programming and how to write functional code in PHP.


He starts by defining some of the basic fundamental concepts of functional programming including recursion, referential transparency, higher order functions and lambda functions. He includes a bit of code along the way, showing things a bit more practically.

Symfony Blog: New in Symfony 2.2: The new fragment sub-framework


Fabien Potencier has new post post to the Symfony Blog today talking about a big update to the Symfony framework, the introduction of a new "fragment sub-framework". This framework (now a part of the HttpKernel) allows the handling of requests based on a few different strategies.



About a month ago, I merged a complete refactoring of the sub-requests management of Symfony. In fact, I created a whole new sub-framework to handle the rendering of resource fragments via different strategies. [...] Besides classical master requests, the HttpKernel component is now able to handle sub-requests. Let's me sum up the different strategies that are available: internal sub-requests, ESIs, HIncludes, and SSIs (in 2.3).


He talks some about each strategy and what situations they're best suited for and some sample code that shows the use of the "standalone" and "strategy" parameters. There's also new methods you can call (like "render_esi" or "render_hinclude") to work with the new features as well.

2013年2月25日星期一

Community News: Latest PEAR Releases for 02.25.2013

Latest PEAR Releases:

Community News: Packagist Latest Releases for 02.25.2013

Recent releases from the Packagist:

Maarten Balliauw: Working with Windows Azure SQL Database in PhpStorm


Maarten Balliauw has a new post to his site showing how you can work with a Azure SQL database directly from the UI of the popular PHP IDE, phpStorm.



PhpStorm provides us the possibility to connect to Windows Azure SQL Database right from within the IDE. In this post, we'll explore several options that are available for working with Windows Azure SQL Database: Setting up a database connection, creating a table, inserting and updating data, using the database console, generating a database diagram and database refactoring.


He includes the instructions and several screenshots showing each step of the above mentioned steps. The database diagram gives you a good overall view of your database structure and allows you to show a visualization of how the tables relate to each other. Note that, though this particular example shows it connecting to an Azure SQL database, the same setup can be used with lots of popular RDBMS out there.

Kevin Schroeder: Why you should not use .htaccess (AllowOverride All) in production


Kevin Schroeder has posted the results of some research he did around using the "AllowOverride" setting in Apache. He found some interesting differences when it was set to "all".



Commonly known as .htaccess, AllowOverride is a neat little feature that allows you to tweak the server's behavior without modifying the configuration file or restarting the server. [...] Beyond the obvious security problems of allowing configuration modifications in a public document root there is also a performance impact. What happens with AllowOverride is that Apache will do an open() call on each parent directory from the requested file onward.


He includes the output from a strace call in the post - first showing the function calls with it set to "none" then the same request with the setting on "all". More "open" calls are being made in the second run, increasing the execution time by a decent amount.

2013年2月24日星期日

Community News: Packagist Latest Releases for 02.24.2013

Recent releases from the Packagist:

2013年2月23日星期六

Community News: Packagist Latest Releases for 02.23.2013

Recent releases from the Packagist:

2013年2月22日星期五

Site News: Popular Posts for the Week of 02.22.2013

Popular posts from PHPDeveloper.org for the past week:

Community News: Packagist Latest Releases for 02.22.2013

Recent releases from the Packagist:

PHP.net: PHP 5.4.12 and PHP 5.3.22 released!


On PHP.net today they've announced the release of PHP 5.4.12 and 5.3.22, the latest versions of the two current release branches.



The PHP development team announces the immediate availability of PHP 5.4.12 and PHP 5.3.22. These releases fix about 10 bugs. All users of PHP are encouraged to upgrade to PHP 5.4.12.


It's a bug fix release, but everyone's encouraged to update. It corrects things in core, FPM, sqlite, PDO_OCI, the Zend Engine and date functionality (and a bit more). You can get this latest version from the downloads page or windows.php.net for the Windows binaries. If you'd like to see the full list of issues fixed, check out the Changelog.

Michael Kimsal: Why do no almost no web frameworks come with any authentication/authorization?


In a new post to his site Michael Kimsal poses an interesting question about something he's noticed in several frameworks - and not just PHP ones: there seems to be a lack of authentication/authorization functionality coming bundled in.



Why do almost no web frameworks provide any default authentication/authorization functionality, with default examples of best practices for common use cases. The standard response I've gotten for years was/is "well, everyone's needs for authentication are different". No, they are not. A (very?) large majority of web applications (which is what most web frameworks are used to build), require some form of user login and authorization management, and often self-registration, dealing with lost passwords, etc.


He points out that by not having something a user can immediately deploy that's been well tested and relatively risk-free, it can introduce security holes as a developer is "left to fend for themselves". He suggests that the "not everyone's the same" mentality that seems to go with authentication/authorization isn't as valid as once thought. He does point out that both Symfony2 and Zend Framework 2 come with ACL functionality, but no common user handling. He mentions ones in a few other tools used in other languages too like Devise in Ruby, Spring Security in Grails and a membership system in ASP.NET.

2013年2月21日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

Community News: Packagist Latest Releases for 02.21.2013

Recent releases from the Packagist:

PHPMaster.com: Working with Slim Middleware


On PHPMaster.com Timothy Boronczyk has written up a tutorial about using the Slim microframework as a sort of "middleware" in your application - a wrapper around other functionality with an easier to use interface.



Slim is a microframework that offers routing capabilities for easily creating small PHP applications. But an interesting, and powerful, feature is its concept of Middleware. [...] I've found middleware to be an eloquent solution for implementing various filter-like services in a Slim app, such as authentication and caching. In this article I'll explain how middleware works and share with you a simple cache example that highlights how you can implement your own custom middleware.


He talks about what "middleware" is (complete with illustration) and how Slim can be used as a layer in the middleware stack. His example is a caching layer, based on Slim, that takes a request, checks the cache for it and returns it if it exists. If not, it saves the content to a database. He also includes code examples of how to use the "add" method to introduce your middleware libraries into the Slim application.



If you'd like more examples, the Slim project has several middleware examples provided in their "extras" github repository.

Andi Gutmans: Zend Server 6 is launched and available on the Amazon Web Services (AWS) Marketplace


Andi Gutmans has a new post to his site about a recent update to the offerings on the Amazon Web Services (AWS) - it now offers Zend Server 6 as an installable option.



Zend Server 6 is the ideal application platform for mobile and web applications, and this version brings a new level of enterprise capabilities. [...] Today, I'm also pleased to share that this newest version of Zend Server is now available on the Amazon Web Services Marketplace. Now, for one combined fee with Amazon Web Services, you can run your applications on a fully supported PHP application platform with Zend Server 6 running on Red Hat Enterprise Linux or Ubuntu Linux.


If you're interested in what Zend Server has to offer, check out the product page on the Zend website. Zend Server handles a lot of the base level things for you and can help you get up and running quickly. It includes things like detailed monitoring, error tracking, code tracing and a nice UI to for management and configuration of the server.

2013年2月20日星期三

Community News: Latest Releases from PHPClasses.org

Community News: Packagist Latest Releases for 02.20.2013

Recent releases from the Packagist:

Anthony Ferrara: Preventing CSRF Attacks


Anthony Ferrara has written up a new post to his site looking at efective use of CSRF tokens and a few different strategies for generating them.



There's been a bit of noise in the past week about the proper way to prevent Cross-Site-Request-Forgery (CSRF) attacks. It seemed to have started with this post. There's been discussion in the comments, and on Twitter about it, and there seems to be several opposing viewpoints on the matter. I want to start off by saying that I agree completely with the post in question. But I figured I'd write a post to explain WHY I agree with it.


He starts with an overview of a few of the common types of request forgery including from a javascript injection, a Man-in-the-Middle attack and a replay attack. He then breaks up the "lines of defense" part of the post into three different sections - adding a hidden token field to forms, changing the token for each request and using random numbers when regenrating them.

Fabien Potencier: Don't use PHP libraries with known security issues


In his latest post Fabien Potencier introduces a new effort to help PHP developers using Composer for their dependencies find potential security issues automatically - the security.sensiolabs.com site.



I want to provide a simple and efficient way to check for vulnerabilities in a project and I want to serve more than just the Symfony community. That's why I'm really proud to announce a new SensioLabs initiative: a simple way to check if your project depends on third-party libraries with known security issues. The website explains how it works in details (https://security.sensiolabs.org/), but basically, this initiative gives you several ways to check for security issues in your project dependencies based on the information contained in you composer.lock file (you are using Composer to manage your dependencies, right?)


Composer users can upload their "composer.lock" file and the system will evaluate it against the vulnerabilities it knows about and return any issues it might find. The current database is hosted on github and can be added to by anyone using a pull request. Additionally, you can install the command-line version if you want to do checks locally.

2013年2月19日星期二

Community News: Latest PECL Releases for 02.19.2013

Latest PECL Releases:

Community News: Packagist Latest Releases for 02.19.2013

Recent releases from the Packagist:

Kevin Schroeder: Would this be a dumb idea for PHP core?


In this new post to his site Kevin Schroeder thinks out loud and wonders if an idea of his is "a dumb idea" to be included into the PHP core - engine state caching.



I was consulting and I would see significant server resources consumed by bootstrapping the apps. Loading config files, loading dependent classes, setting up dependencies, initializing ACL's, and the list goes on and on. One of the ways to negate the effect would be to cache a bootstrap object and then pull that object from the cache at the start of the request. However, the problem is that unserialization can actually end up taking more time than the bootstrap process itself.


He wonders if, after the initial bootstrapping happened, a method could be called (his example is "init_engine_state") that would cache the Zend Engine's current state and pass that to a callback function. This would cache everything - objects, variables, classes, etc - all pre-interpreted into memory and make them easy to reuse on future executions. What do you think? Share your thoughts in the comments of the post.

Lorna Mitchell: New Book: PHP Web Services


Lorna Mitchell has officially announced the release of her O'Reilly-published book about creating and working with web services in PHP, PHP Web Services.



I'm delighted to announce that my new book "PHP Web Services" is now available as an early release! [...] The book isn't huge (or expensive, hint!), but it aims to give solid theory in a practical and approachable way. There's the topics you'd expect to see, covering HTTP and verbs and headers and status codes, and also around data formats. It also covers RPC services including SOAP, and also has a chapter (predictably the longest one!) about REST. I've tried to go beyond simply the "how to do" and into the "how to do in a kick-ass manner" realm, so there are chapters about how to design your API and choose what kind to build, how to handle errors, how to make your API really robust - and of course how to debug when things go wrong!


The book not only has the summaries and descriptions of some common web service challenges, but also includes code samples you can use in your own projects.