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

Edd Mann:
Tuples in PHP
April 18, 2014 @ 09:48:38

Edd Mann has a new post today sharing some of his exploration into implementing tuples in PHP. A tuple is a common data structure in other languages consisting of an immutable, ordered list of items.

Since exploring languages such as Scala and Python which provide the tuple data-structure, I have been keen to experiment with how to clearly map it into a PHP solution. Tuples are simply a finite, ordered sequence of elements - usually with good language support to both pack (construction) and unpack (deconstruction) of the values. I have found that many use-cases of the common place array structure in PHP could be better suited to n-tuple's. [...] I discussed briefly that what makes tuples so powerful in the highlighted languages is their good support for handling their contents, for example unpacking a user tuple into separate id and name variables. PHP supports this form of unpacking in regard to arrays using the 'list' function, which I frequently use to return multiple values from a function/method invocation.

He shares the code for his basic implementation, extended from the SplFixedArray, and shows an example of it in use. He also includes samples showing how to make typed tuples via a "type" method call.

0 comments voice your opinion now!
tuple data structure splfixedarray example tutorial

Link: http://eddmann.com/posts/tuples-in-php/

SitePoint PHP Blog:
Composer Cheatsheet
April 01, 2014 @ 11:22:35

The SitePoint PHP blog has a new post from Matthew Setter today sharing a Composer cheatsheet he recently discovered with an example of the common commands and "composer.json" file structure.

Unless you've been living under a rock, today's PHP isn't your grandmother's PHP; it's an entirely different, much more elegant and mature language with countless improvements and additions. One of the key additions is Composer, the de facto standard for managing PHP project dependencies which, by default, gives you access to hundreds of ready-made libraries, via Packagist.org.

He goes through the parts of the guide, introducing some of the commands and covering the details of the full "composer.json" JSON structure. There's also a video introduction if you'd like the more visual version.

0 comments voice your opinion now!
composer cheatsheet introduction commands json structure

Link: http://www.sitepoint.com/composer-cheatsheet

ClearCode:
Symfony - Project Tamed
March 27, 2014 @ 09:44:29

On the ClearCode blog today there's a new post for the Synfomy2 users out there with some recommendations about taming your project to make it more manageable and maintainable.

When managing projects based on Symfony2, from the technical side, it is a good idea to establish a set of rules for the project. If you haven't established and implemented such rules yet, then they should be created as soon as possible. Why? Well, no matter how many people are working on the project, the code needs to look like it was written by one person. [...] Symfony documentation doesn't specifically focus on this issue, and the bundles that are written by the community have their own set of rules. [...] Learning from mistakes as you go along cannot only be costly, but also time consuming. It is good to have a starting point, something that at least has worked for someone else. This is how the idea to share the guidelines on the Taming Symfony Project came about.

They list out some of the guidelines of the project centered around various aspects of the implementation and the directory structure. They also talk about standards around the use of Doctrine, Twig and Services.

0 comments voice your opinion now!
symfony2 framework project structure recommendations

Link: http://clearcode.cc/2014/03/symfony-project/

Paul Jones:
"Page Script" As A Degenerate Controller
February 04, 2014 @ 12:26:52

In his latest post Paul Jones looks at the more legacy structure of "page controllers" (a site based on several pages rather than an MVC style) that was common before the "MVC revolution" in the PHP community years back.

Almost all of the legacy applications I've had to deal with were page-based. In doing the work to modernize them, there comes a time where the page script has been refactored to look very much like a page controller, with some distinct but not critical differences. As such, I have come to consider the typical PHP page script to be a degenerate form of a page controller. With a little imagination, I think it's easy to see why.

He talks about how, in this older situation, the web server becomes a sort of "simplified front controller+router+dispatcher" and the PHP page acts as a "controller". He suggests that, even though this structure isn't as well separated as an MVC application, it can still be organized to make it easier to maintain.

0 comments voice your opinion now!
page controller mvc legacy structure

Link: http://paul-m-jones.com/archives/5907

Paul Jones:
PSR-4 "Autoloader" Has Passed
December 04, 2013 @ 10:37:51

As Paul Jones mentions in his latest post, one of the latest proposals to the PHP-FIG (Framework Interoperability Group) has officially passed, PSR-4, providing a more strict standard for autoloading than the widely used PSR-0.

Counting from the date of that first formal proposal, it has taken exactly 8 months of discussions, one botched vote, one rescinded vote, an entirely new FIG workflow, and four or five rewrites to get PSR-4 passed. Maybe 8 months doesn't sound so long when you look back on it, but while you're in the middle of it, it's interminable.

Paul talks about some of the differences between it and PSR-0, making for "shallower" and more concise directory structures for packages. He also points to some of the packages from the Aura framework as examples of its implementation.

0 comments voice your opinion now!
psr4 autoloader phpfig proposal vote pass directory structure namespace

Link: http://paul-m-jones.com/archives/4804

Anthony Ferrara:
Beyond Clean Code
November 26, 2013 @ 13:12:41

Anthony Ferrara has posted the latest in his "Beyond" series today with this new post - "Beyond Clean Code". In it he looks at the idea of "clean code" and proposed a different way to think about its creation.

This is the fourth post in my "Beyond" series. The previous three posts focused on re-imagining OOP and questioning some of the core beliefs that we have come to take for granted. This one is going to be slightly different, in that I want to talk about another angle of writing code: the process itself. We always talk about how code should be clean, but how do you write clean code?

He starts with an overview of what it means for code to be "clean" with some of the common criteria including clear code flow, short routines and using libraries for complex tasks. He proposes that a change in perspective is needed away from "pretty code" and more towards code that contributes to the business value of the product. Following through on this pattern of thought, he proposes a more effective method than focusing on just clean code - DIRTI (Develop, Isolate, Refactor, Test and Integrate).

The real beauty of this approach is that it assumes that you don't know your abstractions before you start. This will help you understand the problem (and the solution) as you write it. [...] Initially, when you don't fully understand the solution, you will develop, isolate and refactor over and over until you fully understand the solution that you're building. Once that understanding solidifies, you're going to tend to spend more time in the later parts (Refactor Test and Integrate).
0 comments voice your opinion now!
clean code dirti structure dependencies perspective

Link: http://blog.ircmaxell.com/2013/11/beyond-clean-code.html

PHPMaster.com:
Data Structures for PHP Devs Graphs
August 01, 2013 @ 09:52:34

PHPMaster.com has posted the fourth article in their "Data Structures for PHP Devs" series today, this time with a focus on graphs. He introduces some of the basic concepts behind them and covers two common problems that can be solved by them.

n one of my previous articles I introduced you to the tree data structure. Now I'd like to explore a related structure - the graph. Graphs have a number of real-world applications, such as network optimization, traffic routing, and social network analysis. Google's PageRank, Facebook's Graph Search, and Amazon's and NetFlix's recommendations are some examples of graph-driven applications. In this article I'll explore two common problems in which graphs are used - the Least Number of Hops and Shortest-Path problems.

He explains graphs mathematically, describing them as a set of relationships between nodes and the "lines" that connect them. There's other things involved including directions and weight, but there's not too much detail on those. Instead he gets right into the problems. First is the "Least Number of Hops" and second the "Find the Shortest Path", each with some explanation and sample code of their implementation.

0 comments voice your opinion now!
data structure graph tutorial least hops shortest path

Link: http://phpmaster.com/data-structures-4

PHPMaster.com:
Data Structures for PHP Devs Heaps
July 23, 2013 @ 11:10:17

PHPMaster.com has posted the third part of their "Data Structures for PHP Devs" series today, this time focusing on heaps. Heaps are a method for organizing a parent/child relationship that makes it easier to work with.

In past couple articles I've introduced you to three basic data structures: stack, queue, and tree. In this article I'll introduce you to another abstract data type that is closely related: heap. Heaps are specialized tree-like data structures which satisfy the heap property - the node value (key) of any parent is always ordered with respect to its child node values across the entire tree.

He starts off by explaining what the different types of heaps are - maxheap, minheap and (a special instance) a Priority Queue. He talks about the operations available to heaps and starts off with a binary maxheap implementation using arrays. He also mentions some of the functionality that the SPL already provides for this sort of thing - SplMaxHeap, SplMinHeap and the SplPriorityQueue.

0 comments voice your opinion now!
data structure heap tutorial series spl priority queue

Link: http://phpmaster.com/data-structures-3

PHPMaster.com:
Data Structures for PHP Devs Trees
July 08, 2013 @ 11:20:29

PHPMaster.com has posted their second article in their "data structures" series, this time focusing on trees - a structure for effectively storing related data in an easier to access format.

In a previous article I introduced two basic data structures: stack and queue. The article was well received so I've decided to share data structures in an intermittent on-going series here at PHPMaster. In this entry I'll introduce you to trees, another data structure used in software design and architecture.

He helps you get your head around the concept of trees using the idea of searching data, nothing that a stack or queue aren't exactly the right tools for the job. He talks about the basic concepts behind trees including "leaves" and "root nodes." He includes sample code showing how to make a simple node, insert some child nodes and "walking the tree" to find the information you're looking for.

0 comments voice your opinion now!
data structure tree tutorial introduction

Link: http://phpmaster.com/data-structures-2

PHPMaster.com:
Data Structures for PHP Devs Stacks and Queues
June 18, 2013 @ 11:42:37

On PHPMaster.com today there's a new tutorial - the first part in a series - looking at data structures. In this first post Ignatius Teo looks at the concepts of "stacks" and "queues".

Most of us are familiar with "stacks" and "queues" in normal everyday usage. But, what do supermarket queues and vending machines have to do with data structures? Let's find out. In this article, I will introduce you to two basic abstract data types - the Stack and the Queue - which have their conceptual origins in everyday usage.

He introduces some of the common concepts behind these two ideas and includes some sample code showing how to implement them. He also mentions some of the SPL functionality that's bult into PHP to handle some of this. The SplStack and SplQueue objects take some of the hassle out of it for you.

0 comments voice your opinion now!
data structure stack queue tutorial splqueue splstack

Link: http://phpmaster.com/php-data-structures-1


Community Events





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


version package install library series introduction interview security laravel update community symfony language framework release podcast opinion composer voicesoftheelephpant tool

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