1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Introduction to Version Contron with CVS doc

69 405 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 69
Dung lượng 1,94 MB

Nội dung

VOLUME II - ISSUE 11 php | Cruise March 1 st - March 5 th 2004 See inside for details Get Ready For www.phparch.com NOVEMBER 2003 Plus: Tips & Tricks, Book Reviews, Product Reviews and much Introduction to Version Introduction to Version Control withControl with Discover the power of collaborationDiscover the power of collaboration CVSCVS Implementing Web ServerImplementing Web Server Load ManagementLoad Management Preventing resource overloads Working with PEAR::XML_SerializerWorking with PEAR::XML_Serializer XML has never been so easy Introduction to PHP-GTKIntroduction to PHP-GTK Getting started with desktop applications in PHP An Introduction to SQLiteAn Introduction to SQLite SQL for the masses Object Overloading in PHPObject Overloading in PHP Visit us at www .php arch.com/cruise for more details. php | Cruise March 1 st - March 5 th 2004 Andrei Zmievski - Andrei's Regex Clinic , James Cox - XML for the Masses , Wez Furlong - Extending PHP , Stuart Herbert - Safe and Advanced Error Handling in PHP5, Peter James - mod_rewrite: From Zero to Hero, George Schlossnagle - Profiling PHP, Ilia Alshanetsky - Programming Web Services, John Coggeshall - Mastering PDFLib, Jason Sweat - Data Caching Techniques <? ?> We’ve got you covered, from port to sockets. Port Canaveral • Coco Cay • Nassau Plus: Stream socket programming, debugging techniques, writing high-performance code, data mining, PHP 101, safe and advanced error handling in PHP5, programming smarty, and much, much more! In partnership with Zend Technologies Zend Studio 3.0 is the official PHP IDE of php|cruise Features php | Cruise Traditional PHP Conference* Conference Pass $ 899.99 ** $ 1,150.00 Hotel Included ($ 400.00) Meals Included*** ($ 200.00) Totals: $ 899.99 $1,750.00 You Save $ 850 * Based on average of two major PHP conferences ** Based on interior stateroom, double occupancy *** Alcohol and carbonated beverages not included ENJOY LEARNING PHP IN A FUN AND EXCITING ENVIRONMENT—AND SAVE A BUNDLE! 6 Editorial 7 What’s New! 40 Product Review PHPEclipse by Eddie Peloke 58 Product Review PhpED 3.2.1 by Marco Tabini 61 Tips & Tricks By John W. Holmes 65 Book Reviews by Peter MacIntyre 67 Bits & Pieces Real. Interesting. Stuff. by Peter James 69 e x i t ( 0 ) ; Frequently Annoying Questions By Marco Tabini 9 Object Overloading in PHP by Alessandro Sfondrini 15 Introduction to Version Control with CVS by Dejan Bosanac 25 Introduction to PHP-GTK by Eric Persson 30 Speaker on the High Seas An Interview with Wez Furlong 33 An Introduction to SQLite by John Coggeshall 44 Working with PEAR::XML_Serializer by Stephan Schmidt 52 Implementing Web Server Load Management by Rodrigo Becke Cabral 3 November 2003 ● PHP Architect ● www.phparch.com TABLE OF CONTENTS II NN DD EE XX II NN DD EE XX php|architect Features Departments Existing subscribers can upgrade to the Print edition and save! Login to your account for more details. NEW! NEW! *By signing this order form, you agree that we will charge your account in Canadian dollars for the “CAD” amounts indicated above. Because of fluctuations in the exchange rates, the actual amount charged in your currency on your credit card statement may vary slightly. **Offer available only in conjunction with the purchase of a print subscription. Choose a Subscription type: Canada/USA $ 97.99 CAD ($69.99 US*) International Surface $111.99 CAD ($79.99 US*) International Air $125.99 CAD ($89.99 US*) Combo edition $ 14.00 CAD ($10.00 US) (print + PDF edition) Your charge will appear under the name "Marco Tabini & Associates, Inc." Please allow up to 4 to 6 weeks for your subscription to be established and your first issue to be mailed to you. *US Pricing is approximate and for illustration purposes only. php|architect Subscription Dept. P.O. Box 3342 Markham, ON L3R 9Z4 Canada Name: ____________________________________________ Address: _________________________________________ City: _____________________________________________ State/Province: ____________________________________ ZIP/Postal Code: ___________________________________ Country: ___________________________________________ Payment type: VISA Mastercard American Express Credit Card Number:________________________________ Expiration Date: _____________________________________ E-mail address: ______________________________________ Phone Number: ____________________________________ Visit: http://www.phparch.com/print for more information or to subscribe online. Signature: Date: To subscribe via snail mail - please detach/copy this form, fill it out and mail to the address above or fax to +1-416-630-5057 php|architect The Magazine For PHP Professionals November 2003 ● PHP Architect ● www.phparch.com EE DD II TT OO RR II AA LL RR AA NN TT SS EE DD II TT OO RR II AA LL RR AA NN TT SS php|architect Volume II - Issue 11 November, 2003 Publisher Marco Tabini Editor-in-Chief Peter James petej@phparch.com Editor-at-Large Brian K. Jones brian@phparch.com Editorial Team Arbi Arzoumani Peter James Peter MacIntyre Brian Jones Eddie Peloke Graphics & Layout Arbi Arzoumani Managing Editor Emanuela Corso Director of Marketing J. Scott Johnson scott@phparch.com Account Executive Shelley Johnston shelley@phparch.com Authors Dejan Bosanac, Rodrigo Becke Cabral, John Coggeshall, Eric Persson, Alessandro Sfondrini, Stephan Schmidt php|architect (ISSN 1705-1142) is published twelve times a year by Marco Tabini & Associates, Inc., P.O. Box 54526, 1771 Avenue Road, Toronto, ON M5M 4N5, Canada. Although all possible care has been placed in assuring the accuracy of the contents of this magazine, including all associated source code, listings and figures, the publisher assumes no responsibilities with regards of use of the information contained herein or in all asso- ciated material. Contact Information: General mailbox: info@phparch.com Editorial: editors@phparch.com Subscriptions: subs@phparch.com Sales & advertising: sales@phparch.com Technical support: support@phparch.com Copyright © 2002-2003 Marco Tabini & Associates, Inc. — All Rights Reserved I like to consider myself a fairly adept PHP developer. I’ve been using PHP for just over two years continuously (plus massive amounts of overtime and hobby develop- ment), and have made some pretty cool applications (IMO, at least). Even so, I have yet to actually touch the vast majority of PHP extensions. And those are just the ones doc- umented on www.php.net . Countless others have been developed that may never be pro- filed there. This leads me to my point. Often, the arti- cle ideas submitted to us at php|a deal with aspects of PHP development that we know lit- tle about. As technical editors, though, it is our job to ensure that the material presented here is as accurate as possible, which forces us to (as much as possible) fully understand and grasp the technology being discussed. This presents incredible opportunities for learning and growth. I really think that there are stages in knowl- edge. When you first start out learning some- thing, you are ignorant and you (usually) make no bones about it. As your knowledge grows, you can quickly and easily become cocky and arrogant. This cocky and arrogant attitude usually succeeds giving you plenty of humble pie to eat, which manages to eventu- ally settle you into the comfortable stage where you know what you’re doing, but aren’t going to make a big deal out of it. When I look back at the time I’ve been at php|a, and the articles I’ve worked with, I’m astonished at how much I’ve learned. When I started at php|a, I was definitely in the “armed and dangerous” camp. I knew it all. After a number of months working with some of PHP’s best and brightest, I now realize that I know nothing, and should just shut up. It’s unfortunate, therefore, that I must leave php|a. I’ve really enjoyed working with every- body here, as well as you readers. You’re the reason we burn the midnight oil bringing you the best that the community has to offer every month. Your feedback and comments every month help us create a better publica- EDITORIAL tion . one that we can all be proud of. Many of our readers are also our authors, and I’ve very much enjoyed working with you as well. Your seemingly limitless practical knowledge of PHP has brought much enlightenment to the team here, and we thank you for that, as well as for the excellent articles that you offer us. Of course, php|a will continue. I mean, where would it go? Brian Jones will return as “Guest Editor-in-Chief” for the December issue, which is our first anniversary and will feature some of the best content yet (of course!), and our own Marco Tabini will do the honours again starting with January. Good luck Marco! Until then . November 2003 ● PHP Architect ● www.phparch.com 6 EDITORIAL php|a PHP.net announced the release of PHP 4.3.4. The latest version of the 4.0 branch of PHP, 4.3.4, has been released to the public. It contains, among other things, these fixes, additions and improvements: • Fixed disk_total_space() and disk_free_space() under FreeBSD. • Fixed FastCGI support on Win32. • Fixed FastCGI being unable to bind to a specific IP. • Fixed several bugs in mail() implementation on win32. • Fixed crashes in a number of functions. • Fixed compile failure on MacOSX 10.3 Panther. • Over 60 bug fixes For more information, visit www.php.net . PEAR 1.3b3 PEAR has released of the PEAR Base system. The PEAR package contains: • the PEAR base class • the PEAR_Error error handling mechanism • the PEAR installer, for creating, distributing and installing packages • the OS_Guess class for retrieving info about the OS where PHP is running on What’s New! NEW STUFF NEW STUFF PHP 5.0.0 Beta 2 Can’t wait until PHP5? Well, we are one step closer with the latest Beta 2 release of the new version of PHP. PHP.net announced: ”This is the first feature complete version of PHP 5, and we recommend for PHP users to try it. PHP 5 is still not ready for pro- duction use! Some of the more major changes include: • PHP 5 features the Zend Engine 2. • XML support has been completely redone in PHP 5, all extensions are now focused around the excellent libxml2 library ( http://www.xmlsoft.org/ ). • SQLite has been bundled with PHP. For more information on SQLite, please visit their website. • A new SimpleXML extension for easily accessing and manipulating XML as PHP objects. It can also interface with the DOM extension and vice-versa. • Streams have been greatly improved, including the ability to access low-level socket operations on streams. There have been many changes since Beta 1, some of them documented in the NEWS file and most language changes are documented in ZEND_CHANGES “ November 2003 ● PHP Architect ● www.phparch.com 7 • the System class for quick handling common operations with files and directories Changes in this release include changes to the PEAR installer. Get a taste of the new PEAR at PEAR.PHP.net PhpDocumentor 1.2.3 phpDocumentor is a JavaDoc-like automatic documen- tation generator for PHP written in PHP. The phpDocumentor team announces: “The phpDocumentor team is pleased to announce the release of phpDocumentor 1.2.3. This is a bugfix maintenance release. Only a few small bugs have been found and fixed. Notice: PEAR users will want to read the release notes for directions on how to automatically setup the web inter- face on install” Get all the files and more information from the pro- ject’s Sourceforge page at: http://sourceforge.net/projects/phpdocu/ PHP2Go Sourceforge.net announces the release of PHP2Go, a web development framework. The release announces: “After 12 months of develop- ment, we are very proud to announce that the first beta version of PHP2Go Web Development Framework was released. We strongly recommend that you don’t use this first beta version in a production environment. Soon, the first stable releases will be available here or at the project area in SourceForge.net. In this development period, almost 100 classes were cre- ated and tested. Almost all common features needed by a small, medium or high web application were included in the framework. However, the documentation of this first release is still poor. In a huge framework, that may be used to act like a basement to the development of one or more applications, documentation, tutorials and help stuff are very important. Because of that, as the time goes by, the complete instructions on how to build simple or complex stuff for your Web applications using PHP2Go will be avail- able here. For now, we suggest that you make your first experience with PHP2Go. Bug reports, suggestions or any doubts will be very welcome.” Get more information or download from Sourceforge.net at: http://sourceforge.net/projects/php2go/ :object::kitchen R4 Objectkitchen announces release number 4. What is it? Objectkitchen is a Java application used through a client/server-style connection from your application. It was written with the following goals in mind. It should be very easy to use. An average program- mer should be able to start storing and retrieving object data within 15 minutes of installation. NNEEWW SSTTUUFFFF MySQL.com announces the release of MySQL version 4.0.16. Some changes mentioned in the changelog include: • Added the following new server variables to allow more precise memory allocation: rraannggee__aalllloocc__bblloocckk__ssiizzee , qquueerryy__aalllloocc__bblloocckk__ssiizzee , qquueerryy__pprreeaalllloocc__ssiizzee , ttrraannssaaccttiioonn__aalllloocc__bblloocckk__ssiizzee , and ttrraannssaaccttiioonn__pprreeaalllloocc__ssiizzee . • mmyyssqqllbbiinnlloogg now reads options files. To make this work one must now specify ——rreeaadd--ffrroomm--rreemmoottee--sseerrvveerr when reading binary logs from a MySQL server. (Note that using a remote server is deprecated and may disappear in future mmyyssqqllbbiinnlloogg versions). • Block SSIIGGPPIIPPEE also for non-threaded programs. The blocking is moved from mysql_init() to mysql_server_init() , which is automatically called on the first call to mysql_init() . • Added ——lliibbss__rr and ——iinncclluuddee options to mmyyssqqll__ccoonnffiigg . • New ``>> prompt for mysql. This prompt is similar to the ‘‘>> and ““>> prompts, but indicates that an identifi- er quoted with backticks was begun on an earlier line and the closing backtick has not yet been seen. Get more information or download from MySQL.com . November 2003 ● PHP Architect ● www.phparch.com 8 It should be usable from a multitude of languages, but with primary focus on PHP and Java. It should provide natural mapping of an object-ori- ented design. Relations between objects should just work without any extra work. It should fast enough to be usable for reasonably busy websites. The best way to discover what objectkitchen is actu- ally about is to read the language introduction. Its a small one-page document, which provides you with an easy to read example using PHP as the client language. Get more information from: Objectkitchen.narcissisme.dk. ADOdb 4.00 PHPeverywhere announces the release of ADOdb 4.00 The release announces: ”ADOdb 4.00 is out after a 3 month beta testing process. The distinguishing feature of this release is the perform- ance monitoring functionality. AFAIK, it is the first Open Source cross-platform, multi-database performance moni- toring and health check software in the world. It features: • A quick health check of your database server using $$ppeerrff-->>HHeeaalltthhCChheecckk(()) or $$ ppeerrff-- >>HHeeaalltthhCChheecckkCCLLII(()) . • User interface for performance monitoring, $$ppeerrff-- >>UUII(()) . This UI displays: - the health check, - all SQL logged and their query plans, - a list of all tables in the current database - an interface to continiously poll the server for key performance indicators such as CPU, Hit Ratio, Disk I/O • Gives you an API to build database monitoring tools for a server farm, for example calling $$ppeerrff-- >>DDBBPPaarraammeetteerr((‘‘ddaattaa ccaacchhee hhiitt rraattiioo’’)) returns this very important statistic in a database indepen- dant manner. “ Get more information from PHPEverywhere at: http://php.weblogs.com/2003/11/05#a3100 PHP Meeting in Paris The French PHP User Group AFUP association is proud to announce the third annual PHP meeting in Paris, on November 26th and 27th, 2003. What is it? Developers and managers will gather to meet Zeev Suraski and other prominent community experts for two days of conferences, packed with solutions and advanced techniques. Get more information from: AFUP.org php|a NNEEWW SSTTUUFFFF PHP-GTK 1.0.0 PHP-GTK announces the release of version 1.0.0. What is it? PHP-GTK is an extension for PHP programming lan- guage that implements language bindings for GTK+ toolkit. It provides an object-oriented interface to GTK+ classes and functions and greatly simplifies writing client side cross-platform GUI applications. The release announces: “PHP-GTK Version 1.0.0 is finally out after almost a year of being in stasis. This is probably the last major version that will work with PHP 4 and Gtk+ 1.x. There might be more bugfixes, but no new features or upgrades will be implemented. PHP-GTK 2 is under develop- ment and will focus on PHP 5 and Gtk+ 2.x. “ Get more information from GTK.PHP.net . Direction|PHP NEXEN.NET , leading portal for PHP/MySQL plat- form in French, and php|architect, the Magazine for PHP Professionals, have announced the imme- diate availability of DIRECTION|PHP, the French monthly magazine for PHP/MySQL professionals. ”The French PHP community is among the largest and the most advanced in the world.”, says Damien Seguy, editor-in-chief of Direction|PHP. “ It needed a resource of expert knowledge and in- depth coverage of the industry. Naturally, that led us to partner with php|architect. “. php|architect provides a monthly technical resource for PHP professionals in the English mar- ket that includes in-depth articles, news, editorial comment, and product and book reviews. Direction|PHP is focused tightly on covering French news, and licenses part of its content from php|architect. ” Most technical knowledge is available in English, even if its authors are not native English speakers. I believe Direction|PHP will create oppor- tunities for both French authors and companies to step up to the plate and shine “, adds Damien Seguy. Get more information about Direction|PHP, visit their homepage. What is overloading? Overloading is an important feature of most Object Oriented Programming (OOP) languages like Java and C++. In these languages, overloading allows the pro- grammer to declare many methods or properties with the same name. Which one will be used when a call to that function name is made depends on the type (inte- ger, string, etc.) and the number of arguments passed to the method. If you aren’t too familiar with OO languages, maybe a very basic example in Java will help you out. Take a look at Listing 1. When the Java Virtual Machine finds a call to method hheelllloo(()) of class Greet in this code, it will choose the right method depending on the number of arguments. Of course, if we try to do this in PHP, all we will obtain is a fatal error, like so: Fatal Error: Cannot redeclare hello() For a strongly-typed language, overloading is impor- tant because it allows methods to behave in different ways depending on the number and type of the argu- ments received. If we overload the constructor of a class, we can obtain different objects depending on the number and type of parameters passed. Overloading is one of the most useful peculiarities of OO languages. Unfortunately (at least, in my humble opinion), PHP wasn’t born to be object-oriented. OOP is only really supported since PHP4, but still in quite a poor way. Thankfully, many improvements are being introduced, and PHP 5 will finally provide great OOP support. One of these improvements is the overloading extension. Although this extension differs from the Java version of overloading, we’ll show how to use it to sim- ulate that overloading in PHP. What is overloading in PHP? The “Object property and method call overloading” extension was introduced as a built-in, experimental extension in PHP 4.3.0. It is supposed to become sta- ble in PHP 5. Its purpose is something different from the overload- ing present in most object-oriented languages. In fact it November 2003 ● PHP Architect ● www.phparch.com 9 FEA FEA TURE TURE Object Overloading in PHP by Alessandro Sfondrini PHP: 4.3.3+ OS: N/A Applications: MySQL 4.0.12, Apache 1.3.27 Code: http://code.phparch.com/17/1 Code Directory: object-overloading REQUIREMENTS class Greet { hello() { System.out.println(“Hello World”); } hello(string name) { System.out.println(“Hello “ + name); } hello(string name, string from) { System.out.println(“Hello “ + name); System.out.println(“Greetings from “ + from); } } LISTING 1: Basic OO example in JAVA [...]... Let’s turn our focus now to a few advanced CVS topics, and see how it works “under the hood” This can be very useful in cases where you experience difficulty working with CVS We already mentioned the CVS directories that are placed in the working subdirectories These directories keep track of the state of the working directory with regards to a certain repository The CVS directories can contain several... information about the current CVS “root”, which is the directory where the CVS repository lives This will likely be the directory that we chose in CVS initialization - /usr/local /cvs The Repository file contains the directory for our project in the CVS repository Remember, one CVS repository can be used for several projects This could be an absolute or relative path, so our Repository file could contain... GUI for CVS access It seems that the majority of script developers tend to just use a good text editor for their development (no matter whether they work in Windows or Unix environments), so we will focus on a few standalone applications that could make your client CVS tasks easier Tortoise CVS (http://www.tortoisecvs.org/) is Windows-based tool that allows you to integrate basic CVS commands into Windows... compromising your CVS server If CVS can’t find a username or the passwd file it will try system user look-up (system password file, LDAP, 20 FEATURE Introduction to Version Control with CVS etc) in order to try to authenticate the user This feature can be disabled by specifying a “no” value for the SystemAuth variable in the $CVSROOT/CVSROOT/config file On the client side, the user just has to use the cvs command... software developers It enables you to browse a repository’s revision history with a web browser Figure 3 November 2003 ● PHP Architect ● www.phparch.com 22 FEATURE Introduction to Version Control with CVS Further steps If you’re planning a potentially large project, you’ll definitely need a version control system, and you’re better off to do it from the start CVS is a proven tool for the job, and has a huge... line (e.g cvs -d /usr/local /cvs/ login) or by setting the $CVSROOT environment variable, like so: $ export CVSROOT=/usr/local /cvs) The first thing we should do is to import our project into CVS for tracking $ cd /home/web/e-commerce $ cvs import -m “Imported source” e-commerce “OurCompany” start This command tells CVS that we want to start tracking the source in this folder in the repository under... repository with the pserver authentication method (either using “-d” or storing it in the $CVSROOT variable) When you are accessing the remote repository for the first time, you have to login That is done using the login command, which will prompt you to enter your password $ cvs -d :pserver:dejanb@phparch.com:/usr/local /cvs login Logging in to :pserver:dejanb@phparch.com:2401/usr/local /cvs CVS password:... branch If you want to get any changes that other developers made in the desired branch, you could use the “-r” switch with the update command $ cvs update -r e-commerce-1-0 There are many other possibilities with branching, 21 FEATURE Introduction to Version Control with CVS such as merging branches back into the main development branch, but they are outside the scope of this article CVS Tools Until now,... accidentally edit it 16 FEATURE Introduction to Version Control with CVS instead of the files that are under CVS Before you do this, you may want to consider backing it up somewhere, just in case $ rm -r /home/web/e-commerce.orig If you list the working directory now, you would see that beside the regular project files we have a CVS directory It is the system directory used by CVS, and under normal conditions... used to create aliases and to group project resources into logical modules It is a plain text file with one line for every module or alias Lines can be continued over more than one line, by appending the backslash (“\”) character to the end of each line Aliases have the following syntax: 19 FEATURE Introduction to Version Control with CVS alias_name –a what _to_ alias For example, let’s go back to our . much Introduction to Version Introduction to Version Control withControl with Discover the power of collaborationDiscover the power of collaboration CVSCVS. 1.2.3 phpDocumentor is a JavaDoc-like automatic documen- tation generator for PHP written in PHP. The phpDocumentor team announces: “The phpDocumentor team

Ngày đăng: 21/12/2013, 12:15

TỪ KHÓA LIÊN QUAN