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

Lorna Mitchell:
Logging to Stdout with Monolog
June 09, 2014 @ 09:08:10

Lorna Mitchell has a quick post today showing how you can use the popular Monolog logging library to log messages and data to stdout, the standard output stream of whatever is executing the script.

My worker scripts have really basic logging (as in, they echo when something happens, and I can see those in the supervisord logs). Which is kind of okay, but I wanted to at least add timestamps in to them, and maybe send emails when something REALLY bad happened. I'm a huge fan of Monolog so I grabbed that, but it wasn't immediately obvious which of the many and varied options I would need for this fairly simple addition. It turns out that the right thing to use is the ErrorLogHandler.

She includes a few lines of sample code that use the "ErrorLogger" to output the message. It includes the log level, a timestamp, the message itself and any additional contextual information you pass in.

0 comments voice your opinion now!
monolog stdout output example library logging

Link: http://www.lornajane.net/posts/2014/logging-to-stdout-with-monolog

Evert Pot:
jCard is now a thing
January 21, 2014 @ 11:04:18

In his most recent post Evert Pot talks about jCard, a JSON-based format that was recently approved to serve up VCard personal information data in an easier-to-parse format.

I'm a big fan of this format. vCards have been around since 1995, and even though we've had a pretty significant update in 2011 in the form of vCard 4.0, the format is still complicated to parse, has a number of problems that go all the way back to the early days. [...] The biggest problem with vCards, is that upon a first glance, the format seems extremely easy to parse and generate with just a couple of string manipulation functions. When you dig deeper into the specifications though, you'll notice that it's actually really complex and hosts a ton of edge cases.

He includes an example of how to generate the jCard format using the Sabre/Object and the resulting output, both in the traditional vCard format and the new jCard structure.

0 comments voice your opinion now!
vcard jcard json format sabre object parse output

Link: http://evertpot.com/jcard-completed

Sameer Borate:
Easy PHP debugging with Kint
November 07, 2013 @ 11:24:02

Sameer Borate has posted about using Kint, a "more powerful debugger" that lets you output more data than just the usual var_dump or print_r provides and in a much more readable format.

My standard debugging tool when using PHP is xdebug. Pairing xdebug with Komodo gives me a very productive environment for building PHP applications. However, testing an application code on a hosted server can be many times frustrating as one has only the print_r and var_dump functions at our disposal. What I need is a library that I can easily install on the server and start using. Although there are a few debugging libraries around, one of my favorites is Kint.

He walks you through the installation of the tool and provides an example of the most basic usage (and output) from a call to the tool's "dump" function. He also gets into some of the additional features the library provides including intelligent formatting, debug tracing and limited theme configuration.

0 comments voice your opinion now!
debug kint output printr vardump example setup

Link: http://www.codediesel.com/tools/easy-php-debugging-with-kint/

MaltBlue.com:
Basic CSV Output in Zend Framework 2
July 18, 2013 @ 09:20:42

Matthew Setter has a new post on the MaltBlue site about creating CVS output from a Zend Framework 2 based application. Instead of writing to a CSV file on the local file system, he opts to push the information out to the user directly in the browser.

Today's tutorial is a simple one. We're going to look at a simple way of rendering CSV output in Zend Framework 2 using a combination of a View Template and Controller Action. We're going to see just how easy it is to generate content and send it to the browser, instead of rendering a standard .pthml template.

He includes the module configuration that sets up the location of the CSV template file and defines the "download/download-csv" header. The view template is pretty simple - just a loop of the results that calls fputcsv to push the data info a file handle. The code for the controller is also included, showing how to create a view model to push the data out.

0 comments voice your opinion now!
cvs output zendframework2 tutorial viewmodel

Link: http://www.maltblue.com/tutorial/simple-csv-output-in-zend-framework-2

NetTuts.com:
Whoops! PHP Errors for Cool Kids
June 06, 2013 @ 10:46:12

On NetTuts.com there's a new post spotlighting an interesting tool you can use to help make debugging an easier (and prettier) experience in PHP, the Whoops library.

Whoops is a small library, available as a Composer package, that helps you handle errors and exceptions across your PHP projects. Out of the box, you get a sleek, intuitive and informative error page each time something goes pants-up in your application.

It provides you with detailed error messages, a "code view" of where the error was found, support for Ajax/JSON requests and providers for several popular frameworks. The system is made up of a set of handlers that execute in order to provide the resulting page of output. He goes through how to install the tool (via Composer) and what you'll need to know to put it to use. He shows how to change up some of the configuration options and add in some extra info to the output. There's also a section specifically about integrating it with the Laravel 4 framework.

0 comments voice your opinion now!
whoops error output composer tutorial introduction

Link: http://net.tutsplus.com/tutorials/php/whoops-php-errors-for-cool-kids

Derick Rethans' Blog:
What is PHP doing?
July 13, 2012 @ 08:30:02

Derick Rethans has a new post to his blog showing how you can, using a few simple unix tools, figure out what PHP is doing when your scripts are executing.

Sometimes when you have a long running PHP script, you might wonder what the hell it is doing at the moment. There are a few tools that can help you to find out, without having to stop the script. Some of these work only on Linux.

He shows you how to use the following commands to track down exactly what your process is working on: strace, ltrace and gdb (a handy debugger that will probably give you more information than you're looking for). He includes some sample output for the commands and gives an example of a PHP script-to-gdb output relationship.

0 comments voice your opinion now!
process debug strace ltrace gdb output tutorial


PHPMaster.com:
PHP Security Cross-Site Scripting Attacks (XSS)
May 01, 2012 @ 11:59:28

PHPMaster.com has a new tutorial posted today (by George Fekete) about preventing cross-site scripting attacks in your PHP-based applications.

Unfortunately, cross-site scripting attacks occurs mostly, because developers are failing to deliver secure code. Every PHP programmer has the responsibility to understand how attacks can be carried out against their PHP scripts to exploit possible security vulnerabilities. Reading this article, you'll find out more about cross-site scripting attacks and how to prevent them in your code.

Included in the tutorial is an example with a simple form and definitions of different types of XSS attacks - reflected XSS, persistent XSS and three ways to prevent them: data filtering, output filtering and data validation. He also links to a few "cheatsheets" to help even more (including this guide and a Zend Framework set of XSS test data.

0 comments voice your opinion now!
tutorial security xss filter validate data output cheatsheet


Danne Lundqvist's Blog:
Getting to grips with an existing XML structure
April 25, 2012 @ 10:44:43

Danne Lundqvist has a new post where he shares a bit of code he's written to "come to grips" with an existing XML structure.

Very often I find myself writing input filters for large XML files using PHP. Common enough task; and PHP offer a great variety of tools to do this effectively depending on the situation. Unfortunately, almost as common is the lack of documentation for the aforementioned XML files. [...] I have looked around for a simple tool but I didn't really find a tool that gave me the quick and dirty overview I wanted. A year or so ago I finally wrote a small PHP class to analyze large XML files.

He includes an example XML file, the HTML output of the parsing and a sample of how to use the class to parse and output the XML structure, complete with some CSS.

0 comments voice your opinion now!
xml structure schema parse output html csss


Code2Learn.com:
Generating CSV file using CodeIgniter Framework
April 19, 2012 @ 11:45:52

The Code2Learn site has posted another in their CodeIgniter "series" about producing various kinds of output from an application based on this framework. In this new article Farhan Khwaja shows how to output a CSV-formatted file.

I have already written posts on how to generate pdf files using CodeIgniter Framework and also on how to generate tabulated pdf file using CodeIgniter Framework. This post will help you to generate a CSV file using CodeIgniter. The data for the CSV File will be taken from the MySQL Database and will be put into the CSV File.

He includes the source for a basic "Generate" controller class that uses a custom "CSV_Helper" to do the work. It has two methods - one to transform array data and another to take the database result object and extract each record.

0 comments voice your opinion now!
generate csv file codeigniter framework tutorial output helper


Leaseweb Labs Blog:
POC Flexible PHP Output Caching
February 02, 2012 @ 12:10:21

On the Leaseweb Labs blog there's a recent post looking at using the POC framework to work with flexible output caching. The tool makes it easy to create a new object and push cache content into it, automatically caching the data to sources like the file system, a Redis instance or a MongoDB database.

Last year at the Symfony conference in Paris I have heard a really good quote: "There are only two hard things in Computer Science: cache invalidation and naming things" - Phil Karlton. I agree with it and it gave me a boost to keep evolving the concept.

He includes an introduction to the caching features of the framework complete with sample code showing first how to cache to the default file system and a more complex example that uses unique caches and page blacklists. Other features planned for the caching tool include edge-side includes, using Twig for templating and statistics recorded to a database.

0 comments voice your opinion now!
poc framework cache output flexible



Community Events





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


refactor community interview list testing series unittest experience code install podcast introduction language developer release laravel threedevsandamaybe symfony2 opinion framework

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