PHP 7 Programming Blueprints

Book description

Learn how to exploit the impressive power of PHP 7 with this collection of practical project blueprints – begin building better applications for the web today!

About This Book

  • Don’t just learn PHP 7 – follow a diverse range of practical knowledge to get started quickly

  • Take advantage of PHP 7’s newest features – and find out how to use them to solve real development challenges

  • Put PHP to work for performance and scalability – we’ll show you how, you do it!

  • Who This Book Is For

    The book is for web developers, PHP consultants, and anyone who is working on multiple projects with PHP. Basic knowledge of PHP programming is assumed.

    What You Will Learn

  • Build versatile projects using the newest features PHP 7 has to offer

  • Learn how to use PHP 7’s event-driven asynchronous features

  • Find out how to improve the performance of your code with effective techniques and design patterns

  • Get to grips with backend development and find out how to optimize session handling

  • Learn how to use the PHP 7 Abstract Syntax Tree to improve the quality of your code and make it more maintainable

  • Find out how to build a RESTful web service

  • Build your own asynchronous microservice

  • In Detail

    When it comes to modern web development, performance is everything. The latest version of PHP has been improvised and updated to make it easier to build for performance, improved engine execution, better memory usage, and a new and extended set of tools. If you’re a web developer, what’s not to love? This guide will show you how to make full use of PHP 7 with a range of practical projects that will not only teach you the principles, but also show you how to put them into practice. It will push and extend your skills, helping you to become a more confident and fluent PHP developer.

    You’ll find out how to build a social newsletter service, a simple blog with a search capability using Elasticsearch, as well as a chat application. We’ll also show you how to create a RESTful web service, a database class to manage a shopping cart on an e-commerce site and how to build an asynchronous microservice architecture.

    With further guidance on using reactive extensions in PHP, we’re sure that you’ll find everything you need to take full advantage of PHP 7. So dive in now!

    Style and approach

    This product focuses on helping developers build projects from scratch. But more than that, each project will help the reader to learn a new facet or feature of PHP 7 – it means the reader really will ‘learn by doing.’

    Table of contents

    1. PHP 7 Programming Blueprints
      1. PHP 7 Programming Blueprints
      2. Credits
      3. About the Authors
      4. About the Reviewer
      5. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book 
          3. Errata
          4. Piracy
          5. Questions
      7. 1. Create a User Profile System and use the Null Coalesce Operator
        1. The null coalesce operator
        2. Separation of Concerns
        3. Creating views
        4. Create a profile input form
        5. Admin system
        6. Summary
      8. 2. Build a Database Class and Simple Shopping Cart
        1. Building the database abstraction class
          1. Raw query method
          2. Create method
          3. Read method
          4. Select all method
          5. Delete method
          6. Update method
          7. first_of method
          8. last_of method
          9. iterate_over method
          10. searchString method
          11. Using the convert_to_json method to implement a simple API
        2. Shopping Cart
          1. Building the shopping items list
            1. Item template rendering function
          2. Adding checkboxes to the Shopping List page
          3. Cookies in PHP
          4. Building the Checkout page
          5. Thank you page
        3. Installing TCPDF
        4. Admin for managing purchases
        5. Summary
      9. 3. Building a Social Newsletter Service
        1. Authentication system
          1. Creating a social login for members
          2. Member dashboard
          3. Marketers dashboard
            1. Administration system for managing marketers
          4. Custom template for our newsletter
          5. Link tracking
          6. AJAX socket chat for support
            1. Introduction to socket.io
        2. Summary
      10. 4. Build a Simple Blog with Search Capability using Elasticsearch
        1. Creating the CRUD and admin system
          1. Seeding the post table
          2. What is Elasticsearch?
          3. Installing Elasticsearch and the PHP client
            1. Building a PHP Elasticsearch tool
          4. Adding documents to our Elasticsearch
            1. Querying Elasticsearch
            2. Installing Logstash
            3. Setting up the Logstash configuration
            4. Installing PHP Redis
            5. Encoding and decoding JSON messages
          5. Storing Apache logs in Elasticsearch
            1. Getting filtered data to display with Highcharts
          6. Dashboard app for viewing Elasticsearch logs
          7. Simple search engine with result caching
          8. Cache basics
            1. Cache invalidation of Redis data
          9. Using browser localStorage as cache
          10. Working with streams
          11. Storing and searching XML documents using PHP
          12. Using Elasticsearch to search a social network database
            1. Displaying randomized search engine results
          13. Summary
      11. 5. Creating a RESTful Web Service
        1. RESTful basics
          1. REST architectures
          2. Common HTTP methods and response codes
        2. First steps with the Slim framework
          1. Installing Slim
          2. A small sample application
            1. Accepting URL parameters
          3. Accepting HTTP requests with a message body
          4. The PSR-7 standard
          5. Middleware
        3. Implementing the REST service
          1. Designing the service
          2. Bootstrapping the project
          3. Building the persistence layer with MongoDB
          4. Adding and retrieving users
          5. Listing and searching users
          6. Deleting profiles
          7. Validating input
        4. Streams and large files
          1. Profile image upload
          2. Using GridFS storage
        5. Summary
      12. 6. Building a Chat Application
        1. The WebSocket protocol
        2. First steps with Ratchet
          1. Architectural considerations
          2. Getting started
          3. Testing WebSocket applications
          4. Playing with the event loop
        3. Implementing the chat application
          1. Bootstrapping the project server-side
          2. Bootstrapping the HTML user interface
          3. Building a simple chat application
          4. Receiving messages
          5. Sending messages
          6. Testing the application
          7. Keeping the connection from timing out
        4. Deployment options
        5. Bridging Ratchet and PSR-7 applications
        6. Accessing your application via the web server
        7. Adding authentication
          1. Creating the login form
          2. Checking the authorization
          3. Connecting users and messages
        8. Summary
      13. 7. Building an Asynchronous Microservice Architecture
        1. The target architecture
        2. ZeroMQ patterns
          1. Request/reply pattern
          2. Publish/subscribe pattern
          3. Push/pull pattern
        3. Bootstrapping the project
        4. Building the inventory service
          1. Getting started with ZeroMQ REQ/REP sockets
          2. Using JsonRPC for communication
        5. Making the inventory service multithreaded
        6. Building the checkout service
          1. Using react/zmq
          2. Working with promises
        7. Building the mailing service
        8. Building the shipping service
          1. PUSH/PULL for beginners
          2. Fan-out/fan-in
        9. Bridging ZeroMQ and HTTP
        10. Summary
      14. 8. Building a Parser and Interpreter for a Custom Language
        1. How interpreters and compilers work
        2. Languages and grammars
        3. Your first PEG parser
        4. Evaluating expressions
        5. Building an Abstract Syntax Tree
        6. Building a better interface
        7. Evaluating variables
        8. Adding logical expressions
          1. Comparisons
          2. The "and" and "or" operators
          3. Conditions
        9. Working with structured data
        10. Working with objects
        11. Optimizing the interpreter by adding a compiler
        12. Verifying performance improvements
        13. Summary
      15. 9. Reactive Extensions in PHP
        1. An introduction to observables
        2. Introduction to event loop and ReactiveX
          1. delay
          2. defer
          3. Scheduler
          4. recursive-scheduler
          5. map and flatMap
          6. reduce
          7. toArray
          8. merge
          9. do
          10. scan
          11. zip
        3. Parsing logs through a Reactive scheduler
        4. Event queues with ReactiveX
        5. Summary

    Product information

    • Title: PHP 7 Programming Blueprints
    • Author(s): Jose Palala, Martin Helmich
    • Release date: October 2016
    • Publisher(s): Packt Publishing
    • ISBN: 9781785889714