Phalcon Cookbook
eBook - ePub

Phalcon Cookbook

  1. 386 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

About this book

Master Phalcon by implementing hands-on recipes using industry best practices with the Web and CLI interfacesAbout This Book• Create quick prototypes with the Phalcon Developer Tools• Learn to use the powerful and uniquely efficient Phalcon ORM• Reuse codes in real projects Who This Book Is ForIf you are a beginner-to-intermediate Phalcon developer who wants to level up or an advanced user who is seeking some new techniques and insight, then this book is perfect for you. This book will be relevant to you over a long period of time due to the mixed nature of this book in providing both abstract comprehension as well as specific examples meant to be usable in your projects. You will be able to experiment with each new aspect of integration in prebuilt recipes meant to best illustrate each specific feature. This will save you lots of time getting up to speed before attempting to integrate into a real application.What You Will Learn• Install the Phalcon extension from both premade packages and source code• Create a normal and micro application structure• Understand the dispatcher event cycle and create custom plugins• Get hands-on using the Phalcon Query Language and ORM • Create flexible views with the Volt template system• Leverage Phalcon to prevent common security vulnerabilities• Optimize an application with focused solutions• Profile and debug an application to get increased reliabilityIn DetailPhalcon 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.Style and approachAn easy-to-start guide that provides

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Phalcon Cookbook by David Schissler, Serghei Iakovlev in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Engineering. We have over one million books available in our catalogue for you to explore.

Information

Phalcon Cookbook


Table of Contents

Phalcon Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why Subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There’s more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Used to Phalcon
Introduction
Getting your IDE to work nicely with Phalcon
Getting ready
How to do it…
Ways to enable Phalcon API autocompletion in major IDEs
PhpStorm
NetBeans
Ways to enable Volt syntax highlighting in major IDEs
Netbeans
PhpStorm
Syntax highlighting for Sublime Text or TextMate
Installation via Package Control
Manual installation
How it works…
Creating the application directory structure
Getting ready
How to do it…
How it works…
Setting up your request entry point
Getting ready
How to do it…
How it works…
Easily loading code on demand
Getting ready
How to do it…
How it works…
There's more…
Setting up your request entry point
Getting ready
How to do it…
How it works…
There's more…
Understanding the request life cycle
Getting ready
How to do it…
How it works...
There's more…
See also
2. Structuring Your Projects
Introduction
Choosing the best place for an implementation
Getting ready
How to do it…
How it works…
Automation of routine tasks
Getting ready
How to do it…
How it works…
There's more…
Creating the application structure by using code generation tools
Getting ready
How to do it…
How it works…
There's more…
Get more power by adding a middleware between Phalcon and your application
Getting ready
How to do it…
Logging critical errors
Changing the description and keywords meta tags depending on your route
Receiving site status reports
Caching pages to reduce processing
Redirecting the user to the login screen if access to the resource is protected
How it works…
There's more…
3. Processing Requests
Introduction
Understanding the default routing strategy for controllers
Getting ready
How to do it…
Handling a request along multiple controllers
Getting ready
How to do it…
How it works…
Using flexible key-value action parameter pairs
Getting ready
How to do it…
How it works…
Restricting controllers by managing end user privileges
Getting ready
How to do it…
How it works…
Making unsuccessful requests fail softly
Getting ready
How to do it…
How it works…
Creating a server-sent message server
Getting ready
How to do it…
How it works…
Creating a Ratchet Websocket server
Getting ready
How to do it…
How it works…
4. Dealing with Data
Introduction
Preparation
Applying your own naming conventions to models
Getting ready
How to do it…
How it works…
Defining relationships between models
Getting ready
How to do it…
How it works…
Using the query builder for complex yet fluent model querying
Getting ready
How to do it…
How it works…
Being aware of PHQL capabilities
Getting ready
How to do it…
How it works…
Fetching models from raw SQL queries
Getting ready
How to do it…
How it works…
Getting the most out of your RDBMS of choice
Getting ready
How to do it…
How it works…
Using models as information repositories
Getting ready
How to do it…
How it works…
Storing models across multiple databases
Getting ready
How to do it…
How it works…
5. Presenting Your Application
Introduction
HTML fragments for AJAX-based applications
Getting ready
How to do it…
How it works…
There's more…
See also
Splitting your layout structure
Getting ready
How to do it…
How it works…
Volt and dynamic view implementations
Getting ready…
How to do it…
How it works…
Presenting models nicely
Getting ready
How to do it…
How it works…
There's more…
See also
Reusing view snippets
Getting ready
How to do it…
How it works…
Creating your own Volt keywords and methods
Getting ready
How to do it…
How it works…
There's more…
6. Making Use of Advanced Features
Introduction
Registering dependencies in an effective way
Getting ready
How to do it…
How it works…
There's more…
See also
Using the DI container on different scopes
Getting ready
How to do it…
How it works…
There's more…
See also
Unleashing the real power of event driven programming
Getting ready
How to do it…
How it works…
There's more…
Centralizing validations for rock solid business rules
Getting ready
How to do it…
How it works…
There's more…
Complex routing with regular expressions
Getting ready
How to do it…
How it works…
There's more…
Using in-memory session handlers
Getting ready
How to do it…
How it works…
There's more…
Handy persistence for controllers and components
Getting ready
How to do it…
How it works…
There's more…
Transactional controller actions ensuring consistent operations
Getting ready
How to do it…
How it works…
There's more…
Auditing complex user actions with simplicity
Getting ready
How to do it…
How it works…
There's more…
7. Debugging and Profiling
Introduction
Improved exception reporting
Getting ready
How to do it…
How it works…
Logging server messages to the browser console
Getting ready
How to do it…
How it works…
Creating a route test suite
Getting ready
How to do it…
How it works…
Handling abnormal terminations
Getting ready
How to do it…
How it works…
Detecting slow queries
Getting ready
How to do it…
How it works…
8. Fine Tuning and Optimizing
Introduction
Handling a database timeout
Getting ready
How to do it…
How it works…
Precompiling Volt templates for increased performance and security
Getting ready
How to do it…
How it works…
Optimizing PHQL queries
Getting ready
How to do it…
How it works…
Caching model metadata and query results for faster performance
Getting ready
How to do it…
How it works…
9. High Performance Applications with Phalcon
Introduction
Introduction to asynchronous work by using Beanstalk
Getting ready
How to do it…
How it works…
There's more…
Implementing a three-level cache to increase performance
Getting ready
How to do it…
How it works…
There's more…
Cache view fragments or full pages in Phalcon
Getting ready
How to do it…
How it works…
There's more…
Implementing your own cache adapters
Getting ready
How to do it…
How it works…
There's more…
Cache data to reduce access to database systems
Getting ready
How to do it…
How it works…
There's more…
Creating a PHP extension using Zephir
Getting ready
How to do it…
How it works…
There's more…
Extending Phalcon using Zephir
Getting ready
How to do it…
How it works…
There's more…
See also
10. Securing Your Applications
Introduction
Securing data with encryption
Getting ready…
How to do it…
How it works…
Securing passwords with hashing
Getting ready
How to do it…
How it works…
Preventing Cross-site scripting (XSS) attacks
Getting ready…
How to do it…
How it works…
Preventing Cross-Site Request Forgery (CSRF) attacks
Getting ready…
How to do it…
How it works…
Implementing alternative access control lists
Getting ready…
How to do it…
How it wo...

Table of contents

  1. Phalcon Cookbook