Author: Awais Farooq
-
What is Phalcon?
Phalcon is a high-performance PHP web framework known for its speed and low resource consumption. It’s implemented as a C-extension for PHP, which sets it apart from other frameworks.
-
Phalcon Logging
This method found under directory Phalcon\Logger. It provides logging services for application. We can login to different backend using different adapters. It offers transaction logging, configuration options, different formats and filters. Adapters Adapters are used to store the logged messages. A list of supported adapters: Adapters Description Phalcon\Logger\Adapter\File Logs to a plain text file Phalcon\Logger\Adapter\Stream Logs…
-
Phalcon Class Autoloader
Loader is a class found under Phalcon\Loader directory. This class consists of some pre-defined rules according to rules it loads class automatically. It also handles error such as if a class does not exist but it is called in any part of program then special handler is called for handling. In Loader if a class is added according to…
-
Phalcon Configuration
It is a component which is used to convert configuration files into PHP. Its directory location is Phalcon\Config. Implementation Example: To convert native array into Phalcon\Config Objects. File Adapters Class Description Phalcon\Config\Adapter\Ini Uses INI files to store settings. Internally the adapter uses the PHP function parse_ini_file. Phalcon\Config\Adapter\Json Uses JSON files to store settings. Phalcon\Config\Adapter\Php Uses PHP multidimensional arrays to…
-
Cache
Cache is a class found under Phalcon\Cache directory. It helps in accessing frequently used data at much faster rate. Phalcon\Cache is written in C Programming language and reduce overhead. When to implement Cache? Caching process is divided into 2 parts: 1) Frontend: Frontend checks whether a key has expired or not. Also perform additional transformations to the data before storing and…
-
Cross-Site Request Forgery (CSRF) protection
CSRF protection is against the form elements such as in user registration or adding comments are vulnerable to this attack. CSRF is created to prevent the form values from being sent outside our application. To fix this, we generate a random nonce (token) in each form. We add the token in the session and then…
-
Phalcon Security
Phalcon provides the common security tasks to the developers such as: Password Hashing It is a technique where password is stored in the encrypted form in the database. If the password is stored in the plain text format then any intruder that has the access to the database can easily view the passwords. To avoid…
-
Phalcon Responses
In Phalcon when any request is generated, the user provides the manual response or the response is given by controller. Response file is generated under Phalcon\Http\Response. Http responses are usually composed by headers and body. Example Output Methods for Response Methods Description public setDI (Phalcon\DiInterface $dependencyInjector) Sets the dependency injector public getDI () Returns the internal…
-
Phalcon Cookie Management
Cookie is a small text file stored by browser on user system. Cookies were designed to be a reliable mechanism for websites to remember stateful information or to record the user’s browsing activity. Phalcon\Http\Response\Cookies is the directory where cookies are stored. Cookie management helps in storing cookies under the above directory during the request execution and is…
-
VOLT: Template Engine
Volt provides Phalcon fast execution as it is very fast and designer friendly templating language written in C for PHP. It has many helpers defined to write views. Volt is inspired by Jinja and written by Armin Ronacher. Implementation Volt views are compiled in php which saves time to write php code manually. Activating Volt In…