 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Liip Blog: Table Inheritance with Doctrine
by Chris Cornutt March 28, 2012 @ 09:30:09
On the Liip blog there's a recent post looking at table inheritance with Doctrine, the popular PHP ORM tool. In the post, Daniel Barsotti talks about a database model that needed some updating due to their searching needs.
Our first idea, and it was not that bad, Drupal does just the same, was to have a database table with the common fields, a field containing the type of item (it's either an event or a blog post) and a data field where we serialized the corresponding PHP object. This approach was ok until we had to filter or search LabLog items based on fields that were contained in the serialized data.
To resolve the issue they turned to multiple table inheritance, relating the LabLogItem to both a BlogPost and Event. They also show how it could be modeled with a single table, but opt for the multiple method. Included in the post is the Doctrine-based code showing how to create the parent entity for the LabLogItem and the two child entities for the blog post and event. There's also a brief snippet showing how to use them with the EntityManager.
voice your opinion now!
table inheritance doctrine orm tutorial multiple
PHPMaster.com: Using Traits in PHP 5.4
by Chris Cornutt February 09, 2012 @ 08:40:50
On PHPMaster.com today there's a new tutorial about using a feature in the upcoming PHP release (5.4) to make it easier to work with more modular code - using traits.
In this article I will discuss traits, a new feature introduced in PHP 5.4 to overcome [issues where multiple inheritance is needed]. The concept of traits itself is nothing new to programming and is used in other languages like Scala and Perl. They allows us to horizontally reuse code across independent classes in different class hierarchies.
Included in the post is example code showing what the use of a trait looks like and a method for creating a Singleton that can spawn instances of two classes. Also included are examples of:
- using multiple traits at once,
- traits made up of traits,
- the importance of order,
- aliasing to avoid conflicts,
- reflection
- and a few other features that come along with their use.
voice your opinion now!
traits tutorial introduction feature multiple inheritance
PHPMaster.com: Using Phing
by Chris Cornutt January 05, 2012 @ 10:41:40
On PHPMaster.com today there's a new tutorial posted about using the Phing build tool to automate a process, usually a build for a website launch. In his example, he shows a simple "Hello World" example and how to work with multiple targets in the same build file.
Phing is a PHP project build tool based on Apache Ant. A build system helps you to perform a group of actions using a single command. [...] Phing helps overcome [human error] issues by automating tasks like running unit tests, applying database changes, deploying application code, etc. In this article I'll show you some of the basics of working with Phing.
He includes the commands you'll need to install Phing (if it's not already) via the PEAR installer and a basic "build.xml" file. He explains the parts of the file - tags for "project", "target" "echo" and "property - and includes a more complex build example with multiple targets (and how to call one specifically from the command line).
voice your opinion now!
phing build tool tutorial multiple target helloworld
Derick Rethans' Blog: Multiple PHP versions set-up
by Chris Cornutt November 07, 2011 @ 09:14:00
Derick Rethans has a new post today looking at a method for setting up multiple PHP versions on the same machine and switch between them with a little help from some simple bash scripts.
For many of my projects (both hobby and commercial) I need to support many different PHP configurations. Not only just different PHP versions, but also debug builds, ZTS builds and 32-bit builds. In order to be able to test and build extensions against all those different PHP configurations I have adopted a simple method that I'm sharing with you here.
Using this script he can tell his system to pull the latest version of any release from SVN and try to compile it. The trick is putting each of them into a different directory under /usr/local. He uses another small shell function (with a function called "pe()") that sets up the pathing to the right release, complete with its own locations for PEAR/PECL and a php.ini.
voice your opinion now!
multiple version setup bash script switch tutorial
Joshua Thijssen's Blog: LAMP-stack? Forget it! It's a LAMPGMVNMCSTRAH-stack now...
by Chris Cornutt October 27, 2011 @ 12:49:12
These days there's much more involved in making a good, solid web application than just the platform you serve from. Joshua Thijssen knows this and humorously points it out in a new post about a "LAMPGMVNMCSTRAH-stack" (that's fifteen different technologies for those counting).
Back in the good old days - and in internet-time, this actually means just a few years ago - people were quite happy with their LAMP stack: Linux, Apache, MySQL and PHP. With this quartet, or a variation on it like PostgreSQL instead of MySQL, we could do everything: create a blog-site, setup an e-commerce web shop, making a guestbook, you name it and it was there.. But times have changed... radically.
He talks about this "brave new world" developers live in today where they can't know everything that happens in every facet of the application (he likens it to the responsibilities of generals vs infantry in the army).
As a programmer, you simply cannot pretend that you and you alone are running a system. You are part of a whole, and even though you might be the most important part, or the controlling part, you still need to work with other components in order to get the job done. If you forget this, no matter how good your part is running, the whole system will fail because you either decided to do too much yourself, or did not correctly utilize the rest of the system.
Wondering what his acronym stands for? LAMPGMVNMCSTRAH is short for "Linux, Apache, MySQL, PHP, Gearman, Memcached, Varnish, Ngnix, MongoDB, CouchDB, Solr, Tika, Redit, ActiveMQ, Hadoop."
voice your opinion now!
lamp multiple technology platform specialize environment opinion
Sameer Borate's Blog: Splitting large MySQL dump files
by Chris Cornutt October 03, 2011 @ 08:44:43
In a new post to his blog Sameer Borate includes a handy bit of code you can use to split up a large MySQL dump file into smaller, easier to digest chunks.
One of the frustrating things with working with MySQL is of importing large sql dump files. Either you get a 'max execution time exceeded' error from PHP or a 'Max_allowed_packet_size' from MySQL. In a recent task I needed to import a table of around a million records on a remote host, which quickly became an exercise in frustration due to various limitations on the server. SSH was of no help as changing the configuration files was restricted to the root user. My last resort was to split the huge 'INSERT' statements into smaller size files.
His script needs a little extra time to run (he sets max execute to 600 seconds) and takes the SQL file in line by line, splitting them back out to over files based on a "count" value - "dump-split-*". Depending on the size of your files, using something like this might not be an option. You might need something more like the command line "split" feature to keep it outside of PHP's memory management all together.
voice your opinion now!
mysql sql dump file split unix multiple tutorial
PHPBuilder.com: Transfer Data via Multiple Protocols with Libcurl
by Chris Cornutt September 19, 2011 @ 12:03:23
On PHPBuilder.com today there's a new tutorial showing how to use libcurl to communicate with multiple protocols like FTP, HTTP, HTTPS, SMTP and STMPS. The libcurl library that can be compiled in or installed as a shared module in your PHP install to provide enhanced networking abilities.
As I wrote in my PHP multithreading with cURL article, the libcurl is a free and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP. PHP supports the libcurl library which allows you to connect and communicate to many different types of servers with many different types of protocols.
The tutorial focuses on two different types of connections (well, four really) - FTP/FTPS and HTTP/HTTPS - and how to transfer data across each. Some code is included to create a (procedural) tool to send an uploaded file to a remote site.
voice your opinion now!
tutorial libcurl ftp ftps http https networking multiple protocol
|
Community Events
Don't see your event here? Let us know!
|