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

Codeception Blog:
Writing Better Tests: Expectation vs Implementation
Dec 27, 2016 @ 16:49:42

The Codeception blog has recent post they've written up talking about writing better tests for your application and the difference between expectation and implementation as it relates back to meaningful tests.

What makes a meaningful test? This question should always be asked. No matter we write your tests first or tests after, they may stay in a project for years and it is pretty important them to test the things that really matters. Badly written tests can slow us down by constantly failing on each implementation change, and such tests can be written no matter you follow TDD or not. The idea of a test is to ensure that software works and not to freeze it at specific point.

Such situation happens when a test is bound to implementation details. [...] But how to understand what is stable and what is not? We need to use interfaces. Not that one which is written as interface keyword in PHP but a general term: User Interface, API. And that’s what makes unit testing and browser testing similar: we always need to rely on public interfaces for a test.

They give an example of a test that's "bound to implementation details" from the Magento codebase that relies on a specific function implementation (the "makdir" method). This function is a part of the Symfony functionality, not Magento, and what might happen if things change in your application. They note that the main difference is testing for the result versus testing for the behavior of the functionality. The tutorial wraps up by suggesting that the only testing that should be done is on public, well-defined interfaces that are not as subject to change and not copying logic into tests.

tagged: codeception testing tutorial expectation versus implementation interface public

Link: http://codeception.com/12-21-2016/writing-better-tests-expectation-vs-implementation.html

Reddit.com:
Zend2 vs Symfony2
May 03, 2013 @ 17:57:56

On Reddit.com there's a discussion happening comparing two popular and prominent PHP frameworks - Zend Framework 2 and Symfony 2.

For those that have used both frameworks, what one do you feel is a better overall framework? I tried ZF2 in beta and it seemed overly complicated to symfony but I don't know if its gotten better since then.

Opinions shared in the comments of the post include things like:

  • "So if you are learning for job prospects, go Zend. I love Symfony 2 though, its a joy to work with."
  • "It doesn't matter. Each has a strength and a weakness, and neither will go away. Pick one and use it, you'll be fine."
  • "I don't think there is such thing as a best framework as you should use the best tool for the job. I don't think MVC is the solution to all problems."
  • "Both are quite bloated but they have to be considering their target markets."

On the whole, the views are of the "best tool for the job" mentality - a good sign for the community and these two frameworks.

tagged: zendframework2 symfony2 versus opinion community

Link: http://www.reddit.com/r/PHP/comments/1dcqst/zend2_vs_symfony2

NetTuts.com:
Language War: PHP vs. Ruby
Mar 04, 2011 @ 17:39:13

It seems like one of these sort of (opinion) articles pops up every once and a while, and they always cause their share of controversy. This new post on NetTuts.com comparing PHP and Ruby is no different (over 70 comments and counting).

It’s time; queue the "Going the Distance" theme from Rocky. In the red ring: Envato developer extraordinaire, Ryan Allen, who built the original FlashDen with his cold bare hands. In the blue corner: Michael Wales, a well known member in the PHP and CodeIgniter communities. The battle? PHP vs. Ruby. Fight!

The two contenders in this "fight" were asked the same questions and answers from both sides are shared to help balance things out. The questions were things like:

  • Do you feel that your language is more suited to beginners or advanced users?
  • Many PHP developers move on to Ruby after a few years. Have you found this to be the case, and, if so, why do you think it’s so common?
  • Are there instances when you might choose to use Ruby for one project, and PHP for another?
  • What specifically does your language have that the other does not -- if anything?
  • How does Ruby or PHP’s community compare to the other?

Be sure to check out the comments - there's lots of good thoughts from the communities on both sides there too.

tagged: versus war ryanallen michaelwales language interview

Link:

Juozas Kaziukenas' Blog:
Ruby on Rails vs PHP (Video)
Feb 25, 2009 @ 15:33:24

Juozas Kaziukenas has reposted a video created by the RailsEmnvy.com folks (one of several, check out YouTube for more) that does a "Mac vs PC" Apple parody commercial of Ruby and PHP.

Gregg Pollack and Jason Seifer from RailsEnvy.com do some Ruby on Rails commercials in the same style of the Mac vs PC ads. Videos produced by Jason Hawkins of MakeFilmWork.com.

Other videos include Ruby on Rails vs .NET, Ruby on Rails vs Django and, of course, Ruby on Rails vs ColdFusion.

tagged: rubyonrails railsenvy video mac versus pc apple parody dotnet django coldfusion

Link:

Mike Naberezny's Blog:
__get() - an alternative to __autoload()
Jan 09, 2008 @ 12:47:54

Mike Naberezny has posted this new item on his blog today with a look at why __get() is a perfectly good alternative to __autoload() in a class structure.

__autoload() is a magic function introduced in PHP 5 that provides a mechanism for on-demand loading of classes. After its inclusion in PHP, many argued that using such a feature is too magical or not a good design practice. Putting the religious debates over the appropriateness of __autoload() aside, its implementation does have one significant drawback: it is a function declared in the global scope. Once a function is declared, it cannot be redeclared. This means __autoload() can't be used effectively in shared libraries, since any other code could have already declared it.

Similar lazy-load functionality can be achieved on the class level by using __get().

He gives a short code example where the __get() call mimics the functionality of __autoload(), but the resulting object created is public, not global...

tagged: __get __autoload alternative global versus public __get __autoload alternative global versus public

Link:

Mike Naberezny's Blog:
__get() - an alternative to __autoload()
Jan 09, 2008 @ 12:47:54

Mike Naberezny has posted this new item on his blog today with a look at why __get() is a perfectly good alternative to __autoload() in a class structure.

__autoload() is a magic function introduced in PHP 5 that provides a mechanism for on-demand loading of classes. After its inclusion in PHP, many argued that using such a feature is too magical or not a good design practice. Putting the religious debates over the appropriateness of __autoload() aside, its implementation does have one significant drawback: it is a function declared in the global scope. Once a function is declared, it cannot be redeclared. This means __autoload() can't be used effectively in shared libraries, since any other code could have already declared it.

Similar lazy-load functionality can be achieved on the class level by using __get().

He gives a short code example where the __get() call mimics the functionality of __autoload(), but the resulting object created is public, not global...

tagged: __get __autoload alternative global versus public __get __autoload alternative global versus public

Link:

Jonathan Snook's Blog:
CodeIgniter vs. CakePHP
Mar 20, 2007 @ 14:24:00

In a new post today, Jonathan Snook takes a look at two of the more popular PHP frameworks (CodeIgniter and CakePHP), comparing and contrasting what it's like to work with each.

I almost fear putting this kind of post together as it's bound to pull the fanatics (in the negative sense of the word) out of the woodworks. Right off the bat, let me just say that I've tried to be as fair and honest in this assessment and I've tried to keep it just to the facts while interjecting what my preferences are.

I'm pitting these two frameworks against each other but there really isn't a clear winner. Each has its strengths and weaknesses and ultimately falls to what your preference for certain features might be.

He starts with the "why?" of it all before even getting into the code examples. When he does, it's all about models, views, the out-of-the-box features, auto-loading, and documentation. As he mentioned before he started, though, there's not a "winner" in this comparison. His personal choice, though, is CakePHP for simplicity's sake.

tagged: versus codeigniter cakephp framework compare simplicity autoload versus codeigniter cakephp framework compare simplicity autoload

Link:

Jonathan Snook's Blog:
CodeIgniter vs. CakePHP
Mar 20, 2007 @ 14:24:00

In a new post today, Jonathan Snook takes a look at two of the more popular PHP frameworks (CodeIgniter and CakePHP), comparing and contrasting what it's like to work with each.

I almost fear putting this kind of post together as it's bound to pull the fanatics (in the negative sense of the word) out of the woodworks. Right off the bat, let me just say that I've tried to be as fair and honest in this assessment and I've tried to keep it just to the facts while interjecting what my preferences are.

I'm pitting these two frameworks against each other but there really isn't a clear winner. Each has its strengths and weaknesses and ultimately falls to what your preference for certain features might be.

He starts with the "why?" of it all before even getting into the code examples. When he does, it's all about models, views, the out-of-the-box features, auto-loading, and documentation. As he mentioned before he started, though, there's not a "winner" in this comparison. His personal choice, though, is CakePHP for simplicity's sake.

tagged: versus codeigniter cakephp framework compare simplicity autoload versus codeigniter cakephp framework compare simplicity autoload

Link:

Alexander Netkachev's Blog:
Controller/Action versus Folder/Page
Feb 06, 2007 @ 13:36:00

On his blog today, Alexander Netkachev illustrates a concept behind the "different thought" frameworks like the Zend Framework spin on the idea of web applications.

Web site developers are familiar with a concept that a site consists of pages but Zend Framework proposes Controller/Action idea. Undoubtedly, Controller/Action is cool but how is it relevant to real world tasks? In other words, how is Controller/Action connected to the standard form flow?

His diagram shows the typical flow of an application and, below it, a sample PHP page that would handle the form results for such a layout. His question is what the Controller/Action method has over this typical format, and whether or not it just serves to make things more complex.

tagged: zendframework controller action page versus method zendframework controller action page versus method

Link:

Alexander Netkachev's Blog:
Controller/Action versus Folder/Page
Feb 06, 2007 @ 13:36:00

On his blog today, Alexander Netkachev illustrates a concept behind the "different thought" frameworks like the Zend Framework spin on the idea of web applications.

Web site developers are familiar with a concept that a site consists of pages but Zend Framework proposes Controller/Action idea. Undoubtedly, Controller/Action is cool but how is it relevant to real world tasks? In other words, how is Controller/Action connected to the standard form flow?

His diagram shows the typical flow of an application and, below it, a sample PHP page that would handle the form results for such a layout. His question is what the Controller/Action method has over this typical format, and whether or not it just serves to make things more complex.

tagged: zendframework controller action page versus method zendframework controller action page versus method

Link:


Trending Topics: