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

Qandidate.com Blog:
Handling AngularJS POST requests in Symfony
August 14, 2014 @ 11:09:13

The Qandidate.com blog has a quick new post today showing how to handle AngularJS requests with a Symfony framework based backend application. They automate the process of decoding the JSON from the Angular frontend to make it immediately usable to the framework backend.

At Qandidate.com we started using AngularJS last year and I have to say it was love at first sight! Two-way databinding, testability, dependency injection, server communication...awesome! Did I say server communication? We use Symfony 2 (which is awesome too) for our back end API's. Unfortunately AngularJS and Symfony do not speak the same language out-of-the-box. In this post I will show you how we automatically decode JSON requests so we can use it with Symfony's Request object using our symfony-json-request-transformer library (or class actually).

They start with a simple JSON example and the action to handle it (the "postAction") and show the manual json_decode method. Instead of having to do this in each controller action, they define the Request transformer handler. This handler takes the incoming request and allows for modifications to various aspects of the request, including transforming the data. They've posted a full example here that includes the full stack, not just the transformer itself (to show the full flow of the request).

0 comments voice your opinion now!
angularjs request symfony2 transform json request

Link: http://labs.qandidate.com/blog/2014/08/13/handling-angularjs-post-requests-in-symfony/

SitePoint PHP Blog:
Fractal a Practical Walkthrough
August 06, 2014 @ 13:07:49

The SitePoint PHP blog has a new tutorial posted by Alexander Cogneau that gives you an introductory walkthrough of Fractal, a PHP-based library that provides a translation and presentation layer for the output of your APIs.

If you ever developed for an API, you might have had troubles with changes of your database schema. If you didn't happen to have a good implementation, you had to rework your whole model when changing some column names. In this article I will demonstrate how you can use Fractal as a layer between your models and JSON output. This post will show you how this package will make API development easier.

He walks you through getting the library installed (via Composer) along with Silex for the application handling and the Illuminate/database package from the Laravel framework. He also provides a SQL file to create the database for the application. The sample app handles music information, providing a simple song and artist list. It uses the Fractal package to transform the data using Transformer objects for each data type.

0 comments voice your opinion now!
fractal package tutorial introduction transform output api

Link: http://www.sitepoint.com/fractal-practical-walkthrough/

Lukas Smith's Blog:
Transforming end user queries to Solr
July 01, 2010 @ 13:36:07

In some of his recent work Lukas Smith has been testing the waters of what Solr (the fast, open source search platform) has to offer. In his work with it he needed a way to convert the queries that come in from users into something Solr can understand. In this new post he explains how and shares the code for his solution (symfony-based).

In this blog post I want to talk about a prototype class I threw together (Look ma', I'm using git!) by working ezcSearch to help me in parsing and transforming end user queries into complex Solr queries.

He includes a few examples of Solr queries and what sort of data they'd return as well as the source for the library he's created to extend the sfSolrPlugin translate something coming in from a form into a simple Solr-formatted query.

0 comments voice your opinion now!
transform solr query tutorial symfony framework


Ibuildings techPortal:
Transforming XML with PHP and XSL
December 16, 2009 @ 08:35:37

New on the Ibuildings techPortal today is an article from Michael looking at XML transformation with PHP and XSL (XML-based "style sheets").

If you want to transform XML from one format to another, and especially if either the input or output XML is complicated or the transformation itself is difficult or awkward to express, then XSL may be a good choice. XSL is the eXtensible Stylesheet Language; a family of three W3C recommendations to do with the transformation and presentation of XML documents. This article will walk through some examples of how XSL and PHP can be used to achieve these types of XML tranformations.

He starts off by describing what XSL looks like and how it relates back to the XML you're applying it to. XSL allows you to take an XML file and work with it as a data source to pull bits of information out of or modify and push back out the other side. He gives three specific examples: pulling information out of an XML file, rewriting URLs and one of the more handy things PHP allows you to do - directly call PHP script inside the XSL document for those things that the normal XSL standards don't include.

1 comment voice your opinion now!
tutorial xml xsl transform


Adam Jensen's Blog:
Output Transformation in a Zend Framework Model Layer
April 06, 2009 @ 13:43:06

Adam Jensen has a new post to his blog today looking at a solution he's created to be able to access the raw input a user has entered.

I've run into a minor problem, and I'm not sure my solution is particularly ideal. See, the Zend_Form approach described above does a great job of implementing Chris Shiflett's Filter Input, Escape Output principle...user input is filtered for invalid HTML before it's ever saved to the model, and can then be escaped as appropriate in the view layer. But what happens if you need to be able to retrieve the user's original unfiltered input later?

While working with the raw data could be dangerous, he has created a custom model that, through the getters and setters and doing validation/sanitization and the presentation layer rather than behind the scenes. It's not ideal but he's willing to take suggestions...

0 comments voice your opinion now!
output sanitize filter transform getter setter raw user input


Tim Koschuetzki's Blog:
How To Transform HTML To Textile Markup - The CakePHP TextileHelper Revisite
August 23, 2007 @ 08:34:00

Tim Koschuetzki has a new tutorial posted today for CakePHP users out there - it's a method for transforming HTML content into Textile markup via the TextileHelper CakePHP helper.

For a current project of mine I had to find a way to decode html into textile markup. Why? Because we are using tinyMCE to process our textareas as wyciwyg editors, which generate HTML. However, we want all output controlled via textile to allow only the textile tags. Yes, we could do it with strip_tags(), but textile is much more elegant. Plus, it was a requirement by the client. Come on and find out how to detextile html.

Code is included to work on the transformation: detextile, processTag, detextile_process_glyphs and detextile_process_lists. An example is included as well, showing how to input a block of HTML content to be "textile-ized". The full code is available for cutting and pasting at the bottom of the post.

1 comment voice your opinion now!
cakephp framework textile markup transform html tutorial helper cakephp framework textile markup transform html tutorial helper


Raphael Stolt's Blog:
Transforming data centered XML into SQL statements
May 08, 2007 @ 10:27:00

In this new post on Raphael Stolt's blog, he shows a way that you can take XML that holds SQL information (in his example INSERTs and DELETEs) and transforms them into SQL statements via XSL stylesheets.

A canny data import technique that emerged from praxis, while working on the import of data-centered XML resources, is utilitizing the abilities of Xslt. The generation of the required SQL statements actually only needs a simple Xsl stylesheet which might import for an PHP XSLTProcessor object or pass to the xsltproc command line tool. Both further described approaches are based upon the libxslt library and are assuming the use of XSLT 1.0.

He starts with an example bit of XML that has the XSL stylesheet at the top that will be used to transform the data and the information to perform inserts on several "partner" values in the XML below. Following this, he creates a PHP class to load the file and apply the stylesheet.

He also mentions a few different approaches to the same problem - XSLTProcessor class approach returning a single SQL string , xsltproc approach and the XSLTProcessor class approach using the ability to use PHP functions as XSLT functions.

0 comments voice your opinion now!
transform xml sql statement xslt insert delete transform xml sql statement xslt insert delete


Community News:
HTML2PHP - Transformation Tool
January 24, 2006 @ 07:11:39

Via a post over on digg.com today, there's an interesting little tool called HTML2PHP that could be useful in some certain situations.

The tool takes in whatever text input you have and performs operations on it. For example, paste in some HTML and hit the button to submit it and out the other side pops HTML formatted to echo in PHP (using print). There are other options on the tool - the ability to use printf and echo along with print, to add in newlines, and to add parenthesis (depending on your preference).

It's nothing overly impressive, but if you have a large block of HTML that you need to work with, you might check into it...

0 comments voice your opinion now!
transform html text echo print printf transform html text echo print printf



Community Events





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


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

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