O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning PHP 7 High Performance

Book Description

Improve the performance of your PHP application to ensure the application users aren't left waiting

About This Book

  • Make the optimum use of PHP coding to improve your programming productivity
  • Leverage the potential of PHP for server-side programming, memory management, and object-oriented programming
  • Packed with real-life examples to help the readers implement concepts as they learn

Who This Book Is For

This book is for those who have basic experience in PHP programming. If you are developing performance-critical applications, then this book is for you.

What You Will Learn

  • Setup high performance development and production environment for PHP 7
  • Discover new OOP features in PHP 7 to achieve high performance
  • Improve your PHP applications' performance
  • Attain improved database performance
  • Benchmark PHP applications to optimize them
  • Write quality code by learning to improve code reusability, simplicity, and expressiveness
  • Get rid of the bottlenecks in your PHP 7 applications by writing PHP code optimally
  • Tackle issues related to web applications, such as high user dependency and large datasets

In Detail

PHP is a great language for building web applications. It is essentially a server-side scripting language that is also used for general-purpose programming. PHP 7 is the latest version, providing major backward-compatibility breaks and focusing on high performance and speed.

This fast-paced introduction to PHP 7 will improve your productivity and coding skills. The concepts covered will allow you, as a PHP programmer, to improve the performance standards of your applications. We will introduce you to the new features in PHP 7 and then will run through the concepts of object-oriented programming (OOP) in PHP 7. Next, we will shed some light on how to improve your PHP 7 applications' performance and database performance. Through this book, you will be able to improve the performance of your programs using the various benchmarking tools discussed.

At the end, the book discusses some best practices in PHP programming to help you improve the quality of your code.

Style and approach

The book is a step-by-step guide to improve the quality of your code in PHP through real-time examples. The book takes a practical approach to improving the quality of your code.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Learning PHP 7 High Performance
    1. Table of Contents
    2. Learning PHP 7 High Performance
    3. Credits
    4. About the Author
    5. Acknowledgement
    6. About the Reviewer
    7. www.PacktPub.com
      1. eBooks, discount offers, and more
        1. Why subscribe?
    8. 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
    9. 1. Setting Up the Environment
      1. Setting up Windows
      2. Setting up Debian or Ubuntu
        1. Debian
        2. Ubuntu
      3. Setting up CentOS
        1. Installing NGINX
        2. Installing PHP 7
        3. Installing Percona Server
      4. Setting up Vagrant
      5. Summary
    10. 2. New Features in PHP 7
      1. OOP features
        1. Type hints
          1. Scalar type hints
          2. Return type hints
        2. Namespaces and group use declaration
          1. Non mixed group use declarations
          2. Mixed group use declarations
          3. The compound namespace declaration
        3. The anonymous classes
        4. Old-style constructor deprecation
        5. The throwable interface
          1. Error
      2. New operators
        1. The Spaceship operator (<=>)
        2. The null coalesce operator(??)
      3. Uniform variable syntax
      4. Miscellaneous features and changes
        1. Constant arrays
        2. Multiple default cases in the switch statement
        3. The options array for session_start function
        4. Filtered unserialize function
      5. Summary
    11. 3. Improving PHP 7 Application Performance
      1. NGINX and Apache
        1. Apache
        2. NGINX
      2. HTTP server optimization
        1. Caching static files
          1. Apache
          2. NGINX
      3. HTTP persistent connection
        1. Apache
        2. NGINX
        3. GZIP compression
          1. Apache
          2. NGINX
        4. Using PHP as a separate service
        5. Disabling unused modules
          1. Apache
          2. NGINX
        6. Web server resources
          1. NGINX
      4. Content Delivery Network (CDN)
        1. Using CDN
      5. CSS and JavaScript optimization
        1. Merging
        2. Minifying
          1. Minify
          2. Grunt
      6. Full page caching
      7. Varnish
      8. The infrastructure
        1. Web servers
        2. The database server
        3. Load balancer (LB)
        4. HAProxy load balancing
          1. HAProxy installation
          2. HAProxy load balancing
      9. Summary
    12. 4. Improving Database Performance
      1. The MySQL database
        1. Query caching
      2. Storage engines
        1. The MyISAM storage engine
        2. The InnoDB storage engine
          1. innodb_buffer_pool_size
          2. innodb_buffer_pool_instances
          3. innodb_log_file_size
      3. The Percona Server - a fork of MySQL
        1. Installing the Percona Server
      4. MySQL performance monitoring tools
        1. phpMyAdmin
        2. The MySQL workbench
        3. Percona Toolkit
          1. pt-query-digest
          2. pt-duplicate-key-checker
      5. Percona XtraDB Cluster (PXC)
      6. Redis – the key-value cache store
        1. Connecting with the Redis server
        2. Storing and fetching data from the Redis server
        3. Redis management tools
      7. Memcached key-value cache store
      8. Summary
    13. 5. Debugging and Profiling
      1. Xdebug
        1. Debugging with Sublime Text
        2. Debugging with Eclipse
      2. Profiling with Xdebug
      3. PHP DebugBar
      4. Summary
    14. 6. Stress/Load Testing PHP Applications
      1. Apache JMeter
      2. ApacheBench (ab)
      3. Siege
      4. Load testing real-world applications
        1. Magento 2
        2. WordPress 4
        3. Drupal 8
      5. Summary
    15. 7. Best Practices in PHP Programming
      1. Coding styles
      2. Test-driven development (TDD)
      3. Design patterns
      4. Service-oriented architecture (SOA)
      5. Being object-oriented and reusable always
      6. PHP frameworks
      7. Version control system (VCS) and Git
      8. Deployment and Continuous Integration (CI)
      9. Summary
    16. A. Tools to Make Life Easy
      1. Composer – A dependency manager for PHP
        1. Composer installation
        2. Using Composer
      2. Git – A version control system
        1. Git installation
        2. Using Git
        3. Creating new branches and merging
        4. Cloning a repository
        5. Webhooks
        6. Desktop tools to manage repositories
      3. Grunt watch
      4. Summary
    17. B. MVC and Frameworks
      1. The MVC design pattern
        1. Model
        3. Controllers
      2. Laravel
        1. Installation
        2. Features
          1. Routing
        3. Eloquent ORM
        4. Artisan CLI
        5. Migrations
        6. Blade templates
        7. Other features
      3. Lumen
      4. Apigility
      5. Summary
    18. Index