Installation and Configuration Symfony Framework

Symfony is an open-source PHP web application framework with MVC architecture. It is a set of reusable PHP components/libraries. It is basically designed for developers who need an elegant and simple toolkit to create web applications and is the most popular application frameworks among the open-source developer’s community. It is used to build high-performance complex web applications.

Prerequisites:

Installation:

  • Step 1: Go to xampp root folder and open htdocs folder there. Type “cmd” (without inverted commas) in the address bar(shown below) and hit enter.
  • Step 2: Enter the following command in the command prompt.
    composer create-project symfony/skeleton project_1

    In my case the name of project is project_1, you may take any name of your choice.
    If you see something like this then your project is created successfully.

  • Step 3: Start your xampp server and goto localhost/project_1/public.
    If you see something like this then your project is created successfully.

First Project: Here we will create a Hello World page in three steps.

  • Step 1: Create a new file named “HelloController.php” in src/Controller/ folder and write the following code in that file.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <?php
    namespace App\Controller;
    use Symfony\Component\HttpFoundation\Response;
    class HelloController
    {
        public function hello()
        {
            return new Response(
                'Hello World'
            );
        }
    }

    chevron_right

    
    

  • Step 2: Open config/routes.yaml file and write the following code in that file.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    app_hello:
        path: /
        controller: App\Controller\HelloController::hello

    chevron_right

    
    

  • Step 3: Goto localhost/project_1/public.
    If you see something like this then you have successfully created hello world page.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


3


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.