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

Lập trình PHP 7 programming blueprints

316 5 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 316
Dung lượng 11,22 MB

Nội dung

Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints Lập trình PHP7 programming blueprints www allitebooks comCuuDuongThanCong com https fb comtailieudientucntt http www allitebooks org http cuuduongthancong com?src=pdf https fb comtailieudientucntt PHP 7 Programming Blueprints Le.

CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt PHP Programming Blueprints Learn how to exploit the impressive power of PHP with this collection of practical project blueprints – begin building better applications for the web today! Jose Palala Martin Helmich BIRMINGHAM - MUMBAI CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt PHP Programming Blueprints Copyright © 2016 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: October 2016 Production reference: 2061016 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-78588-971-4 www.packtpub.com CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt Credits Authors Copy Editor Jose Palala Martin Helmich Safis Editing Reviewer Project Coordinator Shuvankar Sarkar Ulhas Kambali Commissioning Editor Proofreader Kunal Parikh Safis Editing Acquisition Editor Indexer Chaitanya Nair Rekha Nair Content Development Editor Production Coordinator Onkar Wani Melwyn Dsa Technical Editor Cover Work Murtaza Tinwala Melwyn Dsa CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt About the Authors Jose Palala has been working professionally with PHP for at least years He has experience working with PHP frameworks such as Eden PHP, CodeIgniter, Laravel and Zend He has worked for Philippine-based IT companies for at least years, working on projects ranging from internal corporate systems and CMS websites In his spare time, he regularly contributes back to the tech community in the Philippines I would like to thank everyone at Packt Publishing, it’s been great working with them since Day Super thanks to all to my colleagues, friends and family who have helped me to become a better developer and have helped me become what I am today Martin Helmich holds a Master's degree in Computer Science from the University of Applied Sciences in Osnabrück He works as a software architect and specializes in building distributed applications using web technologies and Microservice Architectures Besides programming in Go, PHP, Python and Node.JS, he also builds infrastructures using configuration management tools like SaltStack and container technologies like Docker He is an open source enthusiast and likes to make fun of people who are not using Linux In his free time, you'll probably find him coding on one of his open source pet projects, listening to music or reading science-fiction literature CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt About the Reviewer Shuvankar Sarkar is an IT analyst and experienced in C#, NET, PHP and web development He is a technology enthusiast and maintains his blog at http://shuvankar.com/ You can follow him on Twitter at @sonu041 He is interested in computer security as well I would like to thank my family for making my life easier and full of happiness CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt www.PacktPub.com eBooks, discount offers, and more Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy Get in touch with us at customercare@packtpub.com for more details At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks https://www2.packtpub.com/books/subscription/packtlib Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library Here, you can search, access, and read Packt's entire library of books Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt Table of Contents Preface Chapter 1: Create a User Profile System and use the Null Coalesce Operator The null coalesce operator Separation of Concerns Creating views Create a profile input form Admin system Summary Chapter 2: Build a Database Class and Simple Shopping Cart Building the database abstraction class Raw query method Create method Read method Select all method Delete method Update method first_of method last_of method iterate_over method searchString method Using the convert_to_json method to implement a simple API Shopping Cart Building the shopping items list Item template rendering function Adding checkboxes to the Shopping List page Cookies in PHP Building the Checkout page Thank you page Installing TCPDF Admin for managing purchases Summary Chapter 3: Building a Social Newsletter Service CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt 8 10 13 17 18 19 19 19 20 20 21 21 22 22 22 22 23 23 24 24 27 28 29 32 33 38 40 41 Authentication system Creating a social login for members Member dashboard Marketers dashboard Administration system for managing marketers Custom template for our newsletter Link tracking AJAX socket chat for support Introduction to socket.io Summary Chapter 4: Build a Simple Blog with Search Capability using Elasticsearch Creating the CRUD and admin system Seeding the post table What is Elasticsearch? Installing Elasticsearch and the PHP client Building a PHP Elasticsearch tool Adding documents to our Elasticsearch Querying Elasticsearch Installing Logstash Setting up the Logstash configuration Installing PHP Redis Encoding and decoding JSON messages Storing Apache logs in Elasticsearch Getting filtered data to display with Highcharts Dashboard app for viewing Elasticsearch logs Simple search engine with result caching Cache basics Cache invalidation of Redis data Using browser localStorage as cache Working with streams Storing and searching XML documents using PHP Using Elasticsearch to search a social network database Displaying randomized search engine results Summary Chapter 5: Creating a RESTful Web Service RESTful basics REST architectures Common HTTP methods and response codes First steps with the Slim framework [ ii ] CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt 41 47 52 56 57 60 63 66 66 73 75 75 80 80 81 85 87 88 88 89 89 91 92 93 99 101 103 103 104 106 108 108 110 112 113 114 114 115 116 Installing Slim A small sample application Accepting URL parameters Accepting HTTP requests with a message body The PSR-7 standard Middleware Implementing the REST service Designing the service Bootstrapping the project Building the persistence layer with MongoDB Adding and retrieving users Listing and searching users Deleting profiles Validating input Streams and large files Profile image upload Using GridFS storage Summary Chapter 6: Building a Chat Application The WebSocket protocol First steps with Ratchet Architectural considerations Getting started Testing WebSocket applications Playing with the event loop Implementing the chat application Bootstrapping the project server-side Bootstrapping the HTML user interface Building a simple chat application Receiving messages Sending messages Testing the application Keeping the connection from timing out Deployment options Bridging Ratchet and PSR-7 applications Accessing your application via the web server Adding authentication Creating the login form Checking the authorization [ iii ] CuuDuongThanCong.com www.allitebooks.com https://fb.com/tailieudientucntt 116 117 118 119 120 122 124 124 125 127 132 137 140 143 145 145 149 152 153 153 154 154 155 158 159 162 162 164 165 170 171 171 172 173 176 182 183 184 188 Reactive Extensions in PHP In the preceding code, we create an Observable object, which will return 42 when the defer function is called The defer function s a type of promise and returns an Observable, and the code inside it will be executed in an asynchronous manner When the Observable is subscribed to, the functions are in a way tied together or bound to each other and then get invoked or triggered What is an Observable, you might ask? In ReactiveX, an Observer subscribes to an Observable An Observer then reacts to whatever item or sequence of items that the Observable emits This means that when you have a bunch of events that are being sent to your application, but handle them in an asynchronous manner, meaning not necessarily in the order that they may have come in In the preceding code, stdoutObserver is an observer that puts out whatever is in the event loop or the Observable into the stdout or console log Scheduler Schedulers work with three main components: an execution context, which is the ability to the job given to it; the execution policy is how it will be ordered; and there's the clock or timer or the underlying system which measures time, which is needed to schedule when it will be executed The scheduler code is used as follows: $loop = \React\EventLoop\Factory::create(); $scheduler = new \Rx\Scheduler\EventLoopScheduler($loop); It basically creates an eventScheduler, which executes the event loop and parameterizes the concurrency level A simple scheduler within RxPHP is used in the preceding delay recursive-scheduler This is how the recursive-scheduler function is used:

Ngày đăng: 20/12/2022, 19:06

w