Home » Symfony » How to Create a Page for your Website Using Symfony

How to Create a Page for your Website Using Symfony

19 October 2011
  1. Update the “routing.yml” file found in (apps/frontend/config/routing.yml) with the correct URL and Param (module and action).
  2. Create a folder inside the modules (apps/frontend/modules/) folder and name it whatever you want the module to be called.
  3. Create an “actions” folder and “templates” folder inside the module folder you just created.
    • Example: apps/frontend/modules/page/actions or apps/frontend/modules/page/templates. In this example “page” is our module folder.
  4. Create an “actions.class.php” file and save it inside the “actions” folder in the module folder it belongs to.
    1. Create a class, name it after the module. i.e. if module name is “page”, class will be as follows:
      • class pageActions extends sfActions{}
    2. Create functions inside the newly created class. The function names must begin with “execute” followed by the name of the template you created that associates with the action.
      • For example: We created a template called “indexSuccess.php” so the corresponding function will be:
        • public function executeIndex(sfWebRequest $request){}
  5. Create an “indexSuccess.php” file and save it inside the “templates” folder in the module folder it belongs to.
    1. This will be the homepage, so input any PHP or HTML necessary for your homepage.
    2. When saving your template remember to name it according to which function action it belongs to in your actions class.
      • For example: We created a function called “executeIndex” in our “actions.class.php” file that’s saved in the actions folder. So we will name our file, “index” for the function action followed by Success (all templates will have the word “Success” as the second word).
        • “indexSuccess.php”

Symfony , , , , , , , , ,

No Comments to “How to Create a Page for your Website Using Symfony”

Leave a Reply

(required)

(required)