Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Nikola Poša:
On structuring PHP projects
Jan 17, 2017 @ 16:17:18

Nikola Poša has shared some advice form his own experience on structuring PHP projects and some alternatives to some of the typical structures seen across many packages and applications.

An indispensable part of every programming project is how you structure it, which involves organizing files and sources into directories, naming conventions, and similar. As your application grows, so does the need for structuring it in way that it is easy to manage and maintain.

In most cases, structure of an average PHP-based application is dictated or influenced by the framework that is being used, which is something I'm opposed to. With no intention to be intrusive and without any bias towards specific framework, I'll share with you how I think about organizing my PHP projects.

He starts with a common directory structure seen in a wide range of projects in a framework agnostic way. He mentions the PHP-PDS project that tries to promote this same structure but also provides some alternatives:

  • grouping by archetype
  • grouping by feature
  • splitting out domain and general-purpose code

For each he provides an example of the directory structure and explains the rationale behind it a bit.

tagged: project structure applications grouping archetype feature domain

Link: http://blog.nikolaposa.in.rs/2017/01/16/on-structuring-php-projects/

Simon Holywell:
Importing and aliasing PHP functions
Oct 24, 2016 @ 16:34:29

In this recent post to his site Simon Holywell continues his look at namespacing in PHP with a look at importing and aliasing specific functions, not the entire class.

As a follow on to my short post about namespaces and functions from a year ago I thought it would be worth covering importing a specific function and aliasing functions via namespace operators too. This has been possible since PHP 5.6, but there is a nice addition in PHP 7 I’ll cover towards the end.

He starts with a refresher example of pulling in a namespace and using a method with the "use" statement. Following this he shares an update that just imports the one method via a "use function" call rather than the entire class/namespace. He again refactors this into something more usable (the original method name is quite long) with an alias. He then ends the post with the PHP 7 only trick using the braces to define grouped namespace handling (however, this doesn't allow for function level aliasing).

tagged: import alias function namespace grouping php7 tutorial

Link: https://www.simonholywell.com/post/2016/10/importing-and-aliasing-php-functions/

Debuggable Blog:
How to do Group By conditions in Model find() calls in the CakePHP RC1
Jun 12, 2008 @ 13:48:09

On the Debuggable blog, Tim Koschutzki shows how to use grouping in your SQL statements with the find() method calls inside of a Model for an app.

We have to thank Mark Story and wluigi for working on group by conditions for Cake's Model::find() method. Up until now, you would have to add your GROUP BY stuff to string'ed conditions in order to support a group by statement, which could be very ugly.

He has some code included that compares the two methods - the newer of the two applying the 'group' option as a regular condition to the query object.

This functionality is currently only in the the Release Candidate 1 but will be included in the next major release.

tagged: cakephp framework groupby grouping conditional paginate

Link:

Matthew Weir O'Phinney's Blog:
Zend_Form Advanced Features
Apr 08, 2008 @ 17:13:35

Matthew Weir O'Phinney has written up a post for his blog outlining some of the other cool little features that were included in the recent release of the Zend Framework, specifically with the Zend_Form component.

I've been working on for the past few weeks, and it's nearing release readiness. There are a number of features that Cal didn't cover in his DevZone coverage (in part because some of them weren't yet complete) that I'd like to showcase.

These additional features Matthew mentions are:

  • Internationalization
  • Element Grouping
  • Array Support

Check out more of the great features of the component in the Zend Framework documentation.

tagged: zendform advanced feature internationalization grouping array

Link:

Matthew Weir O'Phinney's Blog:
Zend_Form Advanced Features
Feb 11, 2008 @ 19:54:00

In a new post to his blog today, Matthew Weir O'Phinney dives in to some of the more advanced features that the Zend_Form component of the Zend Framework has to offer.

I've been working on for the past few weeks, and it's nearing release readiness. There are a number of features that Cal didn't cover in his DevZone coverage (in part because some of them weren't yet complete) that I'd like to showcase.

These additional features include internationalization, element grouping and array support. He looks at each of these, including some sample code where needed, and shows you how they can be useful to you and your ZF application.

tagged: zendform zendframework advanced feature international grouping array support

Link:

Jim Plush's Blog:
Grouping PHP classes = faster by 24%
Feb 13, 2006 @ 12:55:53

Jim Plush wanted to try a little experiment with perfomance in PHP - specifically dealing with the placement of the class code in an application.

Out of sheer boredom I wanted to see which was better, including one big file of classes or splitting your classes up into multiple files. I'm going to use nusoap as an example. The NuSoap package lets you download one file. nusoap.php. That one file contains 9 classes. While not only is this method nice as you only need to include one class, its also 24% faster on average than having to include 9 seperate files.

In his informal testing he found that combining the files/classes into a single large file made for better performance (as far as object usage) - of course, that also makes it harder to maintain...

tagged: grouping classes one file faster twenty-four percent grouping classes one file faster twenty-four percent

Link:

Jim Plush's Blog:
Grouping PHP classes = faster by 24%
Feb 13, 2006 @ 12:55:53

Jim Plush wanted to try a little experiment with perfomance in PHP - specifically dealing with the placement of the class code in an application.

Out of sheer boredom I wanted to see which was better, including one big file of classes or splitting your classes up into multiple files. I'm going to use nusoap as an example. The NuSoap package lets you download one file. nusoap.php. That one file contains 9 classes. While not only is this method nice as you only need to include one class, its also 24% faster on average than having to include 9 seperate files.

In his informal testing he found that combining the files/classes into a single large file made for better performance (as far as object usage) - of course, that also makes it harder to maintain...

tagged: grouping classes one file faster twenty-four percent grouping classes one file faster twenty-four percent

Link:


Trending Topics: