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

Rob Allen:
Creating a zip file with PHP's ZipArchive
January 15, 2014 @ 15:40:59

Rob Allen has a new post to his site today showing you how to create a ZIP file with the help of PHP's ZipArchive functionality. The latest versions would need to be installed as an extension (PECL) if they're not already there, but it makes creating the archives a lot simpler.

I recently had a requirement to create a zip file from a number of files created within my application. As it has been years since I last had this problem, I had a look around and discovered that PHP 5.2 has the ZipArchive class that makes this easy. ZipArchive is fully featured, but as I just wanted to create a simple zip file.

All it requires is a few short lines of code - one to open the archive itself, some to add in the files to compress down and another to close and create the file. It's a pretty simple process using this handy extension. Rob also included a bit of sample code showing how to send it out for download with the correct headers.

0 comments voice your opinion now!
zip file archive create tutorial ziparchive

Link: http://akrabat.com/php/creating-a-zip-file-with-phps-ziparchive

DZone.com:
Factory patterns Collaborators Map
October 24, 2012 @ 09:43:02

On DZone.com Giorgio Sironi has a new tutorial looking at the Factory design pattern, specifically the use of a "collaborators map" to create them inside of a dependency injection container.

Like for every library, you should first evaluate if the costs and benefit of integrating [a dependency injection container] are worth it. The alternative is to write your own factory classes, methods and closures: this article explains one of the patterns for building dynamic Factory objects, and as such lowers the cost of the second option. What you know how to do has a lower cost than what you still have to learn, considering risk and implementation time.

He talks about the "old way" of making your own factories to create objects and how the collaborators mapping can replace that. The collaboration mapping is passed in when the object is created and a "create" method is called when the objects (or sub-objects) are needed. He also mentions some of the "easy" and "hard" changes you could make to this setup to expand its functionality.

0 comments voice your opinion now!
factory designpattern collaborator map object create


Lorna Mitchell's Blog:
Proof that PHP 5.4 is Twice as Fast as PHP 5.3
June 14, 2012 @ 10:04:55

In this quick post to her blog, Lorna Mitchell shares an interesting bit of benchmarking she did between PHP versions 5.3 and 5.4, finding 5.4 twice as fast as it's previous version sibling.

So recently I was working on some benchmarks for different versions of PHP, because I heard that PHP 5.4 is "faster" and since I'm a data geek I want to know how much faster! Now, PHP 5.4 is, in general, faster than PHP 5.3 but not twice as fast* unless you pick a use case which has been particularly optimised. My first attempt at benchmarking the two versions produced this. This was a surprise to me; was PHP 5.4 really so much faster??

Her benchmark was a pretty simple one - looping and creating a new object, evaluating the timing of how long it took to execute. A commentor also points to some more official benchmarks that were done and posted to the php.internals mailing list.

0 comments voice your opinion now!
speed version difference improvement create object benchmark


Anson Cheung's Blog:
Create nodes in eZ Publish using PHP
May 11, 2012 @ 11:37:47

In this new post from Anson Cheung, he shows you a way to easily create nodes in an eZ Publish-based application, importing content, XML and files/files.

Node creation in eZ Publish by using PHP is not well documented. However, when you encounter a large number of contents need to be insert periodically. You would ask is there any way to automate the content insert function with script in eZ Publish??? Any here I am going to summarize the way to achieve.

He includes the code examples showing how to:

  • Set the creator
  • Import generic content and attaching it to a parent node
  • Importing some XML content
  • Adding an image or file record that points to a local file
0 comments voice your opinion now!
ezpublish create node tutorial


Court Ewing's Blog:
Create and Validate a Choice List in a Symfony 2 Form
August 17, 2011 @ 08:28:21

Court Ewing has written up a new post to his blog about creating a "choice" list (a select list as defined by Symfony 2) with dynamic options and validating the resulting submission. His example uses Doctrine 2 entities to work with most of the data handling.

A standard select list can be created using Symfony's choice field type; it is pretty clear how to create a new choice field with simple, non-dynamic options (e.g. gender), but it gets a little more complicated when you want to create and validate a dynamically generated choice list.

He includes the code for a simple entity, a Post model to fetch the category information and the set up of the form element - a select list of post types/categories. He also includes a bonus section showing how you can achieve the same thing without a model to bind to. The code's a little bit more complex than the previous example, but it's basically just reproducing some of the validation and fetching logic manually.

0 comments voice your opinion now!
create validate tutorial symfony2 form select choice dynamic


PHPBuilder.com:
Creating and Manipulating PDFs with PHP and FPDF
March 11, 2011 @ 10:13:07

On PHPBuilder.com today there's a new tutorial about creating editing PDFs with the help of the FPDF library.

Because the Web has become the primary mechanism for distributing PDF documents, it's common to encounter questions on various web development forums pertinent to the dynamic creation of PDF documents using languages such as PHP. [...] Thankfully, such a demand for PDF manipulation capabilities exists within the PHP community that numerous alternative open source solutions have long been available, including notably FPDF.

They help you get the library installed and show you how to create a basic PDF with some simple text inside. They build on this and show how to add multiple text sections, images and watermarks.

3 comments voice your opinion now!
manipulate pdf fpdf create tutorial


Chris Jones' Blog:
More on PHP and Oracle 11gR2 Improvements to Client Result Caching
March 04, 2011 @ 09:56:33

Chris Jones has posted more information to his Oracle blog about the caching and other improvements that come along with the Oracle 11gR2 release that can be used in PHP applications.

Oracle 11.2 brought several improvements to Client Result Caching. CRC is way for the results of queries to be cached in the database client process for reuse. [...] PHP OCI8 as a "client" of the database can use CRC. The cache is per-process, so plan carefully before caching large data sets. Tables that are candidates for caching are look-up tables where the network transfer cost dominates.

Like many of the other server-side tools Oracle has to offer, it's pretty simple to enable this caching. Before you had to add a custom bit to your query to tell it to enable the caching. Now it's as simple as setting it up on the CREATE or ALTER for the table - nothing extra for the developer to do.

0 comments voice your opinion now!
oracle caching client result create alter


Dan Scott's Blog:
Creating a MARC record from scratch in PHP using File_MARC
March 04, 2011 @ 08:40:08

Dan Scott has posted an example of how to create a MARC record (machine-readable cataloging, more details here) from scratch with the help of the File_MARC PEAR package.

In the past couple of days, two people have written me email essentially saying: "Dan, this File_MARC library sounds great - but I can't figure out how to create a record from scratch with it! Can you please help me? Yes, when you're dealing with MARC, you'll quickly get all weepy and get help from anyone you can.

His example code is pretty simple - load the PEAR package into the script, create the record object and start adding fields to it. He shows various output methods ("pretty print", writing the raw data to a file, etc.) and the output to various other data structures like JSON and XML.

0 comments voice your opinion now!
marc record create filemarc pear package tutorial


NetTuts.com:
Create your First Tiny MVC Boilerplate with PHP
February 24, 2011 @ 12:20:30

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.

0 comments voice your opinion now!
tutorial mvc tiny framework custom create


SpeckBoy.com:
Getting Started with CRUD In PHP
February 18, 2011 @ 12:10:10

On SpeckBoy.com there's a new tutorial posted that introduces you to the concept of CRUD - Create, Read, Update, Delete - in the database interface for your application. Technically CRUD can be applied to any sort of data store, but they chose to go with a MySQL-based example.

It has become a common necessity for website owners to collect data and manage it properly. Creating a MySQL CRUD class allows you to conveniently create, read, update and delete entries for any of your projects, indifferent of how the database is devised. CRUD allows us to generate pages to list and edit database records. So, in this tutorial I will show you how to build a simple CRUD web app, that will empower you with the basic functions of database management.

They briefly walk you through the setup of a XAMPP server to use as a base and give you the settings needed to create a simple users table. The rest of the post is the code you'll need to make the connection from your PHP script, insert data into the table, update them, remove the rows and display their contents. They've wrapped it all up in a single "index.php" file to make it simpler.

0 comments voice your opinion now!
crud database mysql tutorial create read update delete



Community Events





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


api interview symfony opinion introduction tips library deployment community package series install zendserver release framework laravel language list update podcast

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