Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Archive for Luty, 2011

This Week in Web – PHP COM, Pango, Python32, Titanium Mobile

This Week in Web – PHP COM, Pango, Python32, Titanium Mobile

PHP Pango Extension

Michael Maclean has recently published a PHP wrapper for the Pango library. It depends on his Cairo PECL package as well as Pango. Once installed you can draw graphics with Cairo and text with Pango directly from PHP. The following code is taken from his announcement:

header("Content-Type: image/png");
/* Make a 300x300px image surface */
$s = new CairoImageSurface(CairoFormat::ARGB32, 300, 300);
$c = new CairoContext($s);

/* Set the background to white */
$c->setSourceRGB(1, 1, 1);
$c->paint();

/* Let's draw using black 'ink' */
$c->setSourceRGB(0, 0, 0);

/* Make a Pango layout, set the font, then set the layout size */
$l = new PangoLayout($c);
$desc = new PangoFontDescription("Bitstream Charter 28");
$l->setFontDescription($desc);
$l->setWidth(250 * PANGO_SCALE);

/* Here, we use Pango markup to make part of the text bold */
$l->setMarkup("Hello world! Here is a rather long paragraph which should get wrapped");

/* Draw the layout on the surface */
$l->showLayout($c);

/* Output the PNG to the browser */
$s->writeToPng("php://output");

Titanium Mobile 1.6 Released

Appcelerator have just announced the release of version 1.6.0 of their Titanium Mobile SDK. 1.6.0 includes many new features for the Android platform including additional Intents, Samsung Galaxy support and the option that allows the app to be installed directly to the SD card. It also greatly reduces the filesize of the final .apk package of your application. Under the 1.5 SDK a simple app I created was 3.2mb, repackaged with the 1.6 SDK it was only 1.1mb. Note that this version of Titanium Mobile SDK marks Android 1.6 as deprecated. Over the next few weeks Query7 will be featuring a series of tutorials on creating mobile apps with Titanium Mobile.

Using COM in PHP

Justin Martin recently wrote a tutorial titled Using the Windows COM in PHP. In it he describes what the COM (Common Object Model) is and how useful it can be to interact with applications or the Windows operating system. If you run PHP on windows and are interested in using it as a scripting language for your computer I highly recommend you read this article. The following snippet (taken from Justin Martin’s blog) shows how you can change the desktop background using PHP and COM.

RegRead('HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper');
echo "{$currentWallpaper}\n";  

$registry->RegWrite('HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper', 'C:\Documents and Settings\YourUser\Local Settings\Application Data\Microsoft\YourWallpaper.bmp');
?> 

Python 3.2 Released

Since PEP 3003, the Moratorium on Language Changes, is in effect, there are no changes in Python’s syntax and only few changes to built-in types in Python 3.2. Development efforts concentrated on the standard library and support for porting code to Python 3.

Some of the highlights are:

  • an overhauled GIL implementation that reduces contention
  • an extended email package that handles bytes messages
  • a much improved ssl module with support for SSL contexts and certificate hostname matching
  • a sysconfig module to access configuration information
  • additions to the shutil module, among them archive file support
  • many enhancements to configparser, among them mapping protocol support
  • improvements to pdb, the Python debugger
  • countless fixes regarding bytes/string issues; among them full support for a bytes environment (filenames, environment variables)
  • many consistency and behavior fixes for numeric operations

Get Python 3.2

Django and Python3 – Take 2

Django core developer Alex Gaynor has written a blog post about Python 3 support for Django. He is hoping that it will be picked up as a project for the 2011 Google Summer of Code. It will be great news for the Python community if it does get accepted into GSOC as alot of people want to develop Python 3 apps using Django.

Source: http://query7.com/this-week-in-web-php-com-pango-python32-titanium-mobile

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Mayflower Blog: Creating coding standards for PHP_CodeSniffer

Mayflower Blog: Creating coding standards for PHP_CodeSniffer

On the Mayflower blog today there’s a new tutorial posted about creating coding standard “sniffs” for the PHP_CodeSniffer tool. A “sniff” is what defines the rules for your coding standards to follow (like “curly braces after function definitions should be on the next line” kinds of things).

In some cases the pre-installed coding standards like PEAR or Zend might not be sufficient for our current project or we want to deviate. This is the moment when we want to be able to create a custom one that fits our special needs. In this article I want to share my first experiences with you about how to create a custom coding standard for PHP_CodeSniffer.

They get into the details of what a “sniff” is and shows where they belong in the current structure of your PEAR install. There’s an example of how to run the command line tool and how to create your own structure for your own custom sniffs. Their first example sniff checks to ensure that the first letter of a class is in uppercase.

Source: http://www.phpdeveloper.org/news/15966

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Ibuildings techPortal: Win A Ticket to DPC11!

Ibuildings techPortal: Win A Ticket to DPC11!

The Ibuildings techPortal has announced a contest today where they’re giving away a free pass to this year’s Dutch PHP Conference.

I’m wildly excited to announce that we have a ticket to give away for the Dutch PHP Conference 2011!! The conference is entirely English-language (although you will hear many languages spoken in the hallways!), and takes place in Amsterdam between 19th and 21st May 2011. The schedule is online now, and it promises three days of really excellent technical content from some of the leaders of the PHP Community from Europe and beyond. The tickets are on sale already; bookmark this link in case you don’t win the ticket.

Entering the contest is simple – just leave a comment on the post with an email address and the winner will be picked from the group. You’ll have to leave a comment before March 18th, though or it won’t count towards the contest!

Source: http://www.phpdeveloper.org/news/15965

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

php|architect: Creating RRD graphs in PHP

php|architect: Creating RRD graphs in PHP

On the php|architect site today there’s a new tutorial from Joshua Thijssen about using RDD graphs in PHP. RDD graphs are commonly used in dashboard monitoring applications for everything from web servers to network traffic. Joshua introduces you to the topic and shows you how to use the extension in a sample script.

You may not be familiar with the term RRD graph, but if I show you one, you probably recognize them instantaneously. They are used to plot all kind of data against time in a very easy way which is why they are used a lot in all kind of applications. Even though many consider RRD as a library to create graphs, it is actually more than that: it’s a complete system to store aggregated data in a very efficient way.

He talks about how to load in the extension (or the command line, if it won’t compile) and create a sample graph or two from some database information. The functions the extension enables make it simple to create some basic graphs quickly and easily.

Source: http://www.phpdeveloper.org/news/15964

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

PHPBuilder.com: Using the Factory Pattern in PHP Applications

PHPBuilder.com: Using the Factory Pattern in PHP Applications

On PHPBuilder.com today, there’s a new tutorial posted about using one of the more well-known design patterns in your PHP applications – the Factory Pattern. Design patterns are repeatable methods for doing common tasks in a “best practices” sort of way.

In this article you will learn how to use the factory pattern design in your PHP application to construct different objects for interrogating a database (books) and displaying the records from a table (bookstore) [...] The essence of the factory method pattern is to “define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.”

He illustrates with a few sample scripts – one that displays a series of messages on factoried instances of a class, another that randomizes a display of images and another that handles book data and outputs the results.

Source: http://www.phpdeveloper.org/news/15963

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Fabian Schmengler’s Blog: Anonymous function calls in PHP

Fabian Schmengler’s Blog: Anonymous function calls in PHP

Fabian Schmengler has a new post today looking a using anonymous function calls in PHP. He relates to to another popular language that allows for dynamic anonymous functions – Javascript.

Anonymous function calls are a well-known pattern in JavaScript but there are also use cases in PHP where they make sense. Of course PHP 5.3 with its Lambda Functions is required!

He includes several little code snippets showing how the anonymous functions work including the “use” keyword functionality that lets you import variables from outside the function. There’s a sneaky pass-by-reference in there, so don’t get tripped up.

Source: http://www.phpdeveloper.org/news/15962

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Michael Nitschinger’s Blog: Understanding the Lithium Router – Part 2

Michael Nitschinger’s Blog: Understanding the Lithium Router – Part 2

In his latest post Michael Nitschinger extends his first look at the Lithium framework’s routing system with part two of his series – creating some unit and integration tests to help you understand how the various parts work.

Routes play an essential role in your request/response-cycle and therefore should also be tested like any other component that you develop. As the Lithium routing infrastructure also consists of classes and methods, we can run unit and integration tests against them.

Some of the tests include checking for basic request to controller mapping, testing with an ID in the request, using the export() method and testing various routing to ensure that the output is correct (the integration tests).

Source: http://www.phpdeveloper.org/news/15961

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Site News: Popular Posts for the Week of 02.25.2011

Site News: Popular Posts for the Week of 02.25.2011Popular posts from PHPDeveloper.org for the past week:

Source: http://www.phpdeveloper.org/news/15960

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Community News: Dutch PHP Conference – Updates to the site and the schedule

Community News: Dutch PHP Conference – Updates to the site and the schedule

The Dutch PHP Conference has posted an update about the conference today including changes to the schedule and how its represented on the site.

t has been about two weeks since the schedule was published and ticket sales started, but that doesn’t mean we haven’t done anything in the meantime! There have been a number of updates on both the site and the schedule.

There’s five new talks that’ve been added to the schedule including Paul Matthews‘ presentation on Solr, Chris Jones talking about high performance PHP apps and David Soria Parra on git. The site updates mainly revolve around the classification of the different sessions – icons added to show skill level and scope of the presentation. There’s also an update about the unconfernece and official conference social.

Source: http://www.phpdeveloper.org/news/15959

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

NetTuts.com: Create your First Tiny MVC Boilerplate with PHP

NetTuts.com: Create your First Tiny MVC Boilerplate with PHP

If you ever find yourself in need of a basic MVC structure for your application but don’t want to get involved with a full framework to do it, you should try out this new screencast from NetTuts.com. It shows you the creation of a simple “tiny MVC” implementation.

It’s important for me to note that I’m not advocating that you shouldn’t use large frameworks. They absolutely have their places, and I use them often. That said, there are definitely times when they can be overkill for smaller projects. When your only requirement is code organization, it’s typically better to scrape together your own MVC boilerplate.

The screencast’s about 15 minutes long and it walks you through each step of the way – making the routing, setting up controller handling and working with views. For the impatient, you can also download the source and get started quickly.

Source: http://www.phpdeveloper.org/news/15958

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>