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

Matthias Noback:
About fixtures
Jul 10, 2018 @ 15:21:05

Matthias Noback has written up an article on his site covering a tool that's common in many web applications, especially for testing: fixture data. In the post he makes some suggestions about effective ways to use them to provide more "real world" results for tests.

System and integration tests need database fixtures. These fixtures should be representative and diverse enough to "fake" normal usage of the application, so that the tests using them will catch any issues that might occur once you deploy the application to the production environment. There are many different options for dealing with fixtures; let's explore some of them.

He makes four suggestions of ways to handle fixtures:

  1. Generate them the "natural" way via interaction with the application and taking a snapshot of the data.
  2. Generate them at runtime for the tests, reloading them each time
  3. Manual insertion of custom data into the database for all tests
  4. Manual insertion of custom data into the database for each test case

He finishes the post by asking a question for those considering using fixture data: do you need them at all? Testing should be isolated from external sources so maybe they're not really needed...

tagged: fixtures list suggestions natural generate custom data database

Link: https://matthiasnoback.nl/2018/07/about-fixtures/

Derick Rethans:
Natural Language Sorting with MongoDB 3.4
Dec 16, 2016 @ 15:28:33

Derick Rethans (of MongoDB) has posted an update to his site sharing the details about an improvement that comes with MongoDB 3.4 and is supported by the PHP driver: natural language sorting.

Arranging English words in order is simple—most of the time. You simply arrange them in alphabetical order. Sorting a set of German words, or French words with all of their accents, or Chinese with their different characters is a lot harder than it looks.

[...] Years ago I wrote about collation and MongoDB. There is an old issue in MongoDB's JIRA tracker, SERVER-1920, to implement collation so that sorting and indexing could work depending on the different sorting orders as described for each language (locale). Support for these collations have finally landed in MongoDB 3.4 and in this article we are going to have a look at how they work.

He starts off by explaining a bit about how Unicode collation works and PHP's support through the intl extension in the Collator class. He provides a code example using the class, showing the difference in sorting them first as English words then as Norwegian words. He moves into the MongoDB world and shows how the queries using this new collation support would be structured before moving back to PHP and using the MongoDB client to make the same requests. He also includes examples showing how to set the default locale, the "strength" (for the level of comparison), sorting and some interesting quirks with certain locales.

tagged: mongodb derickrethans natural language sorting tutorial driver

Link: https://derickrethans.nl/mongodb-collation-revised.html

Zend PHP Certification Blog:
PHP Sorting Functions
Dec 21, 2011 @ 17:39:06

On the "Zend PHP Certification" blog (study notes), there's sort and natsort).

In all the countless hours I’ve spent with php, I’ve maybe used three or four of these sorting functions. I really had no idea that there is a total of eleven functions used for sorting arrays. Anyway, I’m betting that it may be useful to have these memorized before I take the Zend PHP Certification Exam so here is a brief overview of each one.

He talks about the various flags that can be used in the sorting (for regular, numeric, string and locale-based string handling) and the parameters to call for normal sorting, "natural" sorting, reverse key sorting and others. You can find specifics on these array sorting methods in the PHP manual.

tagged: sorting function array natural reverse key user

Link:

Elizabeth Naramore's Blog:
Growing Online Communities Naturally
Apr 20, 2009 @ 15:24:07

In this recent post to her blog Elizabeth Naramore looks at something some development (and really any type) of community struggles with - growing their number of active, engaged members.

From my experience, one key to a successful online community is the sort of magic that happens between community members that keeps it vibrant and growing. You can't force that kind of magic, and you can't clone it. It just happens.

She points out just a few of the resources you and your groups can use to help get others involved including wikis, mailing lists, IRC channels (I hear Freenode is nice) and twitter. She also gives specific examples of PHP-related community resources she's involved in like the PHPBuilder.com forums, her local PHP user group and the PHPWomen group.

What makes a community tick? [...] I'm no psychologist, but I can offer up a few words of advice for those struggling to grow their community or find that magic. Lay all your cards out on the table and see which ones gather momentum. [...] Let the group grow naturally and remember the complexity of the group dynamics is what dictates how the group will gel, not the leader.
tagged: member communicate usergroup grow natural community online

Link:


Trending Topics: