পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Wednesday, March 8, 2017

Phalcon - Controllers

In MVC framework, “C” stands for the Controller which refers to the switchboards of the web application. The actions undertaken by the controller, helps to pass parameters to the view so that it can display and respond to the user input accordingly.

For example, if we register through a sign-up form which includes details of the user such as username, email address and password, and click the Submit button, the data inserted or posted by the user is sent through the controller with the help of associated action or function.

Features of a Controller

A controller accepts inputs from the view and interacts with the associated model.
  • It helps in updating the model's state by sending commands to the model. It can also send commands to the associated view, which helps in changing the presentation of the view as per the model's state.
  • A controller acts as an intermediary between the model and the view.

Workflow of a MVC in Phalcon

The following illustration shows the workflow of MVC in Phalcon
Workflow MVC

Steps to Create a Controller in Phalcon

Step 1 − Redirect to the project path with the help of command prompt. Refer to the following screenshot.
Create Controller As referred in the above screenshot, “demo” is the project associated with Phalcon PHP framework.
Step 2 − Use the following command to create an associated controller.
phalcon controller <controller-name> 
Following is the output on successful execution of the above command.
Execution Note − The class names of the controllers must have the suffix “controller”. This implies a good naming convention which is followed in Phalcon.
By default, when the application is created in Phalcon PHP framework, it includes a controller named “IndexController”. This controller is invoked by default to trigger the actions.
This controller is extended by controller-base unlike other controllers which extends \Phalcon\Mvc\Controller.
Code
<?php 
class IndexController extends ControllerBase { 
   public function indexAction() { 
      echo "This is my first web application in Phalcon"; 
   } 
}
Output
PHP Framework

No comments:

Post a Comment