tailieunhanh - PHP Objects, Patterns, and Practice- P8
PHP Objects, Patterns, and Practice- P8: This book takes you beyond the PHP basics to the enterprise development practices used by professional programmers. Updated for PHP with new sections on closures, namespaces, and continuous integration, this edition will teach you about object features such as abstract classes, reflection, interfaces, and error handling. You’ll also discover object tools to help you learn more about your classes, objects, and methods. | CHAPTER 15 AN INTRODUCTION TO PEAR AND PYRUS relevant channels have been discovered before running channel-discover with the -o optional dependencies flag set. Using a PEAR Package Once you have installed a PEAR package you should be able to use it in your projects immediately. Your PEAR directory should already be in your include path there should be no problem including the package once it has been installed. Let s install PEAR_Config and any dependencies it might have pear install -a Config downloading . Starting to download 27 718 bytes .done 27 718 bytes downloading . Starting to download 13 476 bytes .done 13 476 bytes install ok channel install ok channel Here s how you would include the package require_once class MyConfig private rootObj function construct filename null type xml this- type type conf new Config if is_null filename this- rootObj conf- parseConfig filename type else this- rootObj new Config_Container section config conf- setroot this- rootObj function set secname key val section this- getOrCreate this- rootObj secname directive this- getOrCreate section key val directive- setContent val private function getOrCreate Config_Container cont name value null itemtype is_null value section directive if child cont- searchPath array name return child return cont- createItem itemtype name null function __toString return this- rootObj- toString this- type 329 CHAPTER 15 AN INTRODUCTION TO PEAR AND PYRUS We begin by including . Most PEAR packages work in this way providing a single toplevel point of access. All further require statements are then made by the package itself. The rest of the example simply works with the classes provided by the Config package Config and Config_Container. The Config package lets you access and create configuration files in a variety of formats. This simple MyConfig
đang nạp các trang xem trước