News Feed
Sections




News Archive
feed this:

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

Erika Heidi:
A beginners guide to Vagrant and Puppet, part 3 - facts, conditionals and modules
July 12, 2013 @ 12:14:06

Erika Heidi has posted the third part of her beginners guide to working with Puppet/Vagrant for development environments. In this latest post, she focuses on facts, conditionals and modules.

Finishing this guide to Vagrant and Puppet, I would like to show some advanced puppet resources. As I said before, Puppet is really powerful and extensive - I'm covering just the main concepts so you can have a good start point for creating your vagrant boxes.

She talks about the concepts behind facts first, pointing out that they're similar to variables, except that they're pre-defined. Conditionals let you do some basic logic and modules make it simpler to split up the functional pieces of the Puppet configuration into reusable chunks. She includes some code examples for these and how to set up your directory structure so you can create and use modules.

0 comments voice your opinion now!
vagrant puppet introduction facts conditional module series

Link: http://www.erikaheidi.com/2013/07/10/a-beginners-guide-to-vagrant-and-puppet-part-3-facts-conditionals-modules-and-templates

Mark van der Velden's Blog:
PHPUnit conditional test based on a PHP version
April 20, 2010 @ 09:57:33

In a new post Mark van der Velden has posted a quick (handy) example of how you can write your PHPUnit tests to be PHP version aware and only test what's needed.

I had a problem with running test cases on multiple CI environments, where one of the two runs on PHP 5.2 and the other on PHP 5.3. This basically meant that all our pretty PHP 5.3 code caused the builds to fail on the 5.2 only machine.

His technique is based on skipping tests that aren't meant for the latest version - like a test that'd only work if the server's running PHP 5.3 or greater. The key is in the PHP_VERSION constant that makes it simple to check what you're running. He also points out that you can use the @depends to achieve a similar functionality.

0 comments voice your opinion now!
phpunit conditional version snippet


SmartyCode.com:
Enable your Zend Framework App with Conditional GET! (Make it green)
March 26, 2009 @ 14:25:59

On the SmartyCode.com site there's a quick new post about making your Zend Framework site a bit more "green" with a conditional GET feature.

In this article I'll show you a simple approach to enable your Zend Framework application saving lots of precious bandwidth, and thus, making it more end-users friendly, and save on bandwidth costs. This technique involves HTTP conditional GET. This is basically a feature of the HTTP protocol. By sending correct HTTP headers with your application, you enable browsers of your end users to cache pages of your site.

A plugin for the front controller (with a dispatchLoopShutdown method inside) is used to handle the requests and cache their content correctly. They have the cache set at 7200 seconds (2 hours) for a time to live, but its easy to tweak it based on your application. TO use the plugin call the registerPlugin function on the controller object and add it as the very last thing that runs.

0 comments voice your opinion now!
conditional get cache timetolive zendframework dispatchloopshutdown


DevShed:
Using Conditional Statements with the Xdebug Extension
March 04, 2009 @ 12:08:43

DevShed continues their series looking at the XDebug extension for PHP with this fifth part looking a bit more at the code coverage functions it comes with.

In this fifth part of a series on using the Xdebug extension to help debug your PHP programs, we'll take a closer look at the xdebug_start_code_coverage() and xdebug_get_code_coverage() functions. Specifically, we'll see how we can extend their usage when working with conditional statements. As always, we'll complement theory with a number of hands-on examples.

They start with a review of the previous tutorial (that started the look at code coverage) and continue on to show how to extend a code coverage class to debug some conditionals and return the results in a simple echoed output.

0 comments voice your opinion now!
conditional statement xdebug tutorial coverage


Sameer Borate's Blog:
Refactoring 1 Consolidating Conditional Expressions
January 05, 2009 @ 09:31:08

Sameer has posted the first article in his "Refactoring" series today - a look at boiling down conditional expressions to only the logic that are really needed (and maybe replacing it all together).

Many times you see a group of conditionals where the returned values are the same. To make the code cleaner you can group the conditionals together using the '&&' or the '||' operators and then extract the code into a separate function. This also has the added benefit that you can reuse the extracted method in other places where the required conditional goes.

He shows how abstracting out a file upload permissions check to another function makes it easier to reuse and simpler to understand (an "if" versus multiple "return" statements).

0 comments voice your opinion now!
refactor conditional consolidate series


DevShed:
Inserting, Updating and Deleting Database Rows with Code Igniter
September 24, 2008 @ 12:03:27

DevShed continues their series focusing on the CodeIgniter framework with the seventh part - a look at interacting with the database to update, delete and insert rows from your application.

You've seen some of the things you can accomplish with the Code Igniter PHP framework in earlier parts of this series. In this seventh part of the series, you will learn, through copious examples, how to perform insertions, updates and deletions on a selected MySQL table by using Code Igniter's database class. You'll see that these tasks are very intuitive and easy to grasp, thanks to Code Igniter's friendly learning curve.

They show how to make conditional select statements (with where clauses) and do both inserts of new information and updates to current information, all with the built-in model functionality the framework provides.

0 comments voice your opinion now!
codeigniter framework tutorial update delete insert conditional


DevShed:
Working with the Active Record Class in Code Igniter
September 17, 2008 @ 13:44:59

DevShed has posted the next part of their series focusing on the CodeIgniter framework. This new tutorial looks at the Active Record class that sits at the heart of the framework.

Welcome to the sixth installment of the series entitled "Introducing the Code Igniter PHP Framework." By using a hands-on approach, this series of articles walks you through the main features that come packaged with this friendly yet powerful development software that lets you quickly build robust PHP applications.

They show a simple example of how to pull information out of your database, how to get a little more complex with conditional select statements and how to use a where to narrow down your results.

2 comments voice your opinion now!
codeigniter framework activerecord tutorial series conditional


Symfony Blog:
Call the expert How to implement a conditional validator?
September 05, 2008 @ 12:06:18

On the symfony blog today, there's a new post that looks at creating a conditional validator in the context of a classic login form for the framework.

Jon works on a symfony 1.1 project with a classic login form. The form is composed of two fields: a username and a password. The validation rules are quite straightforward: he wants each field to be required and he wants to check the correctness of the password.

They show how to set up a normal login widget and how to apply a sfValidatorCallback in the configure() method to check the values in the form. This method checks the username and password values and tosses an error with sfValidatorError if a problem is found.

0 comments voice your opinion now!
conditional validator tutorial symfony framework


Padraic Brady's Blog:
Optimise Your Zend_Feed Aggregators With HTTP Conditional GET Support
July 29, 2008 @ 11:13:06

Padraic Brady has written up a post on how he implemented conditional fetching (GET) as a part of the Zend_Feed component of the Zend Framework.

You see, by default, Zend_Feed is stupid. It will blindly drag in whatever RSS you point it at, parse it, present an accessible API (which is largely an abstract API across PHP DOM), and then merrily sit back while you are driven demented. There is a problem in blindly fetching RSS and parsing it - RSS feeds from a huge number of online sources only change rarely. The rest of the time the feed is unchanged.

The key is in the "Last-Modified" header data of the remote file (and ETag). He shows how to use this knowledge in a simple example - pulling data with a ZFBlog_Aggregate class and dumping the contents into a database table. This code checks the return status for a 304 ("Not modified") and closes out the connection if so. Otherwise it grabs the content and updates the database with the most recent fetch times to compare to the "Last-Modified".

0 comments voice your opinion now!
zendframework feed aggregator conditional get lastmodified


Zend Developer Zone:
Three Quick Tips To Make Your PHP Understandable
June 25, 2008 @ 07:57:19

The Zend Developer Zone has posted a new article today with three tips to help you make your code a little easier to understand (both by other coders and yourself down the road).

Producing code that clearly conveys a developer's intent is key to any well written application. That not only applies to PHP, but every programming language. Developers who emphasize the creation of legible code tend to create applications which are easier to both maintain and expand upon.

His tips include suggestions about keeping conditional logic clean, using "less PHP and more HTML" and to make the best possible use that you can out of sprintf "and friends".

0 comments voice your opinion now!
tips understandable conditional logic html sprintf



Community Events





Don't see your event here?
Let us know!


install list library tips symfony podcast opinion laravel interview introduction bugfix release deployment api series language framework package voicesoftheelephpant community

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework