PHP Community

Justin Carmony: Tech Interviews & Softball Questions

PHPDeveloper.org - Fri, 10/01/2014 - 17:31

Along similar lines as this recent post to the SitePoint PHP blog, Justin Carmony has a new post talking about types of interview questions and the "softball" ones that are commonly used.

While it seems every few months the topic of the interview process goes around the community, and I think the general consensus is most of the time it is ineffective. At DDM, there has been a lot of thought put into our interview process, and so over the next few weeks I hope to share some ideas we've had.

He starts with the "status-quo" of an interview that's set up to ask questions of the candidate, either by a single interviewer or a group, that focuses more on strengths and weaknesses than technical aspects. These usually include the "softball" questions that just about any PHP developer could answer. He then moves on to the more difficult follow up questions relating to specific technologies and features of the language. He also offers some advice on the questions for an interview including writing them down first and ensuring that they're short and to the point.

Link: http://www.justincarmony.com/blog/2014/01/08/tech-interviews-softball-questions

The case against the ifsetor function

Planet-PHP - Fri, 10/01/2014 - 10:00

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:

    $age = (isset($data['people'][0]['age'])) ? $data['people'][0]['age'] : null;

The suggested alternative is a get_in function, which is used as follows:

    $age = get_in($data, ['people', 0, 'age'], $someDefault);

Someone on /r/PHP pointed out that there is an alternative approach to this problem, namely the use of an ifsetor function:

    function ifsetor(&$value, $default = null) {
        return isset($value) ? $value : $default;
    }

The use of this function is very elegant:

    $age = ifsetor($data['people'][0]['age'], $someDefault);

Note that this function will not throw a notice if $data['people'][0]['age'] (or any index in between) does not exist, because the $value is passed by-reference.

By-reference argument passing

This seems to come as a surprise to most people, because the code definitely looks like it accesses an undefined index and ought to throw a notice. Here the magic of references comes in: If you perform a by-reference argument pass (or assign) PHP will be using a different fetch type for retrieving the array offsets. In this particular case it would issue a number of “dim w” (dimension write) fetches.

A write-fetch obviously doesn’t throw a notice if the assigned index doesn’t exist yet (otherwise you wouldn’t be able to create indexes without throwing notices). What’s interesting is that the whole thing also work recursively, so none of the indices in the chain have to exist:

    $array[0][1][2] = 'foobar';

The above example will not throw a notice if $array[0][1] doesn’t exist, it won’t throw a notice if $array[0] doesn’t exist and it even won’t throw a notice if the $array variable itself doesn’t exist.

PHP implements write-fetches by creating the respective offset and initializing it to null (if it doesn’t yet exist). This is compatible with nested ind

Truncated by Planet PHP, read more at the original (another 20859 bytes)

Categories: Open Source, PHP Community

PHP 5.4.24 Released!

Planet-PHP - Fri, 10/01/2014 - 02:00
The PHP development team announces the immediate availability of PHP 5.4.24. About 14 bugs were fixed. All PHP 5.4 users are encouraged to upgrade to this version. For source downloads of PHP 5.4.24 please visit our downloads page, Windows binaries can be found on windows.php.net/download/. The list of changes is recorded in the ChangeLog.
Categories: Open Source, PHP Community

PHP 5.5.8 has been released

Planet-PHP - Fri, 10/01/2014 - 02:00
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. For source downloads of PHP 5.5.8 please visit our downloads page, Windows binaries are located on windows.php.net/download/. The list of changes can be found in the ChangeLog.
Categories: Open Source, PHP Community

SitePoint PHP Blog: PHP Job Interview Task: Day of Week Calculation

PHPDeveloper.org - Thu, 09/01/2014 - 20:14

Sometimes during an interview it's difficult to determine the skill set of the person on the other side of the table. One solution to this that's become popular is asking the developer to perform a task of your choosing and watching how they work out the problem. In this new post to the SitePoint PHP blog Bruno Skvorc shares one suggestion for this kind of test - a day of week calculation.

Not so long ago, I was given a job interview task. I was to write a function which deduces the day of the standard 7-day week of ANY calendar (even an imaginary one), provided I know how often leap years happen, if at all, how many months their year has, and how many days each month has. This is a fairly common introductory job-interview task, and in this article I'll be solving and explaining the math behind it.

His task was, given any kind of calendar definition (not necessarily the Gregorian), figure out what day of the week a certain month/day/year combination would fall on. He walks through the entire code to solve the problem, including a bit to output the resulting calendar to an HTML table for each month.

Link: http://www.sitepoint.com/php-job-interview-task-day-week-calculation

Dutch Web Alliance: The definitive remote debug and unittest with PHPStorm guide: part 6

PHPDeveloper.org - Thu, 09/01/2014 - 19:20

The Dutch Web Alliance has posted the sixth part of their series helping you debug/unit test your applications with PHPStorm and Xdebug. In this new post they focus on working with command-line applications.

So there is already a lot covered: debugging web applications, testing your units, getting code coverage. But one thing that remains is trying to debug your command line applications. Even today more and more applications aren't built for primarily the web, but for other purposes or many web frameworks have some kind of "console" component which allows you to easily create command line tools that deals with asynchronous handling of data, or just mere as cronjobs.

They walk you through the steps you'll need to be sure everything it set up correctly for PHPStorm to catch the debug calls:

  • Ensuring Xdebug is active
  • Validating that PHPStorm is listening for incoming requests
  • Configuring Xdebug on where to connect
  • Setting up the mapping for paths inside PHPStorm
Link: http://dutchweballiance.nl/techblog/the-definitive-remote-debug-and-unittest-with-phpstorm-guide-part-6/

Aura.Web 2.0.0-beta1 Released

Planet-PHP - Thu, 09/01/2014 - 18:21

Our “one release a day” series continues with the 2.0.0-beta1 release of Aura.Web. You can download it directly or install via Composer and Packagist.

Whereas the v1 package included controllers, renderers, and other functionality, the v2 package provides only Request and Response objects… You can read more about the distillation of these concerns into separate packages here.

As a side note, you can see from the timing of these recent releases that Aura libraries are completely independent from each other. There’s no subtree-split or extract-and-build-for-release processing; each library is completely contained in its own repository, making individual releases through our admin script a trivial matter.

via Aura.Web 2.0.0-beta1 Released.

Categories: Open Source, PHP Community

Phil Sturgeon: Autoloading Laravel application code with PSR-4

PHPDeveloper.org - Thu, 09/01/2014 - 18:13

On his site today Phil Sturgeon has a new post showing how to use autoloading with Laravel based on the recently approved PSR-4 standard.

The video shows you how to move over from the current autoloading methods, PSR-0, for your own packages, not Laravel's. He walks you through the creation of the typical PSR-0 package structure and classes then shows it in use in a simple controller.

The font's a bit small on the screencast, but it gets the idea across. Migrating over to the new autoloading is relatively easy, it just takes a little tweaking on the current structure.

Link: http://philsturgeon.co.uk/blog/2014/01/autoloading-laravel-application-code-with-psr4

Brandon Savage: You don't need a framework

PHPDeveloper.org - Thu, 09/01/2014 - 17:56

In the most recent post to his site Brandon Savage suggests that choosing and using a framework for you application isn't even needed.

Looking through the list of PHP frameworks can be daunting. Zend Framework. Laravel. Cake. Symfony. Picking one and learning it can seem like the most important design decision you'll make. And yet, picking a framework is actually one of the least important decisions you face. In fact, you don't need a framework at all.

He starts with a brief history of (PHP) frameworks and talks about their evolution from a set of common libraries out to the full stack versions we have today. He moves on to the "PSR and Composer era" where the lines started to blur a bit. With the renewed emphasis on packages in an easy to install method, frameworks started to become less important.

Now, instead of having a bunch of siloed frameworks that can't work together, there are (supposedly) standards for how they can integrate. An added bonus is that library creators can follow the same standards, making their libraries compatible with all the frameworks that implement the PSR standards.

You can read a rebuttal to this post from Anna Filina on her site.

Link: http://www.brandonsavage.net/you-dont-need-a-framework

Frameworks Are Good, Components Are Awesome!

Planet-PHP - Thu, 09/01/2014 - 17:25

One of the recent problem we can notice is every php framework tries to advertise they are developed from components.

The require-dev dependency is when you want to bind other components. The best way is to get rid of the require-dev. The glue package should be another independent package.

learn PHP, and not the magic of a framework. Depending upon the dependencies it will be easy to replace the component. That is the ultimate aim of components, not to trap you.

Emphasis mine. Also this idea from Hari KT: Packagist needs a way to sort dependent packages, independent packages, and framework packages. Via Frameworks Are Good, Components Are Awesome! – Random thoughts | Hari KT.

Categories: Open Source, PHP Community

Community News: Packagist Latest Releases for 01.09.2014

PHPDeveloper.org - Thu, 09/01/2014 - 16:02
Recent releases from the Packagist:

Frameworks for everyone

Planet-PHP - Wed, 08/01/2014 - 21:17

I recently read an article about the ecosystem of PHP frameworks.

First, I don’t understand why the author puts Aura and Symfony in different categories. Symfony can be used standalone components or as a full-stack framework. Additional components are very easy to install through Composer. The way to describe the frameworks in that article is inaccurate, which makes me wonder whether the author actually tried any of them.

Second, I don’t like the suggestion that all frameworks are essentially the same. I have built mission-critical projects on top of a great many frameworks.  They are not the same. Otherwise, Aura would not have been relevant, given the other frameworks that are already out. Each framework, no matter how decoupled, has its own philosophy that may or may not work for you. Not to mention that each framework has a separate developer community, and its own set of bugs and limitations. You still need to shop around, read reviews, ask for opinions, etc.

Third, frameworks should not be viewed as some big scary monster, only reserved for those who have 15+ years of experience. I have coached many beginner developers on various frameworks with great success. A new framework is possibly the best learning experience for a developer.

By all means, go ahead and try a new framework.

Categories: Open Source, PHP Community

You don’t need a framework

Planet-PHP - Wed, 08/01/2014 - 19:56
Looking through the list of PHP frameworks can be daunting. Zend Framework. Laravel. Cake. Symfony. Picking one and learning it can seem like the most important design decision you’ll make. And yet, picking a framework is actually one of the least important decisions you face. In fact, you don’t need a framework at all. A […]
Categories: Open Source, PHP Community

Jeremy Kendall: PHP Password Hashing: A Dead Simple Implementation

PHPDeveloper.org - Wed, 08/01/2014 - 19:48

In this recent post to his site Jeremy Kendall shares some of his thoughts about password hashing and a new library he's written to help make it simpler - event with an existing password hashing method in place.

We all know to encrypt passwords for highest level of security. Unfortunately, too many do it [the wrong way]. While there was never any excuse for getting it that wrong, there's now no excuse for getting it wrong at all. Developers, meet the new(-ish) PHP password hashing functions (and the userland implementation password-compat).

He shows how to use this password hashing correctly with the "default" hash and how to store that in the database. His Password Validator library aims to help make this even simpler and adds in other features like rehashing and upgrading of legacy passwords. The remainder of the post shows how to use the library for these functions and how to persist them in the tool's storage decorator and interface functionality.

Link: http://jeremykendall.net/2014/01/04/php-password-hashing-a-dead-simple-implementation/

Aura.Router 2.0.0-beta1 Released

Planet-PHP - Wed, 08/01/2014 - 19:03

Continuing our string of library package releases, today we have the 2.0.0-beta1 release of Aura.Router. Given a URL path and a copy of $_SERVER, it will extract path-info and $_SERVER values for a specific route. You can download it directly or install via Composer and Packagist.

The Aura.Router package does not provide a dispatching mechanism. Your application is expected to take the information provided by the matching route and dispatch to a controller on its own. You might do this with Aura.Dispatcher or with some other system of your own devising.

In addition to all the standard stuff like adding routes and generating links, Aura.Router has some added conveniences …

Via Aura.Router 2.0.0-beta1 Released.

Categories: Open Source, PHP Community

SitePoint PHP Blog: Message Queues: Comparing Beanstalkd, IronMQ and Amazon SQS

PHPDeveloper.org - Wed, 08/01/2014 - 18:37

The SitePoint PHP blog has a new post looking at using message queues in PHP. More specifically it compares a few of the different solutions out there and their advantages/disadvantages - Beanstalkd, IronMQ and the Amazon SQS.

This article introduces the concept of message queues and discusses the strengths and weaknesses of three specific message queue services: Beanstalkd, IronMQ and Amazon SQS. [...] Queues allow you to store metadata for processing jobs at a later date. They can aid in the development of SOA (service-oriented architecture) by providing the flexibility to defer tasks to separate processes. When applied correctly, queues can dramatically increase the user experience of a web site by reducing load times.

He starts with some of the overall benefits and downfalls of using a queueing system in your application, including some common use cases. From their he breaks it up into sections, in each talking about the option and how it differs from the others:

  • Services
  • Server setup
  • Service Level Agreements (SLAs)
  • Architecture
  • Client libraries
  • Management interface
  • Redundancy
  • Security
  • Speed
  • Fidelity
  • One-time pickup

...and many, many more. If you're looking for a good, complete overview of how these three options compare on a wide range of features and configurations, definitely check out this post. It even includes some PHP close to the end to make the connections to each and send/receive messages.

Link: http://www.sitepoint.com/message-queues-comparing-beanstalkd-ironmq-amazon-sqs/

Lorna Mitchell: Zend Certified PHP Developer 5.5

PHPDeveloper.org - Wed, 08/01/2014 - 17:23

If you're thinking about taking the Zend Certified PHP Developer (5.5) test but aren't sure exactly where to start, Lorna Mitchell has provided a list of some good resources to help you out.

Yesterday I updated my previous ZCE certificate to the Zend Certified PHP Developer qualification (the new ZCE for PHP 5.5 also got a new name). Since the ZCE 5.3 exam is no longer available and I work with various clients to prepare their teams for these certifications, it was important to me that I keep my own certification up to date. Now I've done that, I'd like to share some resources for others doing the same thing.

She points to a few things that could help you make the grade:

Link: http://www.lornajane.net/posts/2014/zend-certified-php-developer-5-5

Community News: Packagist Latest Releases for 01.08.2014

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