News Feed

News Archive
feed this:

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

This Programming Thing:
Creating Your Own Standard in PHPCS
May 12, 2015 @ 08:55:30

On the This Programming Thing blog there's a recent post showing you how to define your own "sniff" settings for the popular PHP_CodeSniffer tool. The codesniffer lets you define standards that need to be in place for all code in your application and notifies you of violations.

At Zimco, we've started working on standardizing our coding but we ran into a little problem while we tried to automate the process of making sure our code adhered to that standard. [...] I think we get into our own way of doing things and everything else is wrong. This code makes me feel irrationally angry (so angry I'm having a hard time not fixing itů). Ultimately, the best way to fix these kinds of formatting problems is to sit down and discuss what's best and have everyone stick to the same set of standards.

They talk some about the place for PSR in coding standards (specifically PSR-2) and the fact that there's already "sniffs" provided to check against those rules. However, they point out that running this against a non-PSR-2 codebase can be a mess and show you how to customize your own standard to more match your current state. They use an XML configuration file to update the tab width setting to four spaces and then apply the PSR-2 standards. They also show how to exclude certain rules and mention a handy plugin you can use in Sublime Text to keep your code within standards.

0 comments voice your opinion now!
standard phpcs phpcodesniffer sniff configuration xml psr2 update exclude


Evert Pot:
An XML library for PHP you may not hate.
April 02, 2015 @ 11:13:55

Evert Pot has posted about an XML library you may not hate, the sabre/xml library.

If you are writing or consuming API's in PHP, chances are that you need to work with XML. In some cases you may even prefer it. You may have started with SimpleXML and after a while switched to using the DOM after realizing SimpleXML is really not that simple if you strictly use xml namespaces everywhere.

For writing XML, you may have found that using the DOM requires far too much code, or you may simply generate your XML by echoing strings, knowing that it may not be the best idea. sabre/xml hopes to solve your issues, by wrapping XMLReader and XMLWriter, and providing standard design patterns.

He includes some example code showing how it works, extending the XMLReader/Writer functionality with a simplified interface. He includes examples of both writing a new XML file or reading in and working with the contents of a given one. He does point out one issue, though - the library cannot really read in XML contents, modify it and send it back out (it's a "single pass" system). He wraps up the post talking about the various interfaces and elements in the library and some of the overall benefits it provides.

0 comments voice your opinion now!
xml library xmlreader xmlwriter interface simple


Web Mozarts:
Defining PHP Annotations in XML
October 24, 2014 @ 11:10:53

The Web Mozarts blog has an interesting new post today that talks about using annotations in your PHP code to define the attributes in resulting XML that could be generated dynamically from your objects.

Annotations have become a popular mechanism in PHP to add metadata to your source code in a simple fashion. Their benefits are clear: They are easy to write and simple to understand. Editors offer increasing support for auto-completing and auto-importing annotations. But there are also various counter-arguments: Annotations are written in documentation blocks, which may be removed from packaged code. Also, they are coupled to the source code. Whenever an annotation is changed, the project needs to be rebuilt. This is desirable in some, but not in other cases.

They focus in on Symfony-based applications as a good base to work from (as they've pushed to have annotations work in the code for things like routing and data type definition). He starts with an example Doctrine class - a "best buddy" for Symfony as far as annotations go - and how the annotations define the different properties. He also includes an example of the XML output of the same definition generated through an "AnnotationReader" instance. He talks about having multiple XML documents representing one object with different annotations put in each, including the XML output. The post finishes with some advantages including the ease of validation by XML-friendly tools looking to interface with the application.

0 comments voice your opinion now!
annotations xml tutorial symfony doctrine example


Thomas Weinert:
FluentDOM 5 + XML Namespaces
August 07, 2014 @ 10:50:22

In this new post to his site Thomas Weinert shows how to use the FluentDOM library (a PHP implementation of a Javascript library by the same name) when XML namespaces are involved.

FluentDOM 5 allows to register namespaces on the DOM document class. These are not the namespaces of a loaded document, but a definition of namespaces for your programming logic.

He compares it to both a PHP example, using the DOMXpath handling and a Javascript sample using its own xmlDocument functionality. Finally he compares these examples to the few lines of FluentDOM code to handle the same kind of evaluation. He wraps up the post with a brief mention of the "appendElement" function that wraps serveral operations in one for easy element additions.

0 comments voice your opinion now!
fluentdom xml namespace tutorial javascript domxpath element

Using PHP Configuration Patterns Properly
April 16, 2014 @ 11:52:11

On today they have a new post showing different configuration patterns for getting localized settings into your applications. They show the use of INI files, PHP scripts, text files, XML data and a database call.

PHP is a cross platform language. It is a server based application so we must think about the configuration settings of the PHP software. There are various ways of creating configurable PHP applications. The configuration flexibility comes as a built in feature in PHP. But we must understand the requirement clearly before making an application configurable. This article explores different PHP configuration patterns and their implementation.

For each of the options mentioned, there's a brief description of what the method is, some of the common uses and a code example showing a basic implementation. The database pattern is the only one without a code example as the database interface varies widely from application to application.

0 comments voice your opinion now!
configuration pattern ini script text xml database

How to Create an RSS Feed Using PHP and PDO
December 04, 2013 @ 11:52:53

On the site there's a recent tutorial posted showing you a basic way to create an RSS feed using data coming from a database accessed via PDO.

Using an RSS feed on your website is a great way of letting your visitors, search engines or directories get a hand on your content. RSS feeds are common practice on most blog and CMS platforms including Wordpress, Joomla and evenly the newly released Ghost. If you're using a CMS or similar platform, the likelihood is that you don't need to implement an RSS feed yourself. [...] Below you've got the step-by-step process to create anything from the simple, standard-compliant RSS feed - up to the more advanced.

The tutorial shows you how to pull the data from a simple database table (SQL not provided, but pretty easy to figure out(, including example PDO connections for several database types. This data is then manually appended into an XML string to build out the RSS feed correctly. They also talk about implementing the Dublin Core metadata as a way for providing more information about the feed and its contents (including an image and category details).

0 comments voice your opinion now!
rss feed introduction tutorial pdo xml dublincore


Adam Culp:
Zend Framework 2 XML Sitemap
September 09, 2013 @ 11:15:09

In a new post to his site Adam Culp shares how he created an XML sitemap for his Zend Framework 2-based application as he made it (the SunshinePHP site) more SEO friendly.

I was pleasantly surprised to see the Navigation component of Zend Framework 2 includes a bunch of view helpers, including a Sitemap helper. So now I have an xml sitemap created by Zend Framework 2 that works hand in hand with the site navigation. However, the documentation was not complete as of this writing and caused me to do a bit of trial and error debugging to get it working. Below I will post how I got it working, in hopes it will help others.

The code to get it working is relatively simple - set it up in the module configuration, specify the navigation structure and add a route for the sitemap output. The view then accesses the navigation handling and calls a "sitemap" method to push the XML result out to the user.

0 comments voice your opinion now!
xml sitemap sunshinephp zendframework2 navigation helper


Lorna Mitchell:
First Phing Plugin
March 25, 2013 @ 10:49:23

In the latest post to her site, Lorna Mitchell walks you through the creation of a first Phing plugin, an extension to the popular PHP-based build tool.

I'm a huge fan of Phing and use it regularly for build and deployment tasks. Often, I'll ask about a plugin that I wish existed, and get a very courteous "patches welcome" from the nice people in the #phing channel on freenode. This has happened a few times, so I thought I should probably look at how to make a new phing plugin, this article shows you how to make the simplest thing I could think of: a simple "hello world" plugin.

She points you to the location to grab the latest version of the tool (the github repository) and how to define a configuration file for your test runs. Then she includes the sample code showing how to create the "HelloTask" plugin. It takes an input value of "name" and displays a greeting when executed. She shows the syntax for defining this in the XML build file and the sample result when executed.

0 comments voice your opinion now!
phing plugin install build configuration xml helloworld task
Parsing XML With SimpleXML
February 12, 2013 @ 12:48:34

On today there's a new tutorial introducing you to SimpleXML, a handy bit of functionality included with the base PHP install to make working with XML (well, reading it) much simpler.

Parsing XML essentially means navigating through an XML document and returning the relevant data. An increasing number of web services return data in JSON format, but a large number still return XML, so you need to master parsing XML if you really want to consume the full breadth of APIs available. Using PHP's SimpleXML extension that was introduced back in PHP 5.0, working with XML is very easy to do. In this article I'll show you how.

He starts with some basic usage of the SimpleXML parsing, giving an example XML to parse, the resulting object and how to access the data inside it. There's also a bit about dealing with namespaces in the XML you're parsing and a more practical example - parsing the output of a YouTube feed to get links to various videos.

0 comments voice your opinion now!
parse xml simplexml introduction tutorial

Andrew Podner:
Managing PHP Application Builds with Phing
February 04, 2013 @ 09:08:16

Andrew Podner has a new post to his site today introducing you to Phing, a PHP-based build tool (designed after on Apache Ant) that makes automating builds of your applications easy.

One of the things I have been focusing on lately is trying to to a better job of mechanizing and automating the process of building and deploying an application. The reason for this is pretty simple: applications just seem to keep getting more and more complicated and intricate as time goes on. [...] Phing is a "project build system" that helps developers manage repetitive tasks associated with preparation and deployment of applications. Phing uses XML based files to allow you the ability to customize the build process to the individual application.

He walks you through the Phing installation (from PEAR, note that you can install it via Composer now too) and how to set up your first project XML definition. He shows you how to add a "target" or step to the build with the basic example of running your app's PHPUnit tests. He also includes a list of other things Phing can do and work with including CodeSniffer checks, FTP handling, version control interfaces and automated documentation.

0 comments voice your opinion now!
application build phing tool introduction phpunit targer xml

Community Events

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

api community example opinion performance conference symfony2 language podcast application install laravel introduction interview configure series php7 framework library release

All content copyright, 2015 :: - Powered by the Solar PHP Framework