Phalcon Interview Questions for freshers experienced :-
1. What is Phalcon?
Phalcon is an open source framework based on the MVC (Model-View-Controller) pattern. It is the combination of PHP and C language. It is developed by Andres Gutierrez and his group of collaborators.
2. Which language supports Phalcon Framework?
Phalcon Framework supports two language that are : C & PHP.
3. What is the initial date of Phalcon framework?
Initial date of Phylcon framework is: 14 November 2012.
4. What are the features of Phalcon Framework?
Phalcon Framework features are:
- Low overhead
- MVC & HMVC Pattern
- Dependency Injection
- Support for Rest
- Autoloader
- Router
5. Explain directory structure of Phalcon Framework ?
Phalcon Framework directory structure are given below:
- App
- Config
- Controllers
- Library
- Migrations
- Models
- Views
- Cache
- Public
- Css
- files
- img
- js
- temp
- .htaccess
- .htaccess
- .htrouter.php
- index.html
6. What are database related functions in Phalcon?
In Phalcon, database related functions are:
- find()
- findFirst()
- query()
- findFirstBy etc.
7. What are database engines supported by Phalcon?
Phalcon supported PDO_ database engines that are:
- Phalcon\Db\Adapter\Pdo\Mysql : Mysql
- Phalcon\Db\Adapter\Pdo\Postgresql : Postgresql
- Phalcon\Db\Adapter\Pdo\Sqlite : Sqlite
8. What is zephir in Phalcon ?
Zephir stands for Ze(nd Engine) Ph(p) I(nt)r(mediate) . It is a high level language. It is used for creation and maintainability of extensions for PHP. It exported to C code that can be compiled and optimized by major C compilers such as gcc/clang/vc++.
9. What are the various type of application events in Phalcon?
In Phalcon, there are various tyes of application event :
Event Name Triggered
boot Executed when the application handles its first request
before StartModule Before initialize a module, only when modules are registered
afterStartModule After initialize a module, only when modules are registered
beforeHandleRequest Before execute the dispatch loop
afterHandleRequest After execute the dispatch loop
10. How can we pass data from conroller to view in Phalcon ?
In Phalcon, we can pass data from controller to view by setVar() method.
$this->view->setVar(“username”, $user->username);
11. How can we increase csrf timeout in Phalcon ?
In Phalcon, we can increase csrf (Cross-Site Request Forgery) timeout by increase the token time because tokens default uses sessions.
12. Which template engine Phalcon Use ?
Phalcon uses a Volt template engine.
13. How can we inject services into a Volt template?
We can inject services into a Volt template by using following code:
{# Inject the ‘flash’ service #}
<div id=”messages”>{{ flash.output() }}</div>
{# Inject the ‘security’ service #}
14. What is PHQL in Phalcon Framework?
In Phalcon Framework, PHQL stands for Phalcon Query Language, It allows to write queries by using a standardized SQL-like language.
15. How can we read, write and delete sessions in Phalcon?
In Phalcon, we can read, write and delete sessions by using following code:
Creating session: $this->session->set(“user-name”, “Michael”);
Reading or Retriving session: $this->session->get(“user-name”);
Deleting or Removing session: $this->session->remove(“user-name”);
17. Does Phalcon support multiple web server?
Yes, Phalcon supports multiple web server.
18. What are the features of a controller?
There are following features of a controller.
- It helps to update the model’s state by sending command to the model.
- It is also used to send command to the associated view.
- It acts as an intermediary between the model and the view.
19. How many type of views in Phalcon?
In Phalcon, there are two type of views:
- .Volt
- .Phtml
20. What are the differences between .volt and .phtml files?
There are various differences between .volt and .phtml that are given below in table:
.volt .phtml
It is used when the template engine set up. It is used when the template engine is PHP itself.
It can be used as a stand-alone component. It cannot be used as a stand-alone component.
Volt views are compiled to PHP code. It includes PHP volt so there is no need of compilation in Phalcon framework.
21. What are the different type of HTTP methods?
There are various different type of HTTP methods:
- GET : It is used to retrieve and search data.
- POST: It is used to add data.
- PUT : It is used to update data.
- DELETE: It is used to delete data.
22. How can we declare variable in Phalcon?
In Phalcon, we can declare variable by using set.
Example:
1. {% set fruits = [‘Apple’, ‘Banana’, ‘Orange’] %} // array declare
2. {% set name = “John Kennedy” %} // string declare
23. Does Phalcon support multiple Databases?
Yes, Phalcon supports multiple Databases.
24. at is PHQL in Phalcon?
In Phalcon, PHQL stands for Phalcon Query Language. It is a high-level SQL that standardize SQL queries for the database system.
Example:
// Instantiate the Query
$query = new Query(
“SELECT * FROM Users”,
$this->getDI()
);
// Execute the query returning a result if any
$cars = $query->execute();
25. What are cookies and its types?
Cookies stores small text files in browser. It is known as browser cookies.
Types of cookies are:
- Session cookies
- Persistent cookies
26. How can we create a session with a name and value in Phalcon?
The following code is used to create a session with a name and value in Phalcon.
<?php
class SessionController extends \Phalcon\Mvc\Controller {
public function indexAction() {
//Define a session variable
$this->session->set(“user-name”, “Omkar”);
//Check if the variable is defined
if ($this->session->has(“user-name”)) {
//Retrieve its value
$name = $this->session->get(“user-name”);
echo($name);
}
}
}
27. What are the difference between SQL and NoSQL?
There are following difference between SQL and NoSQL
SQL NoSQL
It is also termed as Relational Databases (RDBMS). It is called as non-relational or distributed database.
The structure of database is constituted as tables and views. It consists of document based and graph databases.
It includes a predefined schema. It has a dynamic schema.
It is very powerful for defining and manipulating data. It is powerful in maintaining data as collection of documents.
28. Which protocol is used to encrypt the password in Phalcon?
In Phalcon, md5, base64 and sh1 protocol is used to encrypt the password.
29. What is CSRF?
CSRF stands for Cross Site Request Forgery. It is an attack which forces authenticated user of web applications. It performs certain unwanted action.