Book Image

Getting Started with Phalcon

By : Stephan A. Miller
Book Image

Getting Started with Phalcon

By: Stephan A. Miller

Overview of this book

<p>Phalcon is an open source PHP framework which makes developing with PHP easier and more efficient by combining the speed and performance of C with the unique development features of the MVC architecture. Phalcon is installed as a PHP module so you don’t have to download an archive like you do with other frameworks, and building projects is made easier with its controllers and models. The Phalcon Query Language (PHQL) makes this tool even more expressive and clean. Its reputation as the most downloaded PHP tool is definitely justified by its rich offerings. This tutorial provides you with the knowledge you need to build your very own web application with the revolutionary Phalcon framework. This comprehensive guide will start by describing the installation of Phalcon PHP. You will then learn how to build projects and how to further utilize the Phalcon Developer Tools to build models, views, and controllers with the central example of a blog application. Features like PHQL are also explained and implemented effectively throughout the book. The genius in you will be revered by the stunning web application that you will be able to create by reading this book. This handy guide gives you a detailed introduction to using the remarkable Phalcon framework to develop web applications. You will begin by learning how to install the Phalcon module and how to build your own projects. The blog application is the central example throughout the book, and by using Phalcon Developer Tools and web tools, you will create and optimize the basic skeleton for your application with ease and efficiency. You will learn how to add rich features to your blog using Phalcon Views, Models, and Controllers. You will also gain expertise in Phalcon functionalities like the Volt template engine, view helpers, PHQL, and so on. This is an invaluable tutorial for enthusiasts and developers alike who wish to use the fascinating Phalcon PHP framework to rapidly design and develop impressive web applications.</p>
Table of Contents (12 chapters)
Getting Started with Phalcon
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Filtering and sanitizing data


To prevent unauthorized access, SQL injection, and other malicious attacks on our application, we need to filter and sanitize user input. We can use the Phalcon\Filter component to do this for us. This component supplies wrappers for the PHP filter extension.

Securing your application is beyond the scope of this book, but we can take a look at a filter that Phalcon development tools already added for us when we named one of our user field's e-mail. In the UsersControllers.php file located at app/controller, you will find that the createAction function has the following line of code:

$user->email = $this->request->getPost("email", "email");

The filter object is accessed through the Phalcon request object. The first parameter is the name of the variable we are accessing, and the second optional parameter is our filter. Phalcon has the following built-in filters:

Name

Description

string

Strips tags

email

Removes all characters except letters, digits...