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

INANI El Houssain:
Build your OWN switch statment using Laravel’s custom blade directives
Nov 03, 2016 @ 15:26:01

In this post on his Medium blog INANI El Houssain shows you how to create a custom directive for use with Laravel's Blade templating language. In this example he shows how to make a custom switch statement, something commonly used on the PHP side to select an action based on a value.

One of the good points of Laravel’s framework is that it allows you to make your own components, macros and directives. so today we will make use of Laravel’s Custom Blade directives and make something good.

He starts with a simple "hello world" example to show where the pieces all live, outputting a simple "Hello $name" string. He then moves into the creation of the "@switch" directive having it write out the PHP code required for the switch to start and end. He adds in two more tags to start and end the different cases: @case and @endcase. The post wraps up with an example of all of these tags in use and how to catch when the value under evaluation might be empty.

tagged: laravel blade directive custom output switch tutorial case

Link: https://medium.com/@InaniT0/build-your-own-switch-statment-using-laravels-custom-blade-directives-218244e41a7c#.dtkbzif3j

DZone.com:
CakePHP - Web Test Cases with SimpleTest
Sep 07, 2011 @ 15:08:24

On DZone.com today there's a new post written up by Mike Bernat about making web test cases for CakePHP applications with SimpleTest.

Most of the applications I work on have very straight-forward components and not a lot of complex functions/methods. I would only be testing whether or not they worked at all, rather than if they worked in a wide-array of situations. [...] For example, unit-testing a simple news list and detail page is probably overkill. Sure, you can test your classes by simple instantiating them but that only goes so far. My new method involves using SimpleTest's Scriptable Browser to actually crawl webpages and ensure that the proper data is being displayed.

He includes a few snippets of code to show how to implement SimpleTest's web test functionality - one that just checks a HTTP response values, another that checks for text on the page, one testing for a login on an admin page and a test for add/edit pages to ensure valid loading based on URLs/links.

tagged: simpletest web test case browser tutorial

Link:

Bradley Holt's Blog:
The Case For Rapid Release Cycles
Aug 09, 2011 @ 13:44:33

Bradley Holt has a new post to his blog today talking about something he's a fan of in his development processes - rapid release cycles - and how something like the Zend Framework could benefit from it.

There has been some discussion recently on the Zend Framework mailing list around release cycles. I proposed a release cycle of six months for major versions (someone else suggested eighteen months, which may be more reasonable for a framework). Rapid releases allow one to accelerate the cycle of building, measuring, and learning. Gathering data from actual usage (measuring) provides an opportunity for learning that can be applied to the next release (building).

He points out that the post isn't specifically targeted at the Zend Framework project, merely that it was the inspiration point for the idea. He talks about what rapid release cycles are and what it can give the team that implements it - less worries about backwards compatibility breaks, a potential encouragement for development pacing and the ease for the customers doing upgrades.

A rapid release cycle allows you to apply new learning, knowledge, and perspective as often as possible. Do your best today, and give yourself opportunities to do your best in the future as well.
tagged: case opinion rapid release cycle software development

Link:

Debuggable Blog:
Code Insults Round 1 - Why switch blocks are dumb
Oct 29, 2008 @ 13:48:28

In the first of his "I will insult your code" series, Nate Abele looks at this submitted code and points out that maybe blocks of switch/case statements aren't such a good idea after all.

The entire submission is actually two files, which together comprise a console script for interacting with a web service (the names of the entrants have been withheld to protect the identities of the guilty). Rather than examine the full entry, we're going to take a look at one part which I find comes up fairly often: switch block overkill.

The example he's talking about has a switch statement with eight different cases under it, most of them just setting two properties on the current class. Its used ot map command line parameters to their correct properties. Nate suggests a bit different method - still using switch/case but pulling the properties to be assigned from an array of options rather than hard-coding them into the evaluation.

tagged: switch case block insult refine overkill property

Link:

Debuggable Blog:
Testing Models in CakePHP - Now let's get rid of the unnecessary ModelTest classes!
Jul 31, 2008 @ 12:51:38

On the Debuggable blog today Tim Koschutzki looks at another testing topics for the CakePHP framework - a cleaner way for testing models.

Up until now there was always a need to create a so-called test model that extends your model-under-test in order to overwrite its $useDbConfig setting to be 'test_suite'. By that you ensured that your models run with the test_suite datasource when the tests are run. [...] Nate proposed ClassRegistry::config(), which allows you to tell the ClassRegistry class which datasource it shall use when ClassRegistry::init() is used the next time (and thereby a model is instantiated).

He includes an example of the new functionality - a test case ensuring that three articles are there and are marked as published. The registry makes it easier to automatically create the ArticleTest instance inside the test case rather than having to manually declare and define it.

tagged: test case cakephp framework registry modeltest class

Link:

Debuggable Blog:
How to bend Cake's Model::find() method to your needs
Jun 23, 2008 @ 17:08:32

New on the Debuggable blog, Tim Koschutzki has posted a method to get the fund() method in the CakePHP framework's models to bend to your will.

CakePHP allows you to use your own "find-types" for the Model::find() methodology. Those of your who are familiar with the find() method know that there are currently four types in the core: 'list', 'all', 'first' and 'count'. However, sometimes it is nice to specify your own type.

He shows an example of the end result - a find() call with a custom type that automagically gets translated correctly. His script overrides and enhances the usual find call in an extended object (extended from AppModel) that uses a switch/case statement to define the custom types and their find() search calls.

tagged: cakephp framework find custom type model switch case

Link:

Sebastian Bergmann's Blog:
Support for the Cancel Case Workflow Pattern
Jan 25, 2008 @ 15:45:00

Sebastian Bergmann has a post about a new feature of the Workflow component in the eZ Components libraries - the Cancel Case Pattern.

Version 1.2 of the Workflow component that is part of the eZ Components adds support for the Cancel Case workflow pattern:

Once this Workflow pattern is called the complete Workflow instance is removed from the current execution (including any running nodes). You can find out more about the ezWorkflowNode in their documentation.

tagged: cancel case workflow pattern ezcomponents

Link:

Mike Lively's Blog:
Adding Database Tests to Existing PHPUnit Test Cases
Sep 05, 2007 @ 15:50:30

Mike Lively has posted about functionality he's created to add database testing procedures to preexisting PHPUnit tests supplementing his other post n adding database support to PHPUnit.

When I was first creating the Database Extension for PHPUnit I realized that there was a very high likelihood that several people would have tests that were already written that they would like to add additional database tests too. To accomplish this I actually wrote the PHPUnit_Extensions_Database_DefaultTester class. In fact, if you were to look at the source of the database test case you will see that all of it's operations are actually forwarded to this class which does all of the work.

He includes his same example from before - the banking system - and shows how the tests can be appended on, adding a getDatabaseTester method that returns an object the rest of the tests can use.

tagged: database test phpunit unittest existing case database test phpunit unittest existing case

Link:

Mike Lively's Blog:
Adding Database Tests to Existing PHPUnit Test Cases
Sep 05, 2007 @ 15:50:30

Mike Lively has posted about functionality he's created to add database testing procedures to preexisting PHPUnit tests supplementing his other post n adding database support to PHPUnit.

When I was first creating the Database Extension for PHPUnit I realized that there was a very high likelihood that several people would have tests that were already written that they would like to add additional database tests too. To accomplish this I actually wrote the PHPUnit_Extensions_Database_DefaultTester class. In fact, if you were to look at the source of the database test case you will see that all of it's operations are actually forwarded to this class which does all of the work.

He includes his same example from before - the banking system - and shows how the tests can be appended on, adding a getDatabaseTester method that returns an object the rest of the tests can use.

tagged: database test phpunit unittest existing case database test phpunit unittest existing case

Link:

Ben Ramsey's Blog:
Business Case for PHP
Feb 14, 2007 @ 17:16:00

With all of the recent talk about business cases for PHP, Ben Ramsey wanted to get some of his thoughts on the matter out and into his blog in a new post.

I don't believe anyone has ever published any white papers on PHP, giving it a business case, and while we have companies like Zend, OmniTI, and eZ Systems providing support for PHP, I haven't seen any documentation from them like this. So, last Thursday when Google Group for developing a business case for PHP, I took notice and joined.

Definitely good to hear encouraging words about a project that could ultimately help out the language as a whole break into an area where the growth has been the slowest.

tagged: business case whitepaper googlegroup develop business case whitepaper googlegroup develop

Link:


Trending Topics: