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

Marc Morera:
Behat and Data-test
Apr 27, 2015 @ 14:55:08

In a new post Marc Morera makes a suggestion for a testing practice to add to the use of the popular BDD PHP testing framework Behat - a "data-test" option to help with decoupling the tests from implementation.

Tests should be as robust as possible. I think you will agree with me with that phrase. If your tests are too coupled with your implementation, a simple modification of your code will need the modification of your tests, and that’s so annoying, right? [...] My question is… should the frontend of your website be aware of the how your Behat tests are built? In my opinion, nope. Your tests should live in a simple layout on top of your application, emulating some cases and ensuring that your users will be able to do what they should be able to.

He points out the main problem with the current testing methods, mainly that the real issue is in the hard-wiring of the test functionality to the name/id/type of the interface elements. He also brings up the aspect of translations and ensuring that your tests take into account that the text may not always be in English. He also mentions Symfony forms and how they define their own structure and naming, not necessarily what you manually generate. He instead proposes a "data-test" property that could be added to elements both indicating that they're used by the testing process and can help in locating the elements during the testing process.

tagged: behat bdd datatest property markup testing method opinion

Link: http://mmoreram.com/blog/2015/04/25/behat-and-data-test/

SitePoint PHP Blog:
Introduction to JadePHP
Apr 10, 2014 @ 15:30:30

Lukas White has posted an introduction to JadePHP to the SitePoint PHP blog today. JadePHP is a port of the popular Jade templating language more often used in Javascript.

There are dozens of templating engines out there, with options such as Smarty, Twig (used in the upcoming version of Drupal) and Blade (the default for Laravel) among the best known – as well as vanilla PHP, of course. [...] One which differs quite significantly from most is Jade, an engine usually associated with Javascript applications – it’s supported out-of-the-box by Express for Node.js, for example. It’s Jade I’m going to look at in this article; or more specifically the PHP port JadePHP.

He starts by briefly talking about HAML, a markup language that aims to make it easier and cleaner to write well-formatted HTML documents. Jade creates the entire document this way, meaning you could use it even without any templating needs (just outputting normal HTML pages). He shows you how to get started with the code and provides a simple example of a basic HTML page without any template objects to replace.He explains the markup and what each part does before moving on and showing how to add in the dynamic content and logic. He finishes off the tutorial by answering the question "Why use Jade?" touching on some of the good and bad of the templating engine.

tagged: jadephp templating haml markup library tutorial

Link: http://www.sitepoint.com/introduction-jadephp

NetTuts.com:
How to Create a PyroCMS Theme
May 21, 2013 @ 16:19:25

On NetTuts.com today there's a new tutorial posted showing you how to create a theme for PyroCMS, an open source, PHP-based content management system with a large user base and community.

Like most content management systems, PyroCMS uses front-end themes. Though PyroCMS themes are built a bit differently than what you might be used to from other systems, they’re still quite easy to create. They’re so easy, in fact, that very little PHP experience is required to assemble them!

He walks through things like the folder structure of the templates directory and how to get started on a custom "Foo" theme of your own. He covers how to lay out the HTML markup for the theme and how you can use partials for the sections of the site. He briefly touches on using multiple layout files and how to use different layouts shown only to mobile devices.

tagged: pyrocms theme tutorial introduction mobile markup patrials

Link: http://net.tutsplus.com/tutorials/php/how-to-create-a-pyrocms-theme

CodeIgniter.com:
New User Guide in Development
Oct 06, 2011 @ 14:55:48

The CodeIgniter development team is happy to announce work that's been done on the framework's user guide to help make it even better and easier to find the information you're looking for (now based on the Sphinx documentation generation engine).

In addition to handling the tedium of generating page and document tables of contents, or maintaining internal links and references, the documentation is now easier to write, as you can simply focus on the content instead of markup and presentation. Don’t forget syntax highlighting of PHP, HTML, CSS, and JavaScript in code samples. Based on ReStructured Text, it’s also more human readable in a text editor than HTML is, which is likely where you spend most of your time. As an added benefit, Sphinx can output HTML, PDF, and even EPUB formats all from the same source files.

There's also been a style redesign in the latest release (here on github) on the development branch of the framework. They warn of a few "bumps" that you might come across in using it, but they're working hard to take care of those quickly. If you'd like to see the new version, check out the nightly build results.

tagged: usergruide development sphinx markup generation framework codeigniter

Link:

Jason Gilmore's Blog:
How I Learned to Stop Worrying and Love Zend_Form
Aug 22, 2011 @ 18:57:14

On his blog today Jason Gilmore has a quick post about solving one of his frustrations with Zend_Form (a part of the Zend Framework) - the default form decorators.

It is a fantastically productive framework, one which I happen to use almost every single day. There was however one feature which absolutely drove me crazy. The Zend_Form component's uses the dd, dl, and dt elements as the default form markup decorators, meaning that even a simple contact form consisting of name, email, and message fields and a submit button [is marked up with dl, dt and dds]. [...] It goes without saying that the overwhelming majority of developers do not use these elements to mark up their forms, with the sheer number of questions posted to StackOverflow and elsewhere about getting rid of these decorators backing this assertion.

He gives his simple solution to the issue, something better than removing all of the decorators and using setDecorator to replace them - a simple partial view that echos out the fields directly. The trick is to use the setDecorators call with a "ViewScript" option pointing to your partial and setElementDecorators() call to use a "ViewHelper".

tagged: zendform tutorial markup decorator form

Link:

Benjamin Schneider's Blog:
Use PHP's Tidy extension to validate your (X)HTML markup
Oct 07, 2010 @ 15:59:30

In a new post to his blog Benjamin Schneider looks at how you can use the Tidy extension to clean up the (X)HTML markup that comes out of your application.

Tidy is a very cool PHP extension. You can let it tell you what kind of mistakes you might have in your HTML markup and even correct it for you - if you want. In my projects I use it to give me a hint if my generated markup is invalid. This way I can easily correct it during development without being dependent on external validators. In this post I will show you how easy it is and how few lines of code you need to make your application show any potential errors you might have in your HTML markup.

He shows how, with the help of output buffering, to grab the HTML output of your script and push it through the Tidy functionality (via a call to tidy_parse_string) and outputting the results. It even has a built in error catcher for when it finds invalid formatting in the generated markup. You can find out more about the features of this extension in the PHP manual.

tagged: extension tidy markup html tutorial

Link:

Sameer Borate's Blog:
Templating with Haml
Sep 09, 2010 @ 17:51:40

Sameer Borate has posted about an alternative templating system that's currently being used in multiple languages - Haml (HTML Abstraction Markup Language). As Sameer points out, there's also a PHP port of it.

It has been a while since I’ve used a template engine during development, the last one I used was Smarty. Now there are a plethora of template systems, but most are a rehash of Smarty. Readers may beg to differ, but Smarty gets the work done, which is all that matters. The one that I found really interesting is Haml.

He includes some markup examples of how it's structured - the main structure of the site, tables, divs, etc - and what it comes out like on the other side of the parser. The phphaml and phamlp libraries let you run the template through with variable values set and display it. There are some downsides he mentions, though, like the rules on indentation and that the markup has to be all in one file (or combined before sending to be rendered).

tagged: template haml markup abstraction tutorial phphaml phamlp

Link:

The Web Squeeze:
Using Prado - A PHP Framework
Apr 28, 2009 @ 17:54:18

On The Web Squeeze blog there's a recent post looking at a PHP framework that doesn't get mentioned that often (at least these days) - Prado. The post looks briefly at the framework at getting it set up for development.

This [word game] project was going to be slightly larger, and writing everything myself from scratch would have taken far too long. So I decided to use a PHP framework. PHP frameworks are a collection of code, meant to make your life easier and to aid you in the rapid development of dynamic websites. My choice fell on the Prado framework (see www.pradosoft.com).

He walks you through a first example script with both sides - controller to create/gather the content and the custom tag markup for it to inject the content into. He also includes a look at some of the Ajax support included with the framework. His example is the user clicking on a "Add to Cart" button to call the backend "onToCartClicked" method.

tagged: framework prado introduction example custom markup

Link:

Developer Tutorials Blog:
Why you should be using YAML for config
Jan 25, 2008 @ 17:22:00

The Developer Tutorials blog has a new post mentioning the use of YAML structure for creating configuration files in your application.

YAML, or YAML Ain't Markup Language, is a "human friendly data serialization standard". It's essentially a very basic format for storing data, and uses far less syntax than standard PHP. [...] It's almost like English; it's as basic as you want. Of course, that's not to say it doesn’t support complex structures - this example demonstrates the power of the format.

He also points out the spyc extension that makes working with the files in PHP a breeze.

tagged: yaml config markup language configuration file spyc

Link:

DeveloperTutorials.com:
Create a Facebook Application With PHP
Jan 07, 2008 @ 15:36:00

The DeveloperTutorials website has a new tutorial posted that walks the reader through a step-by-step process to create a PHP Facebook application of their very own.

Everyone is talking about Facebook and their new Application Platform and I have to admit I think it's pretty cool too. So I decided to create an application that uses the Facebook Platform. I'm writing the application in PHP and I thought it might be useful for others to know how to write their own Facebook applications with PHP.

They show you where you'll need to go to set up an ID with Facebook to develop with, the developer application you'll need to add, where to grab the Facebook developer API and, finally, creating a simple application.

Their example is just of the "Hello World" sort, but it gives you a good foundation to start from. They also include pointers to the Facebook Markup Language and a reference for the Facebook REST-based API interface.

tagged: facebook application library developer api rest platform markup facebook application library developer api rest platform markup

Link:


Trending Topics: