Book Image

Phalcon Cookbook

By : Serghei Iakovlev, David Schissler
1 (2)
Book Image

Phalcon Cookbook

1 (2)
By: Serghei Iakovlev, David Schissler

Overview of this book

Phalcon is a high-performance PHP framework delivered as a PHP extension. This provides new opportunities for speed and application design, which until recently have been unrealized in the PHP ecosystem. Packed with simple learning exercises, technology prototypes, and real-world usable code, this book will guide you from the beginner and setup stage all the way to advanced usage. You will learn how to avoid niche pitfalls, how to use the command-line developer tools, how to integrate with new web standards, as well as how to set up and customize the MVC application structure. You will see how Phalcon can be used to quickly set up a single file web application as well as a complex multi-module application suitable for long-term projects. Some of the recipes focus on abstract concepts that are vital to get a deep comprehension of Phalcon and others are designed as a vehicle to deliver real-world usable classes and code snippets to solve advanced problems. You’ll start out with basic setup and application structure and then move onto the Phalcon MVC and routing implementation, the power of the ORM and Phalcon Query Language, and Phalcon’s own Volt templating system. Finally, you will move on to caching, security, and optimization.
Table of Contents (17 chapters)
Phalcon Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Detecting slow queries


As an application grows, its SQL queries can become quite complex and so slow that the entire application suffers. Without a clear path toward discovering the slowdown we would be in a difficult spot. This recipe will give us the tools to detect these exceptionally slow queries so that we can begin to develop optimizations or redesigns. Additionally, this will have a pleasant side effect of illustrating some nice details about how the Phalcon ORM (Object Relational Model) works by showing us all of the queries that are performed to set up this powerful functionality. Lastly, being able to see the metrics of these queries will give us ideas and entice us to think about how it can be further optimized with query caching.

Getting ready

This recipe uses Phalcon Developer Tools for setting up a project skeleton and a configured database connection for demonstrating the fast queries that are performed when setting up the ORM, as well as the synthetic slow queries that we...