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

Introduction


Despite the fact that Phalcon is a framework for PHP application development, it isn't itself PHP-based. Therefore, some difficulties may appear when using syntax highlighting or code autocompletion. In this chapter, we will try to study how to set up autocompletion in a modern Integrated Development Environment (IDE) and how to enable code autocompletion.

An essential step in the architecture process when developing an application is a clear understanding of the project directory structure and the role of each of the directories. We will use a variation of a Phalcon project directory structure, which is easy to deploy and upgrade. The directory structure, which we work with in this chapter, isn't a rule set in stone. In future you will, time after time, use different directory structures, which will be different than the one we will be using. That structure is only one of the options and a starting point for your needs, and it easily responds to changes caused by certain technical conditions.

Phalcon is not only the fastest framework in the world, it is one of the easiest frameworks. As a rule, you don't need any special knowledge or additional software. However, when developing an application with Phalcon, you will need to create a base system configuration and application skeleton. In this chapter, we will learn how to deploy an application with the use of Phalcon, how to make its base configuration, and how to create a flexible and efficient application skeleton, which you can use in future.

Any object-oriented PHP application needs classes. You have to tell your class autoloader where your classes are situated and which way they can be searched for. We will look at some possible options of class auto-loading in Phalcon and their usage methods.

Many developers, despite their experience, have difficulty when working with a Request component. Phalcon isn't an exception. We will discover how to make a base application configuration so that Phalcon starts handling requests. We will learn how Phalcon handles these requests and in what sequence they are executed. We will learn which components take part in a request life cycle, where it is possible to catch the request, how to specify its state, as well as how to take any suitable actions.