 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPMaster.com: Bending XML to Your Will
by Chris Cornutt January 26, 2012 @ 11:04:44
PHPMaster.com has a new tutorial posted today about "bending XML to your will" - working with XML data using the XML Parser and SimpleXML functionality already included with PHP.
If you've ever worked with the Twitter or Facebook APIs, looked at RSS feeds from a website, or made use of some type of RPC calls, you've undoubtedly experienced working with XML. [...] Knowing how to process XML data is a crucial programming skill today, and thankfully, PHP offers multiple ways to read, filter, and even generate XML. In this article I'll explain what exactly XML is, in case you haven't had any experience with it yet, and then dive into a few ways you can use PHP to bend XML to your will.
He introduces the concepts and syntax behind XML first for those not accustomed and quickly moves into the tools to parse it. First he looks at the XML Parser, an event-based parser, and SimpleXML, an easy way to access the contents of a well-formed XML document. Snippets of code are provided for each to show you how to put them into practice.
voice your opinion now!
xml tutorial parse eventbased simplexml introduction
PHPBuilder.com: PHP Simple HTML DOM Parser Editing HTML Elements in PHP
by Chris Cornutt September 08, 2011 @ 10:06:07
On PHPBuilder.com today there's a new tutorial from Vojislav Janjic about using a simple DOM parser in PHP to edit the markup even if it's not correctly W3C-formatted - the Simple HTML DOM Parser
Simple HTML DOM parser is a PHP 5+ class which helps you manipulate HTML elements. The class is not limited to valid HTML; it can also work with HTML code that did not pass W3C validation. Document objects can be found using selectors, similar to those in jQuery. You can find elements by ids, classes, tags, and much more. DOM elements can also be added, deleted or altered.
They help you get started using the parser, passing in the HTML content to be handled (either directly via a string or loading a file) and locating elements in the document either by ID, class or tag. Selectors similar to those in CSS are available. Finally, they show how to find an object and update its contents, either by adding more HTML inside or by appending a new object after it.
voice your opinion now!
simple html dom parse tutorial selector find replace edit
Matthew Weier O'Phinney's Blog: Using DocBlox
by Chris Cornutt August 04, 2011 @ 08:08:36
On his blog today Matthew Weier O'Phinney has a new post looking at an alternative to some of the other PHPDoc-based documentation tools, DocBlox, a tool written in PHP.
Until a few years ago, there were basically two tools you could use to generate API documentation in PHP: phpDocumentor and Doxygen. [...] phpDocumentor is practically unsupported at this time (though a small group of developers is working on a new version), and Doxygen has never had PHP as its primary concern. As such, a number of new projects are starting to emerge as replacements.
He introduces DocBlox as one of these alternatives and points out where you can get the latest version (from one of many sources including github, PEAR or by just grabbing a release. He includes instructions on how to run the tool on your code, use it to identify missing docblock comments and how to use the class diagrams feature that gives a more visual sense of how things fit together. He also mentions changing the title of the output, using different templates and how it uses a local SQLite database to cache the parsed information about your code (making it simpler and faster to do updates in the future).
voice your opinion now!
docblox docblock comment parse introduction
Michelangelo van Dam's Blog: Quality Assurance on PHP projects - PHPDocumentor
by Chris Cornutt July 27, 2011 @ 08:51:48
Michelangelo van Dam has posted the latest in his "quality assurance in PHP projects" series today with a look at something that can make your life and documentation easier - PHPDocumentor.
Unfortunately I've come across too many lines of code that were just lines of code, no comments or annotations provided. So, in best cases I could guess the types and parameters, but in many it was too obfuscated. I already talked about usage of a code sniffer like PHP_CodeSniffer in my previous post where you can validate the usage of comments in the code. But forcing developers (using a pre-commit checker) into writing documentation with their code is not really a good thing.
He suggests using something like PHPDocumetor (there's other PHPDoc parsers including DocBlox and Doxygen out there) to automatically generate documentation for your code based on its comments, giving your developers easier web-based access to the contents. He includes some sample docblocks for a class/method and gives an example command line call to build docs based on a project. A screencast and screenshot of the generated site shows the results of the run.
voice your opinion now!
phpdocumentor docblock parse quality assurance documentation
Maarten Balliauw's Blog: A hidden gem in the Windows Azure SDK for PHP command line parsing
by Chris Cornutt July 11, 2011 @ 11:41:38
In this new post Maarten Balliauw looks at a "hidden gem" in the Windows Azure SDK for PHP - the ability to create scripts to work with command-line scripts - the Microsoft_Console_Command class.
Usually when creating a command line script you would parse $_SERVER['argv'], validate values and check whether required switches are available or not. With the Microsoft_Console_Command class from the Windows Azure SDK for PHP, you can ease up this task. Let's compare writing a simple "hello" command.
He compares the two sides of making a PHP command-line script: the "ugly way" using normal PHP code and $_SERVER['argv'] and the "easy way" using the Microsoft_Console_Command class that uses a class to define the functionality. There's also methods to grab specific arguments, pull from STDIN and get environment variables.
voice your opinion now!
windows sdk azure commandline parse
Nicolas Grekas (on Github): Improved handling of HTTP requests in PHP
by Chris Cornutt June 17, 2011 @ 09:39:41
As Nicolas Grekas shows in this tutorial (posted as a gist), the functionality that PHP gives users to work with the raw HTTP requests is pretty limited. There's a few solutions he offers, but none of them allow for the full use of the HTTP options provided by the server.
HP offers comprehensive autoglobals to access external data sent with each request. These variables do not expose all the possibilities allowed by the HTTP protocol, but a controlled use can in practice minimize the impact of this limitation. Two problems are particularly troublesome: the lack of access to multi-valued keys without using a special syntax and complexity of the magic bracketed syntax. Until PHP natively provides another interface freed from these problems, a different interface in user space can circumvent them.
He gives some code examples of methods that can be used to parse strings like those found in cookies (or pulled in via php://stdin) including mentions of key normalization and accessing the values by literal keys. You can see a more full implementation here.
voice your opinion now!
http handling improved requests tutorial parse
Script-Tutorials.com: How to parse web pages using XPath
by Chris Cornutt April 21, 2011 @ 09:49:59
On the Script-Tutorials.com site there's a new article showing you how to use XPath to parse web pages, complete with screenshots of the page and the code to make it happen.
Today I will tell you how you can make parsers of remote HTML pages (in PHP). In this article I will show you how to perform xpath queries to Web pages. XPath - a query language to elements of xml or xhtml document. To obtain the necessary data, we just need to create the necessary query. For the work, we also need: browser Mozilla Firefox, firebug and firepath plugins. For our experiment, I suggest this webpage Google Sci/Tech News. Of course you can choose any other web page too.
They provide two demos and a downloadable package with everything you need. The script pulls in the page as a DOM document (which works as long as it's correctly formatted XML) and spits back out the matches from a few different XPath expressions. There's all sorts of sites out there that can help you with examples of other XPath expressions and syntax.
voice your opinion now!
xpath tutorial parse html website
Mike van Riel's Blog: Introducing DocBlox
by Chris Cornutt February 02, 2011 @ 13:48:14
Frustrated with some of the limitations the phpDocumentor tool has - mostly dealing with the memory issues - Mike van Riel has introduced how own tool that works similar but takes better advantage of advancements in PHP to keep things bit more manageable - Docblox.
Right before or during the Dutch PHP Conference 2010 the issue had arisen again and this time I was determined on solving it. In the end I chose to build a new Documentation Generation Application (may I coin DGA?) for PHP [...] With [a list of key] requirements written down in a small TODO file I started designing the new project (which at the time was still nameless) After spending some hours designing, coding, prototyping, designing, coding and testing is now the time to reveal the fruits of my labour: DocBlox
Currently the project is in a pre-release state but is quickly headed to a 1.0 release. The current codebase is completely able to parse files and output the results to HTML files. PDF support is planned for the future. You can find the current feature list here and can download/clone the latest source from it's github repository.
voice your opinion now!
docblox phpdocumentor parse docblock comment output
Working Software Blog: Parsing the output of PHPs print_r function
by Chris Cornutt January 14, 2011 @ 12:19:00
On the Working Software blog there's a recent post looking at correcting a mistake that the developer made when choosing the logging method of his application - pushing the output of print_r into a file.
recently deployed a job on which the timeline was so tight that my ability to type quickly was what made the difference between delivering on time or not. Everything was rushed, the budget was tight, it was one of those real seat of the pants deals and there was far too little testing done. [...] The only problem is that, in the 5 minutes before the site was supposed to go live, I didn't really have much time to thoughtfully prepare a logging system to record all this stuff and, in my haste, I settled for [a file_put_contents of the print_r of $_GET and $_POST].
Obviously, this solution is useful for casual browsing of the information, but if you need any real data from it, it's a real chore. To help you with the task, they've put together a snippet of code that can work through your print_r output and return it in a much more handy line-by-line result. Full code is copy-and-paste ready in the post.
voice your opinion now!
printr log file parse output
|
Community Events
Don't see your event here? Let us know!
|